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> |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 81 | #include <linux/ethtool.h> |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 82 | |
| 83 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
| 84 | #include "qdf_periodic_work.h" |
| 85 | #endif |
| 86 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 87 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 88 | #include <soc/qcom/subsystem_restart.h> |
| 89 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 90 | #include <wlan_hdd_hostapd.h> |
| 91 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 92 | #include <wlan_hdd_green_ap.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 93 | #include "qwlan_version.h" |
| 94 | #include "wma_types.h" |
| 95 | #include "wlan_hdd_tdls.h" |
| 96 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 97 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 98 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 99 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 100 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 101 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 102 | #include "wlan_hdd_nan.h" |
| 103 | #include "wlan_hdd_debugfs.h" |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 104 | #include "wlan_hdd_debugfs_csr.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 105 | #include "wlan_hdd_driver_ops.h" |
| 106 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 107 | #include "wlan_hdd_data_stall_detection.h" |
stonez | c9936cb | 2019-03-11 16:41:22 +0800 | [diff] [blame] | 108 | #include "wlan_hdd_mpta_helper.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 109 | |
| 110 | #include <wlan_hdd_ipa.h> |
| 111 | #include "hif.h" |
| 112 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 113 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 114 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 115 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 116 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 117 | #include "wlan_hdd_lpass.h" |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 118 | #include "wlan_nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 119 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 120 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 121 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 122 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 123 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 124 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 125 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 126 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 127 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 128 | #include "os_if_wifi_pos.h" |
| 129 | #include "wifi_pos_api.h" |
| 130 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 131 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 132 | #include "os_if_nan.h" |
| 133 | #include "nan_public_structs.h" |
Nachiket Kukade | 85aa378 | 2018-11-02 20:12:34 +0530 | [diff] [blame] | 134 | #include "nan_ucfg_api.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 135 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 136 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 137 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 138 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 139 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 140 | #include <cdp_txrx_cmn_struct.h> |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 141 | #include <dp_txrx.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 142 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 143 | #include "wlan_disa_ucfg_api.h" |
Wu Gao | 52084c1 | 2018-05-17 20:47:11 +0800 | [diff] [blame] | 144 | #include "wlan_disa_obj_mgmt_api.h" |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 145 | #include "wlan_action_oui_ucfg_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 146 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 147 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 148 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 149 | #include "wlan_hdd_apf.h" |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 150 | #include "wlan_hdd_twt.h" |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 151 | #include "qc_sap_ioctl.h" |
Sandeep Puligilla | c5609d5 | 2018-05-17 19:23:41 -0700 | [diff] [blame] | 152 | #include "wlan_mlme_main.h" |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 153 | #include "wlan_p2p_cfg_api.h" |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 154 | #include "wlan_cfg80211_p2p.h" |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame^] | 155 | #include "wlan_cfg80211_interop_issues_ap.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> |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame^] | 169 | #include <wlan_interop_issues_ap_ucfg_api.h> |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 170 | #include <target_type.h> |
Arun Kumar Khandavalli | deda5a8 | 2019-03-11 15:32:19 +0530 | [diff] [blame] | 171 | #include <wlan_hdd_debugfs_coex.h> |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 172 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 173 | #ifdef MODULE |
| 174 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 175 | #else |
| 176 | #define WLAN_MODULE_NAME "wlan" |
| 177 | #endif |
| 178 | |
| 179 | #ifdef TIMER_MANAGER |
| 180 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 181 | #else |
| 182 | #define TIMER_MANAGER_STR "" |
| 183 | #endif |
| 184 | |
| 185 | #ifdef MEMORY_DEBUG |
| 186 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 187 | #else |
| 188 | #define MEMORY_DEBUG_STR "" |
| 189 | #endif |
| 190 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 191 | #ifdef PANIC_ON_BUG |
| 192 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 193 | #else |
| 194 | #define PANIC_ON_BUG_STR "" |
| 195 | #endif |
| 196 | |
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}, |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame^] | 324 | [QDF_MODULE_ID_INTEROP_ISSUES_AP] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 325 | }; |
| 326 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 327 | struct notifier_block hdd_netdev_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 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 691 | return 0; |
| 692 | } |
| 693 | |
Will Huang | 79af29f | 2019-04-11 15:46:26 +0800 | [diff] [blame] | 694 | uint8_t hdd_get_adapter_home_channel(struct hdd_adapter *adapter) |
| 695 | { |
| 696 | uint8_t home_channel = 0; |
| 697 | |
| 698 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 699 | adapter->device_mode == QDF_P2P_GO_MODE) && |
| 700 | test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
| 701 | home_channel = adapter->session.ap.operating_channel; |
| 702 | } else if ((adapter->device_mode == QDF_STA_MODE || |
| 703 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
| 704 | adapter->session.station.conn_info.conn_state == |
| 705 | eConnectionState_Associated) { |
| 706 | home_channel = |
| 707 | adapter->session.station.conn_info.channel; |
| 708 | } |
| 709 | |
| 710 | return home_channel; |
| 711 | } |
| 712 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 713 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 714 | static inline struct net_device *hdd_net_dev_from_notifier(void *context) |
| 715 | { |
| 716 | struct netdev_notifier_info *info = context; |
| 717 | |
| 718 | return info->dev; |
| 719 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 720 | #else |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 721 | static inline struct net_device *hdd_net_dev_from_notifier(void *context) |
| 722 | { |
| 723 | return context; |
| 724 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 725 | #endif |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 726 | |
| 727 | static int __hdd_netdev_notifier_call(struct net_device *net_dev, |
| 728 | unsigned long state) |
| 729 | { |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 730 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 731 | struct hdd_context *hdd_ctx; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 732 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 733 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 734 | hdd_enter_dev(net_dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 735 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 736 | if (!net_dev->ieee80211_ptr) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 737 | hdd_debug("ieee80211_ptr is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 738 | return NOTIFY_DONE; |
| 739 | } |
| 740 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 741 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 742 | if (!hdd_ctx) { |
| 743 | hdd_err("HDD Context is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 744 | return NOTIFY_DONE; |
| 745 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 746 | |
| 747 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 748 | hdd_debug("%s: Driver module is closed", __func__); |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 749 | return NOTIFY_DONE; |
| 750 | } |
| 751 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 752 | /* Make sure that this callback corresponds to our device. */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 753 | adapter = hdd_get_adapter_by_iface_name(hdd_ctx, net_dev->name); |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 754 | if (!adapter) { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 755 | hdd_debug("failed to look up adapter for '%s'", net_dev->name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 756 | return NOTIFY_DONE; |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 757 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 758 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 759 | if (adapter != WLAN_HDD_GET_PRIV_PTR(net_dev)) { |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 760 | hdd_err("HDD adapter mismatch!"); |
| 761 | return NOTIFY_DONE; |
| 762 | } |
| 763 | |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 764 | if (cds_is_driver_recovering()) { |
| 765 | hdd_debug("Driver is recovering"); |
| 766 | return NOTIFY_DONE; |
| 767 | } |
| 768 | |
| 769 | if (cds_is_driver_in_bad_state()) { |
| 770 | hdd_debug("Driver is in failed recovery state"); |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 771 | return NOTIFY_DONE; |
| 772 | } |
| 773 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 774 | hdd_debug("%s New Net Device State = %lu", net_dev->name, state); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 775 | |
| 776 | switch (state) { |
| 777 | case NETDEV_REGISTER: |
| 778 | break; |
| 779 | |
| 780 | case NETDEV_UNREGISTER: |
| 781 | break; |
| 782 | |
| 783 | case NETDEV_UP: |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 784 | sme_ch_avoid_update_req(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 785 | break; |
| 786 | |
| 787 | case NETDEV_DOWN: |
| 788 | break; |
| 789 | |
| 790 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 791 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 792 | complete(&adapter->linkup_event_var); |
| 793 | break; |
| 794 | |
| 795 | case NETDEV_GOING_DOWN: |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 796 | vdev = hdd_objmgr_get_vdev(adapter); |
| 797 | if (!vdev) |
| 798 | break; |
| 799 | if (ucfg_scan_get_vdev_status(vdev) != |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 800 | SCAN_NOT_IN_PROGRESS) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 801 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 802 | adapter->vdev_id, INVALID_SCAN_ID, |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 803 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 804 | } |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 805 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 806 | cds_flush_work(&adapter->scan_block_work); |
| 807 | /* Need to clean up blocked scan request */ |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 808 | wlan_hdd_cfg80211_scan_block(adapter); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 809 | hdd_debug("Scan is not Pending from user"); |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 810 | /* |
| 811 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 812 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 813 | * flag after which driver does not send the cfg80211_scan_done. |
| 814 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 815 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 816 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, net_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 817 | break; |
| 818 | |
| 819 | default: |
| 820 | break; |
| 821 | } |
| 822 | |
| 823 | return NOTIFY_DONE; |
| 824 | } |
| 825 | |
| 826 | /** |
| 827 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 828 | * @nb: pointer to notifier block |
| 829 | * @state: state |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 830 | * @context: notifier callback context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 831 | * |
| 832 | * Return: 0 on success, error number otherwise. |
| 833 | */ |
| 834 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 835 | unsigned long state, |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 836 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 837 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 838 | struct net_device *net_dev = hdd_net_dev_from_notifier(context); |
| 839 | struct osif_vdev_sync *vdev_sync; |
| 840 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 841 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 842 | errno = osif_vdev_sync_op_start(net_dev, &vdev_sync); |
| 843 | if (errno) |
| 844 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 845 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 846 | errno = __hdd_netdev_notifier_call(net_dev, state); |
| 847 | |
| 848 | osif_vdev_sync_op_stop(vdev_sync); |
| 849 | |
| 850 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 851 | } |
| 852 | |
| 853 | struct notifier_block hdd_netdev_notifier = { |
| 854 | .notifier_call = hdd_netdev_notifier_call, |
| 855 | }; |
| 856 | |
| 857 | /* variable to hold the insmod parameters */ |
| 858 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 859 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 860 | static int con_mode_ftm; |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 861 | int con_mode_epping; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 862 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 863 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 864 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 865 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 866 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 867 | /** |
| 868 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 869 | * @ch_width: NL channel width |
| 870 | * |
| 871 | * Converts the NL channel width to the driver's internal representation |
| 872 | * |
| 873 | * Return: Converted channel width. In case of non matching NL channel width, |
| 874 | * CH_WIDTH_MAX will be returned. |
| 875 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 876 | 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] | 877 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 878 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 879 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 880 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 881 | switch (ch_width) { |
| 882 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 883 | case NL80211_CHAN_WIDTH_20: |
| 884 | return CH_WIDTH_20MHZ; |
| 885 | case NL80211_CHAN_WIDTH_40: |
| 886 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 887 | case NL80211_CHAN_WIDTH_80: |
| 888 | return CH_WIDTH_80MHZ; |
| 889 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 890 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 891 | return CH_WIDTH_80P80MHZ; |
| 892 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 893 | return CH_WIDTH_160MHZ; |
| 894 | else |
| 895 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 896 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 897 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 898 | return CH_WIDTH_160MHZ; |
| 899 | else |
| 900 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 901 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 902 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 903 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 904 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 905 | default: |
| 906 | hdd_err("Invalid channel width %d, setting to default", |
| 907 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 908 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 909 | } |
| 910 | } |
| 911 | |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 912 | QDF_STATUS hdd_nl_to_qdf_iface_type(enum nl80211_iftype nl_type, |
| 913 | enum QDF_OPMODE *out_qdf_type) |
| 914 | { |
| 915 | switch (nl_type) { |
| 916 | case NL80211_IFTYPE_ADHOC: |
| 917 | *out_qdf_type = QDF_IBSS_MODE; |
| 918 | break; |
| 919 | case NL80211_IFTYPE_AP: |
| 920 | *out_qdf_type = QDF_SAP_MODE; |
| 921 | break; |
| 922 | case NL80211_IFTYPE_MONITOR: |
| 923 | *out_qdf_type = QDF_MONITOR_MODE; |
| 924 | break; |
| 925 | case NL80211_IFTYPE_OCB: |
| 926 | *out_qdf_type = QDF_OCB_MODE; |
| 927 | break; |
| 928 | case NL80211_IFTYPE_P2P_CLIENT: |
| 929 | *out_qdf_type = QDF_P2P_CLIENT_MODE; |
| 930 | break; |
| 931 | case NL80211_IFTYPE_P2P_DEVICE: |
| 932 | *out_qdf_type = QDF_P2P_DEVICE_MODE; |
| 933 | break; |
| 934 | case NL80211_IFTYPE_P2P_GO: |
| 935 | *out_qdf_type = QDF_P2P_GO_MODE; |
| 936 | break; |
| 937 | case NL80211_IFTYPE_STATION: |
| 938 | *out_qdf_type = QDF_STA_MODE; |
| 939 | break; |
| 940 | case NL80211_IFTYPE_WDS: |
| 941 | *out_qdf_type = QDF_WDS_MODE; |
| 942 | break; |
| 943 | default: |
| 944 | hdd_err("Invalid nl80211 interface type %d", nl_type); |
| 945 | return QDF_STATUS_E_INVAL; |
| 946 | } |
| 947 | |
| 948 | return QDF_STATUS_SUCCESS; |
| 949 | } |
| 950 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 951 | uint8_t wlan_hdd_find_opclass(mac_handle_t mac_handle, uint8_t channel, |
| 952 | uint8_t bw_offset) |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 953 | { |
| 954 | uint8_t opclass = 0; |
| 955 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 956 | sme_get_opclass(mac_handle, channel, bw_offset, &opclass); |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 957 | return opclass; |
| 958 | } |
| 959 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 960 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 961 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 962 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 963 | * @bitmask: Bitmask of log levels to be enabled |
| 964 | * |
| 965 | * Called immediately after the cfg.ini is read in order to configure |
| 966 | * the desired trace levels. |
| 967 | * |
| 968 | * Return: None |
| 969 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 970 | 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] | 971 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 972 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 973 | int qdf_print_idx = -1; |
| 974 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 975 | /* |
| 976 | * if the bitmask is the default value, then a bitmask was not |
| 977 | * specified in cfg.ini, so leave the logging level alone (it |
| 978 | * will remain at the "compiled in" default value) |
| 979 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 980 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 981 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 982 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 983 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 984 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 985 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 986 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 987 | QDF_TRACE_LEVEL_NONE, 0); |
| 988 | |
| 989 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 990 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 991 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 992 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 993 | while (0 != bitmask) { |
| 994 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 995 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 996 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 997 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 998 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 999 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1000 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1001 | level++; |
| 1002 | bitmask >>= 1; |
| 1003 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1004 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1005 | } |
| 1006 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1007 | 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] | 1008 | { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1009 | if (!hdd_ctx) { |
| 1010 | hdd_err("HDD context is null (via %s)", func); |
| 1011 | return -ENODEV; |
| 1012 | } |
| 1013 | |
| 1014 | if (!hdd_ctx->config) { |
| 1015 | hdd_err("HDD config is null (via %s)", func); |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 1016 | return -ENODEV; |
| 1017 | } |
| 1018 | |
| 1019 | if (cds_is_driver_recovering()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1020 | hdd_debug("Recovery in progress (via %s); state:0x%x", |
| 1021 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1022 | return -EAGAIN; |
| 1023 | } |
| 1024 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 1025 | if (cds_is_load_or_unload_in_progress()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1026 | hdd_debug("Load/unload in progress (via %s); state:0x%x", |
| 1027 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1028 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 1029 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1030 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1031 | if (cds_is_driver_in_bad_state()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1032 | hdd_debug("Driver in bad state (via %s); state:0x%x", |
| 1033 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 1034 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1035 | } |
| 1036 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 1037 | if (cds_is_fw_down()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1038 | hdd_debug("FW is down (via %s); state:0x%x", |
| 1039 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 1040 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 1041 | } |
| 1042 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1043 | return 0; |
| 1044 | } |
| 1045 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1046 | int __hdd_validate_adapter(struct hdd_adapter *adapter, const char *func) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1047 | { |
| 1048 | if (!adapter) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1049 | hdd_err("adapter is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1050 | return -EINVAL; |
| 1051 | } |
| 1052 | |
| 1053 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1054 | hdd_err("bad adapter magic (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1055 | return -EINVAL; |
| 1056 | } |
| 1057 | |
| 1058 | if (!adapter->dev) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1059 | hdd_err("adapter net_device 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->dev->flags & IFF_UP)) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1064 | hdd_debug_rl("adapter '%s' is not up (via %s)", |
| 1065 | adapter->dev->name, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1066 | return -EAGAIN; |
| 1067 | } |
| 1068 | |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 1069 | return __wlan_hdd_validate_vdev_id(adapter->vdev_id, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1070 | } |
| 1071 | |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 1072 | 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] | 1073 | { |
Srinivas Girigowda | d8697d4 | 2019-03-08 15:34:39 -0800 | [diff] [blame] | 1074 | if (vdev_id == WLAN_UMAC_VDEV_ID_MAX) { |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 1075 | hdd_debug_rl("adapter is not up (via %s)", func); |
| 1076 | return -EINVAL; |
| 1077 | } |
| 1078 | |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 1079 | if (vdev_id >= WLAN_MAX_VDEVS) { |
| 1080 | hdd_err("bad vdev Id:%u (via %s)", vdev_id, func); |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 1081 | return -EINVAL; |
| 1082 | } |
| 1083 | |
| 1084 | return 0; |
| 1085 | } |
| 1086 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 1087 | QDF_STATUS __wlan_hdd_validate_mac_address(struct qdf_mac_addr *mac_addr, |
| 1088 | const char *func) |
| 1089 | { |
| 1090 | if (!mac_addr) { |
| 1091 | hdd_err("Received NULL mac address (via %s)", func); |
| 1092 | return QDF_STATUS_E_INVAL; |
| 1093 | } |
| 1094 | |
| 1095 | if (qdf_is_macaddr_zero(mac_addr)) { |
| 1096 | hdd_err("MAC is all zero (via %s)", func); |
| 1097 | return QDF_STATUS_E_INVAL; |
| 1098 | } |
| 1099 | |
| 1100 | if (qdf_is_macaddr_broadcast(mac_addr)) { |
| 1101 | hdd_err("MAC is Broadcast (via %s)", func); |
| 1102 | return QDF_STATUS_E_INVAL; |
| 1103 | } |
| 1104 | |
| 1105 | if (QDF_NET_IS_MAC_MULTICAST(mac_addr->bytes)) { |
| 1106 | hdd_err("MAC is Multicast (via %s)", func); |
| 1107 | return QDF_STATUS_E_INVAL; |
| 1108 | } |
| 1109 | |
| 1110 | return QDF_STATUS_SUCCESS; |
| 1111 | } |
| 1112 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1113 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1114 | * wlan_hdd_validate_modules_state() - Check modules status |
| 1115 | * @hdd_ctx: HDD context pointer |
| 1116 | * |
| 1117 | * Check's the driver module's state and returns true if the |
| 1118 | * modules are enabled returns false if modules are closed. |
| 1119 | * |
| 1120 | * Return: True if modules are enabled or false. |
| 1121 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1122 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1123 | { |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1124 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 1125 | hdd_info("Modules not enabled, Present status: %d", |
| 1126 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1127 | return false; |
| 1128 | } |
Dustin Brown | f688ea1 | 2019-03-19 17:02:32 -0700 | [diff] [blame] | 1129 | |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1130 | return true; |
| 1131 | } |
| 1132 | |
| 1133 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1134 | * 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] | 1135 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1136 | * |
| 1137 | * This function sets the IBSS power save config parameters to WMA |
| 1138 | * which will send it to firmware if FW supports IBSS power save |
| 1139 | * before vdev start. |
| 1140 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1141 | * 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] | 1142 | * on failure. |
| 1143 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1144 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1145 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1146 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1147 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1148 | if (!hdd_ctx) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1149 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1150 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1151 | } |
| 1152 | |
Manikandan Mohan | 2bd0977 | 2018-11-28 18:27:32 -0800 | [diff] [blame] | 1153 | return ucfg_mlme_ibss_power_save_setup(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1154 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1155 | } |
| 1156 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1157 | #ifdef FEATURE_RUNTIME_PM |
| 1158 | /** |
| 1159 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1160 | * @hdd_ctx: HDD context |
| 1161 | * |
| 1162 | * Return: None |
| 1163 | */ |
| 1164 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1165 | { |
| 1166 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1167 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1168 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1169 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1170 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1171 | wlan_scan_runtime_pm_init(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1172 | } |
| 1173 | |
| 1174 | /** |
| 1175 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1176 | * @hdd_ctx: HDD Context |
| 1177 | * |
| 1178 | * Return: None |
| 1179 | */ |
| 1180 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1181 | { |
| 1182 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1183 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1184 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1185 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1186 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1187 | wlan_scan_runtime_pm_deinit(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1188 | } |
| 1189 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1190 | #else /* FEATURE_RUNTIME_PM */ |
| 1191 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1192 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1193 | #endif /* FEATURE_RUNTIME_PM */ |
| 1194 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1195 | #define INTF_MACADDR_MASK 0x7 |
| 1196 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1197 | void hdd_update_macaddr(struct hdd_context *hdd_ctx, |
| 1198 | struct qdf_mac_addr hw_macaddr, bool generate_mac_auto) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1199 | { |
| 1200 | int8_t i; |
| 1201 | uint8_t macaddr_b3, tmp_br3; |
| 1202 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1203 | /* |
| 1204 | * If "generate_mac_auto" is true, it indicates that all the |
| 1205 | * addresses are derived addresses, else the first addresses |
| 1206 | * is not derived address (It is provided by fw). |
| 1207 | */ |
| 1208 | if (!generate_mac_auto) { |
| 1209 | qdf_mem_copy(hdd_ctx->provisioned_mac_addr[0].bytes, |
| 1210 | hw_macaddr.bytes, QDF_MAC_ADDR_SIZE); |
| 1211 | hdd_ctx->num_provisioned_addr++; |
| 1212 | hdd_info("hdd_ctx->provisioned_mac_addr[0]: " |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 1213 | QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1214 | QDF_MAC_ADDR_ARRAY(hdd_ctx-> |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1215 | provisioned_mac_addr[0].bytes)); |
| 1216 | } else { |
| 1217 | qdf_mem_copy(hdd_ctx->derived_mac_addr[0].bytes, |
| 1218 | hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1219 | QDF_MAC_ADDR_SIZE); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1220 | hdd_ctx->num_derived_addr++; |
| 1221 | hdd_info("hdd_ctx->derived_mac_addr[0]: " |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 1222 | QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1223 | QDF_MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[0].bytes)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1224 | } |
| 1225 | for (i = hdd_ctx->num_derived_addr; i < (QDF_MAX_CONCURRENCY_PERSONA - |
| 1226 | hdd_ctx->num_provisioned_addr); |
| 1227 | i++) { |
| 1228 | qdf_mem_copy(hdd_ctx->derived_mac_addr[i].bytes, |
| 1229 | hw_macaddr.bytes, |
| 1230 | QDF_MAC_ADDR_SIZE); |
| 1231 | macaddr_b3 = hdd_ctx->derived_mac_addr[i].bytes[3]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1232 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1233 | INTF_MACADDR_MASK; |
| 1234 | macaddr_b3 += tmp_br3; |
| 1235 | |
| 1236 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1237 | * mac address range before collision |
| 1238 | */ |
| 1239 | macaddr_b3 ^= (1 << 7); |
| 1240 | |
| 1241 | /* Set locally administered bit */ |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1242 | hdd_ctx->derived_mac_addr[i].bytes[0] |= 0x02; |
| 1243 | hdd_ctx->derived_mac_addr[i].bytes[3] = macaddr_b3; |
| 1244 | hdd_info("hdd_ctx->derived_mac_addr[%d]: " |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 1245 | QDF_MAC_ADDR_STR, i, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1246 | QDF_MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1247 | hdd_ctx->num_derived_addr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1248 | } |
| 1249 | } |
| 1250 | |
Jeff Johnson | 2de5879 | 2019-02-08 07:49:17 -0800 | [diff] [blame] | 1251 | #ifdef FEATURE_WLAN_TDLS |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1252 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1253 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1254 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1255 | struct tdls_start_params tdls_cfg; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1256 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1257 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 1258 | |
| 1259 | /* Populate the nss chain params from ini for this vdev type */ |
| 1260 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 1261 | QDF_TDLS_MODE, |
| 1262 | hdd_ctx->num_rf_chains); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1263 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1264 | cfg_tdls_set_vdev_nss_2g(hdd_ctx->psoc, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1265 | vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1266 | cfg_tdls_set_vdev_nss_5g(hdd_ctx->psoc, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1267 | vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]); |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1268 | hdd_init_tdls_config(&tdls_cfg); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1269 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1270 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1271 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1272 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1273 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1274 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1275 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1276 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1277 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1278 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1279 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1280 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
Arun Kumar Khandavalli | 43fdd25 | 2019-04-24 18:34:18 +0530 | [diff] [blame] | 1281 | tdls_cfg.tdls_osif_init_cb = wlan_cfg80211_tdls_osif_priv_init; |
| 1282 | tdls_cfg.tdls_osif_deinit_cb = wlan_cfg80211_tdls_osif_priv_deinit; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1283 | |
| 1284 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1285 | if (status != QDF_STATUS_SUCCESS) { |
| 1286 | hdd_err("failed pmo psoc configuration"); |
| 1287 | return -EINVAL; |
| 1288 | } |
| 1289 | |
| 1290 | hdd_ctx->tdls_umac_comp_active = true; |
| 1291 | /* enable napier specific tdls data path */ |
| 1292 | hdd_ctx->tdls_nap_active = true; |
| 1293 | |
| 1294 | return 0; |
| 1295 | } |
Jeff Johnson | 74c6bb2 | 2019-02-15 10:15:07 -0800 | [diff] [blame] | 1296 | #else |
| 1297 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1298 | { |
| 1299 | return 0; |
| 1300 | } |
| 1301 | #endif |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1302 | |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1303 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1304 | static void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1305 | struct wma_tgt_services *cfg) |
| 1306 | { |
| 1307 | bool roam_offload_enable; |
| 1308 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1309 | ucfg_mlme_get_roaming_offload(hdd_ctx->psoc, &roam_offload_enable); |
| 1310 | ucfg_mlme_set_roaming_offload(hdd_ctx->psoc, |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1311 | roam_offload_enable & |
| 1312 | cfg->en_roam_offload); |
| 1313 | } |
| 1314 | #else |
| 1315 | static inline void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1316 | struct wma_tgt_services *cfg) |
| 1317 | { |
| 1318 | } |
| 1319 | #endif |
| 1320 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1321 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1322 | struct wma_tgt_services *cfg) |
| 1323 | { |
| 1324 | struct hdd_config *config = hdd_ctx->config; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1325 | bool arp_offload_enable; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1326 | bool mawc_enabled; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1327 | #ifdef FEATURE_WLAN_TDLS |
| 1328 | bool tdls_support; |
| 1329 | bool tdls_off_channel; |
| 1330 | bool tdls_buffer_sta; |
| 1331 | uint32_t tdls_uapsd_mask; |
| 1332 | #endif |
Will Huang | b9cb124 | 2019-04-02 14:52:17 +0800 | [diff] [blame] | 1333 | bool get_peer_info_enable; |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1334 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1335 | /* Set up UAPSD */ |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 1336 | ucfg_mlme_set_sap_uapsd_flag(hdd_ctx->psoc, cfg->uapsd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1337 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1338 | /* 11AX mode support */ |
| 1339 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1340 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1341 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1342 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1343 | /* 11AC mode support */ |
| 1344 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1345 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1346 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1347 | |
| 1348 | /* ARP offload: override user setting if invalid */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1349 | arp_offload_enable = |
| 1350 | ucfg_pmo_is_arp_offload_enabled(hdd_ctx->psoc); |
| 1351 | ucfg_pmo_set_arp_offload_enabled(hdd_ctx->psoc, |
| 1352 | arp_offload_enable & cfg->arp_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1353 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1354 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1355 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1356 | if (cfg->pno_offload) |
Pragaspathi Thilagaraj | 24789d3 | 2018-12-10 22:28:03 +0530 | [diff] [blame] | 1357 | ucfg_scan_set_pno_offload(hdd_ctx->psoc, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1358 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1359 | #ifdef FEATURE_WLAN_TDLS |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1360 | cfg_tdls_get_support_enable(hdd_ctx->psoc, &tdls_support); |
| 1361 | cfg_tdls_set_support_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1362 | tdls_support & cfg->en_tdls); |
| 1363 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1364 | cfg_tdls_get_off_channel_enable(hdd_ctx->psoc, &tdls_off_channel); |
| 1365 | cfg_tdls_set_off_channel_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1366 | tdls_off_channel && |
| 1367 | cfg->en_tdls_offchan); |
| 1368 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1369 | cfg_tdls_get_buffer_sta_enable(hdd_ctx->psoc, &tdls_buffer_sta); |
| 1370 | cfg_tdls_set_buffer_sta_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1371 | tdls_buffer_sta && |
| 1372 | cfg->en_tdls_uapsd_buf_sta); |
| 1373 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1374 | cfg_tdls_get_uapsd_mask(hdd_ctx->psoc, &tdls_uapsd_mask); |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1375 | if (tdls_uapsd_mask && cfg->en_tdls_uapsd_sleep_sta) |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1376 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, true); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1377 | else |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1378 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1379 | #endif |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1380 | hdd_update_roam_offload(hdd_ctx, cfg); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1381 | |
Will Huang | b9cb124 | 2019-04-02 14:52:17 +0800 | [diff] [blame] | 1382 | if (ucfg_mlme_get_sap_get_peer_info( |
| 1383 | hdd_ctx->psoc, &get_peer_info_enable) == QDF_STATUS_SUCCESS) { |
| 1384 | get_peer_info_enable &= cfg->get_peer_info_enabled; |
| 1385 | ucfg_mlme_set_sap_get_peer_info(hdd_ctx->psoc, |
| 1386 | get_peer_info_enable); |
| 1387 | } |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1388 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1389 | ucfg_mlme_is_mawc_enabled(hdd_ctx->psoc, &mawc_enabled); |
| 1390 | ucfg_mlme_set_mawc_enabled(hdd_ctx->psoc, |
| 1391 | mawc_enabled & cfg->is_fw_mawc_capable); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1392 | hdd_update_tdls_config(hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1393 | sme_update_tgt_services(hdd_ctx->mac_handle, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1394 | } |
| 1395 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1396 | /** |
| 1397 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1398 | * @hdd_ctx: HDD context |
| 1399 | * |
| 1400 | * Sets the Nss per vdev type based on INI |
| 1401 | * |
| 1402 | * Return: None |
| 1403 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1404 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1405 | { |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1406 | uint8_t max_supp_nss = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1407 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1408 | QDF_STATUS status; |
| 1409 | bool bval; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1410 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1411 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1412 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1413 | hdd_err("unable to get vht_enable2x2"); |
| 1414 | |
| 1415 | if (bval && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1416 | max_supp_nss = 2; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1417 | |
| 1418 | hdd_debug("max nss %d", max_supp_nss); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1419 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1420 | mac_handle = hdd_ctx->mac_handle; |
| 1421 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1422 | NSS_CHAINS_BAND_2GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1423 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1424 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1425 | NSS_CHAINS_BAND_5GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1426 | } |
| 1427 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1428 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1429 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1430 | * @hdd_ctx: HDD context |
| 1431 | * |
| 1432 | * Updates wiphy vhtcap fields |
| 1433 | * |
| 1434 | * Return: None |
| 1435 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1436 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1437 | { |
| 1438 | struct ieee80211_supported_band *band_5g = |
| 1439 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1440 | QDF_STATUS status; |
| 1441 | uint8_t value = 0, value1 = 0; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1442 | |
| 1443 | if (!band_5g) { |
| 1444 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1445 | return; |
| 1446 | } |
| 1447 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1448 | status = ucfg_mlme_cfg_get_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 1449 | &value); |
| 1450 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1451 | hdd_err("unable to get tx_bfee_ant_supp"); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1452 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1453 | band_5g->vht_cap.cap |= |
| 1454 | (value << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1455 | |
| 1456 | value1 = NUM_OF_SOUNDING_DIMENSIONS; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1457 | band_5g->vht_cap.cap |= |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1458 | (value1 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1459 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 1460 | hdd_debug("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1461 | band_5g->vht_cap.cap, value, value1); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1462 | } |
| 1463 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1464 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1465 | struct wma_tgt_ht_cap *cfg) |
| 1466 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1467 | QDF_STATUS status; |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1468 | qdf_size_t value_len; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1469 | uint32_t value; |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1470 | uint8_t mpdu_density; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1471 | struct mlme_ht_capabilities_info ht_cap_info; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1472 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1473 | bool b_enable1x1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1474 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1475 | /* get the MPDU density */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1476 | status = ucfg_mlme_get_ht_mpdu_density(hdd_ctx->psoc, &mpdu_density); |
| 1477 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1478 | hdd_err("could not get HT MPDU Density"); |
| 1479 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1480 | } |
| 1481 | |
| 1482 | /* |
| 1483 | * MPDU density: |
| 1484 | * override user's setting if value is larger |
| 1485 | * than the one supported by target |
| 1486 | */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1487 | if (mpdu_density > cfg->mpdu_density) { |
| 1488 | status = ucfg_mlme_set_ht_mpdu_density(hdd_ctx->psoc, |
| 1489 | cfg->mpdu_density); |
| 1490 | if (QDF_IS_STATUS_ERROR(status)) |
| 1491 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1492 | } |
| 1493 | |
| 1494 | /* get the HT capability info */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1495 | 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] | 1496 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1497 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1498 | return; |
| 1499 | } |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1500 | |
| 1501 | /* check and update RX STBC */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1502 | if (ht_cap_info.rx_stbc && !cfg->ht_rx_stbc) |
| 1503 | ht_cap_info.rx_stbc = cfg->ht_rx_stbc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1504 | |
| 1505 | /* Set the LDPC capability */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1506 | ht_cap_info.adv_coding_cap = cfg->ht_rx_ldpc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1507 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1508 | if (ht_cap_info.short_gi_20_mhz && !cfg->ht_sgi_20) |
| 1509 | ht_cap_info.short_gi_20_mhz = cfg->ht_sgi_20; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1510 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1511 | if (ht_cap_info.short_gi_40_mhz && !cfg->ht_sgi_40) |
| 1512 | ht_cap_info.short_gi_40_mhz = cfg->ht_sgi_40; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1513 | |
| 1514 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1515 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1516 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1517 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &b_enable1x1); |
| 1518 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1519 | hdd_err("unable to get vht_enable2x2"); |
| 1520 | |
| 1521 | b_enable1x1 = b_enable1x1 && (cfg->num_rf_chains == 2); |
| 1522 | |
| 1523 | status = ucfg_mlme_set_vht_enable2x2(hdd_ctx->psoc, b_enable1x1); |
| 1524 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1525 | hdd_err("unable to set vht_enable2x2"); |
| 1526 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1527 | if (!b_enable1x1) { |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1528 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1529 | |
| 1530 | /* 1x1 */ |
| 1531 | /* Update Rx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1532 | status = ucfg_mlme_cfg_set_vht_rx_supp_data_rate( |
| 1533 | hdd_ctx->psoc, |
| 1534 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1535 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1536 | hdd_err("Failed to set rx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1537 | /* Update Tx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1538 | status = ucfg_mlme_cfg_set_vht_tx_supp_data_rate( |
| 1539 | hdd_ctx->psoc, |
| 1540 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1541 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1542 | hdd_err("Failed to set tx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1543 | } |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1544 | if (!(cfg->ht_tx_stbc && b_enable1x1)) |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1545 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1546 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1547 | 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] | 1548 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1549 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1550 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1551 | value_len = SIZE_OF_SUPPORTED_MCS_SET; |
| 1552 | if (ucfg_mlme_get_supported_mcs_set( |
| 1553 | hdd_ctx->psoc, mcs_set, |
| 1554 | &value_len) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1555 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1556 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1557 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1558 | |
| 1559 | if (b_enable1x1) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1560 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1561 | mcs_set[value] = |
| 1562 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1563 | |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1564 | status = ucfg_mlme_set_supported_mcs_set( |
| 1565 | hdd_ctx->psoc, |
| 1566 | mcs_set, |
| 1567 | (qdf_size_t)SIZE_OF_SUPPORTED_MCS_SET); |
| 1568 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1569 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1570 | } |
| 1571 | } |
| 1572 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1573 | } |
| 1574 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1575 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1576 | struct wma_tgt_vht_cap *cfg) |
| 1577 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1578 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1579 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1580 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1581 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1582 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1583 | struct wma_caps_per_phy caps_per_phy; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1584 | uint8_t val = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1585 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1586 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1587 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1588 | return; |
| 1589 | } |
| 1590 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1591 | status = ucfg_mlme_update_vht_cap(hdd_ctx->psoc, cfg); |
| 1592 | if (QDF_IS_STATUS_ERROR(status)) |
| 1593 | hdd_err("could not update vht capabilities"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1594 | |
| 1595 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1596 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1597 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1598 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1599 | else |
| 1600 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1601 | |
| 1602 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1603 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1604 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1605 | VHT_CAP_160_AND_80P80_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1606 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1607 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1608 | band_5g->vht_cap.cap |= |
| 1609 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1610 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1611 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1612 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1613 | VHT_CAP_160_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1614 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1615 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1616 | band_5g->vht_cap.cap |= |
| 1617 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1618 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1619 | } |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1620 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1621 | status = |
| 1622 | ucfg_mlme_cfg_get_vht_chan_width(hdd_ctx->psoc, &val); |
| 1623 | if (QDF_IS_STATUS_ERROR(status)) |
| 1624 | hdd_err("could not get channel_width"); |
| 1625 | |
| 1626 | val = QDF_MIN(val, ch_width); |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1627 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, val); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1628 | if (QDF_IS_STATUS_ERROR(status)) |
| 1629 | hdd_err("could not set the channel width"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1630 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1631 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1632 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1633 | hdd_debug("VHT RxLDPC capability is set"); |
| 1634 | } else { |
| 1635 | /* |
| 1636 | * Get the RX LDPC capability for the NON DBS |
| 1637 | * hardware mode for 5G band |
| 1638 | */ |
| 1639 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1640 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1641 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1642 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1643 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1644 | hdd_debug("VHT RX LDPC capability is set"); |
| 1645 | } |
| 1646 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1647 | |
| 1648 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1649 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1650 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1651 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1652 | |
| 1653 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1654 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1655 | |
| 1656 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1657 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1658 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1659 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1660 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1661 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1662 | |
| 1663 | band_5g->vht_cap.cap |= |
| 1664 | (cfg->vht_max_ampdu_len_exp << |
| 1665 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1666 | |
| 1667 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1668 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1669 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1670 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1671 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1672 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1673 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1674 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1675 | |
| 1676 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1677 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1678 | |
| 1679 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1680 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1681 | /** |
| 1682 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1683 | * @hdd_ctx: Pointer to the HDD context |
| 1684 | * |
| 1685 | * Auto-generate mac address using device serial number. |
| 1686 | * Keep the first 3 bytes of OUI as before and replace |
| 1687 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1688 | * |
| 1689 | * Return: 0 for success |
| 1690 | * Non zero failure code for errors |
| 1691 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1692 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1693 | { |
| 1694 | unsigned int serialno = 0; |
| 1695 | struct qdf_mac_addr mac_addr = { |
| 1696 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1697 | }; |
| 1698 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1699 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1700 | if (serialno == 0) |
| 1701 | return -EINVAL; |
| 1702 | |
| 1703 | serialno &= 0x00ffffff; |
| 1704 | |
| 1705 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1706 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1707 | mac_addr.bytes[5] = serialno & 0xff; |
| 1708 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1709 | hdd_update_macaddr(hdd_ctx, mac_addr, true); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1710 | return 0; |
| 1711 | } |
| 1712 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1713 | static void hdd_sar_target_config(struct hdd_context *hdd_ctx, |
| 1714 | struct wma_tgt_cfg *cfg) |
| 1715 | { |
| 1716 | hdd_ctx->sar_version = cfg->sar_version; |
| 1717 | } |
| 1718 | |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1719 | static void hdd_update_vhtcap_2g(struct hdd_context *hdd_ctx) |
| 1720 | { |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1721 | uint32_t chip_mode = 0; |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1722 | QDF_STATUS status; |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1723 | bool b2g_vht_cfg = false; |
| 1724 | bool b2g_vht_target = false; |
| 1725 | struct wma_caps_per_phy caps_per_phy; |
| 1726 | struct wmi_unified *wmi_handle; |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1727 | |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1728 | wmi_handle = get_wmi_unified_hdl_from_psoc(hdd_ctx->psoc); |
| 1729 | if (!wmi_handle) { |
| 1730 | hdd_err("wmi handle is NULL"); |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1731 | return; |
| 1732 | } |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1733 | |
| 1734 | 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] | 1735 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1736 | hdd_err("Failed to get 2g vht mode"); |
| 1737 | return; |
| 1738 | } |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1739 | if (wmi_service_enabled(wmi_handle, wmi_service_ext_msg)) { |
| 1740 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1741 | HW_MODE_DBS_NONE, |
| 1742 | CDS_BAND_ALL); |
| 1743 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1744 | hdd_err("Failed to get phy caps"); |
| 1745 | return; |
| 1746 | } |
| 1747 | if (caps_per_phy.vht_2g) |
| 1748 | b2g_vht_target = true; |
| 1749 | } else { |
| 1750 | status = wlan_reg_get_chip_mode(hdd_ctx->pdev, &chip_mode); |
| 1751 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1752 | hdd_err("Failed to get chip mode"); |
| 1753 | return; |
| 1754 | } |
| 1755 | b2g_vht_target = |
| 1756 | (chip_mode & WMI_HOST_REGDMN_MODE_11AC_VHT20_2G) ? |
| 1757 | true : false; |
| 1758 | } |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1759 | |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1760 | b2g_vht_cfg = b2g_vht_cfg && b2g_vht_target; |
| 1761 | hdd_debug("vht 2g target: %d, cfg: %d", b2g_vht_target, b2g_vht_cfg); |
| 1762 | 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] | 1763 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1764 | hdd_err("Failed to update 2g vht mode"); |
| 1765 | return; |
| 1766 | } |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1767 | } |
| 1768 | |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1769 | int 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] | 1770 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1771 | int ret; |
Jeff Johnson | ea70b94 | 2018-07-02 09:42:31 -0700 | [diff] [blame] | 1772 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1773 | uint8_t temp_band_cap, band_capability; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1774 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1775 | uint8_t antenna_mode; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1776 | uint8_t sub_20_chan_width; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1777 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1778 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1779 | bool bval = false; |
| 1780 | uint8_t value = 0; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1781 | uint32_t fine_time_meas_cap = 0; |
gaurank kathpalia | fa7ad0a | 2019-03-12 19:17:56 +0530 | [diff] [blame] | 1782 | enum nss_chains_band_info band; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1783 | |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1784 | if (!hdd_ctx) { |
| 1785 | hdd_err("HDD context is NULL"); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1786 | return -EINVAL; |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1787 | } |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1788 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1789 | if (ret) { |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1790 | QDF_DEBUG_PANIC("Failed to create pdev; errno:%d", ret); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1791 | return -EINVAL; |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1792 | } |
| 1793 | |
| 1794 | hdd_debug("New pdev has been created with pdev_id = %u", |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1795 | hdd_ctx->pdev->pdev_objmgr.wlan_pdev_id); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1796 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1797 | status = dispatcher_pdev_open(hdd_ctx->pdev); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1798 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1799 | QDF_DEBUG_PANIC("dispatcher pdev open failed; status:%d", |
| 1800 | status); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1801 | ret = qdf_status_to_os_return(status); |
| 1802 | goto exit; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1803 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1804 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 1805 | status = hdd_component_pdev_open(hdd_ctx->pdev); |
| 1806 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1807 | QDF_DEBUG_PANIC("hdd component pdev open failed; status:%d", |
| 1808 | status); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1809 | ret = qdf_status_to_os_return(status); |
| 1810 | goto dispatcher_close; |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 1811 | } |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1812 | |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1813 | cdp_pdev_set_ctrl_pdev(cds_get_context(QDF_MODULE_ID_SOC), |
| 1814 | cds_get_context(QDF_MODULE_ID_TXRX), |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1815 | (struct cdp_ctrl_objmgr_pdev *)hdd_ctx->pdev); |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1816 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1817 | wlan_pdev_set_dp_handle(hdd_ctx->pdev, |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1818 | cds_get_context(QDF_MODULE_ID_TXRX)); |
| 1819 | |
Will Huang | 0724417 | 2018-05-14 14:23:30 +0800 | [diff] [blame] | 1820 | hdd_objmgr_update_tgt_max_vdev_psoc(hdd_ctx, cfg->max_intf_count); |
| 1821 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1822 | ucfg_ipa_set_dp_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1823 | cds_get_context(QDF_MODULE_ID_SOC)); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1824 | ucfg_ipa_set_txrx_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1825 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1826 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1827 | hdd_softap_hard_start_xmit); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1828 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1829 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1830 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1831 | status = ucfg_mlme_get_sub_20_chan_width(hdd_ctx->psoc, |
| 1832 | &sub_20_chan_width); |
| 1833 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1834 | hdd_err("Failed to get sub_20_chan_width config"); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1835 | ret = qdf_status_to_os_return(status); |
| 1836 | goto pdev_close; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1837 | } |
| 1838 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1839 | if (cds_cfg) { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1840 | if (sub_20_chan_width != |
| 1841 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1842 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1843 | cds_cfg->sub_20_channel_width = |
| 1844 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1845 | } else { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1846 | cds_cfg->sub_20_channel_width = sub_20_chan_width; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1847 | } |
| 1848 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1849 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1850 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 1851 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1852 | hdd_err("Failed to get MLME band capability"); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1853 | ret = qdf_status_to_os_return(status); |
| 1854 | goto pdev_close; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 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"); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1883 | ret = qdf_status_to_os_return(status); |
| 1884 | goto pdev_close; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1885 | } |
| 1886 | |
| 1887 | hdd_ctx->curr_band = band_capability; |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1888 | |
Qun Zhang | 043635a | 2019-02-27 15:19:29 +0800 | [diff] [blame] | 1889 | status = wlan_hdd_update_wiphy_supported_band(hdd_ctx); |
| 1890 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1891 | hdd_err("Failed to update wiphy band info"); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1892 | goto pdev_close; |
Qun Zhang | 043635a | 2019-02-27 15:19:29 +0800 | [diff] [blame] | 1893 | } |
| 1894 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1895 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1896 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1897 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1898 | } |
| 1899 | |
| 1900 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1901 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1902 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) |
| 1903 | qdf_mem_copy(&hdd_ctx->hw_macaddr, &cfg->hw_macaddr, |
| 1904 | QDF_MAC_ADDR_SIZE); |
| 1905 | else |
| 1906 | hdd_info("hw_mac is zero"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1907 | |
| 1908 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1909 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1910 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 1911 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 1912 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 1913 | sizeof(cfg->hw_bd_info)); |
| 1914 | |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 1915 | if (cfg->max_intf_count > WLAN_MAX_VDEVS) { |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 1916 | hdd_err("fw max vdevs (%u) > host max vdevs (%u); using %u", |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 1917 | cfg->max_intf_count, WLAN_MAX_VDEVS, WLAN_MAX_VDEVS); |
| 1918 | hdd_ctx->max_intf_count = WLAN_MAX_VDEVS; |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 1919 | } else { |
| 1920 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1921 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1922 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1923 | hdd_sar_target_config(hdd_ctx, cfg); |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1924 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1925 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1926 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
Pragaspathi Thilagaraj | eb36728 | 2019-02-19 00:42:28 +0530 | [diff] [blame] | 1927 | status = ucfg_mlme_set_fw_supported_roaming_akm( |
| 1928 | hdd_ctx->psoc, |
| 1929 | cfg->ft_akm_service_bitmap); |
| 1930 | if (QDF_IS_STATUS_ERROR(status)) |
| 1931 | hdd_err("Failed to set ft akm suites bitmap"); |
| 1932 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1933 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1934 | |
| 1935 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1936 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1937 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1938 | if (cfg->services.en_11ax) { |
| 1939 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1940 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1941 | } |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 1942 | hdd_update_tgt_twt_cap(hdd_ctx, cfg); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1943 | |
gaurank kathpalia | fa7ad0a | 2019-03-12 19:17:56 +0530 | [diff] [blame] | 1944 | for (band = NSS_CHAINS_BAND_2GHZ; band < NSS_CHAINS_BAND_MAX; band++) { |
| 1945 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1946 | QDF_STA_MODE, band); |
| 1947 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1948 | QDF_SAP_MODE, band); |
| 1949 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1950 | QDF_TDLS_MODE, band); |
| 1951 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1952 | QDF_P2P_DEVICE_MODE, |
| 1953 | band); |
| 1954 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1955 | QDF_OCB_MODE, band); |
| 1956 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1957 | QDF_TDLS_MODE, band); |
| 1958 | } |
| 1959 | |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1960 | hdd_update_vdev_nss(hdd_ctx); |
| 1961 | |
gaurank kathpalia | 5fcefa9 | 2018-10-24 15:03:15 +0530 | [diff] [blame] | 1962 | hdd_ctx->dynamic_nss_chains_support = |
| 1963 | cfg->dynamic_nss_chains_support; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1964 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, &fine_time_meas_cap); |
| 1965 | fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
| 1966 | status = ucfg_mlme_set_fine_time_meas_cap(hdd_ctx->psoc, |
| 1967 | fine_time_meas_cap); |
| 1968 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1969 | hdd_err("failed to set fine_time_meas_cap, 0x%x, ox%x", |
| 1970 | fine_time_meas_cap, cfg->fine_time_measurement_cap); |
| 1971 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 1972 | &fine_time_meas_cap); |
| 1973 | } |
| 1974 | |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1975 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1976 | hdd_debug("fine_time_meas_cap: 0x%x", fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1977 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1978 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1979 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1980 | hdd_err("unable to get vht_enable2x2"); |
| 1981 | |
| 1982 | antenna_mode = (bval == 0x01) ? |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1983 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1984 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1985 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1986 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1987 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1988 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1989 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1990 | 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] | 1991 | &value); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1992 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1993 | status = false; |
| 1994 | hdd_err("set tx_bfee_ant_supp failed"); |
| 1995 | } |
| 1996 | |
| 1997 | if ((value > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1998 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1999 | !cfg->tx_bfee_8ss_enabled) { |
| 2000 | status = |
| 2001 | ucfg_mlme_cfg_set_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 2002 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF); |
| 2003 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2004 | status = false; |
| 2005 | hdd_err("set tx_bfee_ant_supp failed"); |
| 2006 | } |
| 2007 | } |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2008 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2009 | mac_handle = hdd_ctx->mac_handle; |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2010 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2011 | hdd_debug("txBFCsnValue %d", value); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2012 | |
| 2013 | /* |
| 2014 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2015 | */ |
| 2016 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2017 | |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 2018 | hdd_update_vhtcap_2g(hdd_ctx); |
| 2019 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2020 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2021 | |
Ashish Kumar Dhanotiya | 908925d | 2019-03-01 17:35:30 +0530 | [diff] [blame] | 2022 | 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] | 2023 | /* |
| 2024 | * This needs to be done after HDD pdev is created and stored since |
| 2025 | * it will access the HDD pdev object lock. |
| 2026 | */ |
| 2027 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2028 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2029 | /* Configure NAN datapath features */ |
| 2030 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Nachiket Kukade | 85aa378 | 2018-11-02 20:12:34 +0530 | [diff] [blame] | 2031 | ucfg_nan_set_tgt_caps(hdd_ctx->psoc, &cfg->nan_caps); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2032 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2033 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 2034 | hdd_ctx->obss_scan_offload = cfg->services.obss_scan_offload; |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 2035 | status = ucfg_mlme_set_obss_detection_offload_enabled( |
| 2036 | hdd_ctx->psoc, cfg->obss_detection_offloaded); |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2037 | if (QDF_IS_STATUS_ERROR(status)) |
| 2038 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2039 | |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 2040 | status = ucfg_mlme_set_obss_color_collision_offload_enabled( |
| 2041 | hdd_ctx->psoc, cfg->obss_color_collision_offloaded); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2042 | if (QDF_IS_STATUS_ERROR(status)) |
| 2043 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Arif Hussain | 5068908 | 2019-03-26 12:07:58 -0700 | [diff] [blame] | 2044 | |
| 2045 | ucfg_mlme_get_bcast_twt(hdd_ctx->psoc, &bval); |
| 2046 | if (bval) |
| 2047 | ucfg_mlme_set_bcast_twt(hdd_ctx->psoc, cfg->bcast_twt_support); |
| 2048 | else |
| 2049 | hdd_debug("bcast twt is disable in ini, fw cap %d", |
| 2050 | cfg->bcast_twt_support); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 2051 | return 0; |
| 2052 | |
| 2053 | dispatcher_close: |
| 2054 | dispatcher_pdev_close(hdd_ctx->pdev); |
| 2055 | pdev_close: |
| 2056 | hdd_component_pdev_close(hdd_ctx->pdev); |
| 2057 | exit: |
| 2058 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 2059 | |
| 2060 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2061 | } |
| 2062 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2063 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2064 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2065 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2066 | struct hdd_ap_ctx *ap_ctx; |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2067 | bool dfs_disable_channel_switch = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2068 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2069 | if (!hdd_ctx) { |
| 2070 | hdd_info("Couldn't get hdd_ctx"); |
| 2071 | return true; |
| 2072 | } |
| 2073 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2074 | ucfg_mlme_get_dfs_disable_channel_switch(hdd_ctx->psoc, |
| 2075 | &dfs_disable_channel_switch); |
| 2076 | if (dfs_disable_channel_switch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2077 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2078 | hdd_ctx, dfs_disable_channel_switch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2079 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2080 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2081 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2082 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2083 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2084 | |
| 2085 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2086 | QDF_P2P_GO_MODE == adapter->device_mode) && |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2087 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2088 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2089 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2090 | true; |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 2091 | hdd_info("tx blocked for vdev: %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2092 | adapter->vdev_id); |
bings | 6fb9bf6 | 2018-07-05 14:01:53 +0800 | [diff] [blame] | 2093 | if (adapter->txrx_vdev) |
| 2094 | cdp_fc_vdev_flush( |
| 2095 | cds_get_context(QDF_MODULE_ID_SOC), |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2096 | adapter->txrx_vdev); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2097 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2098 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2099 | |
| 2100 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2101 | } |
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 | bool hdd_is_valid_mac_address(const uint8_t *mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2104 | { |
| 2105 | int xdigit = 0; |
| 2106 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2107 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2108 | while (*mac_addr) { |
| 2109 | if (isxdigit(*mac_addr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2110 | xdigit++; |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2111 | } else if (':' == *mac_addr) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2112 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2113 | break; |
| 2114 | |
| 2115 | ++separator; |
| 2116 | } else { |
| 2117 | /* Invalid MAC found */ |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2118 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2119 | } |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2120 | ++mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2121 | } |
| 2122 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2123 | } |
| 2124 | |
| 2125 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2126 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2127 | * @dev: Handle to struct net_device to be updated. |
| 2128 | * |
| 2129 | * Return: None |
| 2130 | */ |
| 2131 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2132 | { |
| 2133 | dev->header_ops = NULL; |
| 2134 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2135 | dev->hard_header_len = ETH_HLEN; |
| 2136 | dev->mtu = ETH_DATA_LEN; |
| 2137 | dev->addr_len = ETH_ALEN; |
| 2138 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2139 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2140 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2141 | |
| 2142 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2143 | } |
| 2144 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2145 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2146 | /** |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2147 | * hdd_mon_turn_off_ps_and_wow() - Update monitor mode struct net_device. |
| 2148 | * @hdd_ctx: Pointer to HDD context. |
| 2149 | * |
| 2150 | * Return: None |
| 2151 | */ |
| 2152 | static void hdd_mon_turn_off_ps_and_wow(struct hdd_context *hdd_ctx) |
| 2153 | { |
| 2154 | ucfg_pmo_set_power_save_mode(hdd_ctx->psoc, PS_NOT_SUPPORTED); |
| 2155 | ucfg_pmo_set_wow_enable(hdd_ctx->psoc, PMO_WOW_DISABLE_BOTH); |
| 2156 | } |
| 2157 | |
| 2158 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2159 | * __hdd__mon_open() - HDD Open function |
| 2160 | * @dev: Pointer to net_device structure |
| 2161 | * |
| 2162 | * This is called in response to ifconfig up |
| 2163 | * |
| 2164 | * Return: 0 for success; non-zero for failure |
| 2165 | */ |
| 2166 | static int __hdd_mon_open(struct net_device *dev) |
| 2167 | { |
| 2168 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2169 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2170 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2171 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2172 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2173 | |
| 2174 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2175 | if (ret) |
| 2176 | return ret; |
| 2177 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2178 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2179 | |
| 2180 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 2181 | ret = hdd_trigger_psoc_idle_restart(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2182 | if (ret) { |
| 2183 | hdd_err("Failed to start WLAN modules return"); |
| 2184 | return ret; |
| 2185 | } |
| 2186 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2187 | |
| 2188 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2189 | ret = hdd_start_adapter(adapter); |
| 2190 | if (ret) { |
| 2191 | hdd_err("Failed to start adapter :%d", |
| 2192 | adapter->device_mode); |
| 2193 | return ret; |
| 2194 | } |
| 2195 | hdd_err("hdd_start_adapters() successful !"); |
| 2196 | } |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2197 | hdd_mon_turn_off_ps_and_wow(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2198 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2199 | } |
| 2200 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2201 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2202 | |
| 2203 | if (!ret) |
| 2204 | ret = hdd_enable_monitor_mode(dev); |
| 2205 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2206 | return ret; |
| 2207 | } |
| 2208 | |
| 2209 | /** |
| 2210 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2211 | * @dev: Pointer to net_device structure |
| 2212 | * |
| 2213 | * This is called in response to ifconfig up |
| 2214 | * |
| 2215 | * Return: 0 for success; non-zero for failure |
| 2216 | */ |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2217 | static int hdd_mon_open(struct net_device *net_dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2218 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2219 | int errno; |
| 2220 | struct osif_vdev_sync *vdev_sync; |
| 2221 | |
| 2222 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 2223 | if (errno) |
| 2224 | return errno; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2225 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2226 | errno = __hdd_mon_open(net_dev); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2227 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2228 | osif_vdev_sync_trans_stop(vdev_sync); |
| 2229 | |
| 2230 | return errno; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2231 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2232 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2233 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2234 | static QDF_STATUS |
| 2235 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2236 | { |
| 2237 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2238 | QDF_STATUS status; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2239 | uint32_t chnl_sel_logic_conc = 0; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2240 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2241 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2242 | |
| 2243 | if (!hdd_ctx) { |
| 2244 | hdd_err("HDD context is NULL"); |
| 2245 | return QDF_STATUS_E_FAILURE; |
| 2246 | } |
| 2247 | |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2248 | /* |
| 2249 | * ROME platform doesn't support any DBS related commands in FW, |
| 2250 | * so if driver sends wmi command with dual_mac_config with all set to |
| 2251 | * 0 then FW wouldn't respond back and driver would timeout on waiting |
| 2252 | * for response. Check if FW supports DBS to eliminate ROME vs |
| 2253 | * NON-ROME platform. |
| 2254 | */ |
| 2255 | if (!policy_mgr_find_if_fw_supports_dbs(hdd_ctx->psoc)) |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2256 | return QDF_STATUS_SUCCESS; |
| 2257 | |
| 2258 | cfg.scan_config = 0; |
| 2259 | cfg.fw_mode_config = 0; |
| 2260 | 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] | 2261 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc)) { |
| 2262 | status = |
| 2263 | ucfg_policy_mgr_get_chnl_select_plcy(hdd_ctx->psoc, |
| 2264 | &chnl_sel_logic_conc); |
| 2265 | if (status != QDF_STATUS_SUCCESS) { |
| 2266 | hdd_err("can't get chnl sel policy, use def"); |
| 2267 | return status; |
| 2268 | } |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2269 | } |
| 2270 | status = |
| 2271 | ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 2272 | &dual_mac_feature); |
| 2273 | if (status != QDF_STATUS_SUCCESS) { |
| 2274 | hdd_err("ucfg_policy_mgr_get_dual_mac_feature failed, use def"); |
| 2275 | return status; |
| 2276 | } |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2277 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2278 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2279 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2280 | hdd_ctx->psoc, &cfg.scan_config, |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2281 | &cfg.fw_mode_config, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2282 | dual_mac_feature, |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2283 | chnl_sel_logic_conc); |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2284 | |
| 2285 | if (status != QDF_STATUS_SUCCESS) { |
| 2286 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2287 | status); |
| 2288 | return status; |
| 2289 | } |
| 2290 | } |
| 2291 | |
| 2292 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2293 | cfg.scan_config, cfg.fw_mode_config); |
| 2294 | |
| 2295 | status = sme_soc_set_dual_mac_config(cfg); |
| 2296 | if (status != QDF_STATUS_SUCCESS) { |
| 2297 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2298 | return status; |
| 2299 | } |
| 2300 | |
| 2301 | return QDF_STATUS_SUCCESS; |
| 2302 | } |
| 2303 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2304 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2305 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2306 | * @adapter: pointer to HDD adapter |
| 2307 | * |
| 2308 | * This function is called to start the device specific adapter for |
| 2309 | * the mode passed in the adapter's device_mode. |
| 2310 | * |
| 2311 | * Return: 0 for success; non-zero for failure |
| 2312 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2313 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2314 | { |
| 2315 | |
| 2316 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2317 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2318 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2319 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2320 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2321 | |
| 2322 | switch (device_mode) { |
| 2323 | case QDF_P2P_CLIENT_MODE: |
| 2324 | case QDF_P2P_DEVICE_MODE: |
| 2325 | case QDF_OCB_MODE: |
| 2326 | case QDF_STA_MODE: |
| 2327 | case QDF_MONITOR_MODE: |
| 2328 | ret = hdd_start_station_adapter(adapter); |
| 2329 | if (ret) |
| 2330 | goto err_start_adapter; |
Alok Kumar | 81e1d73 | 2018-09-04 11:10:36 +0530 | [diff] [blame] | 2331 | |
| 2332 | hdd_nud_ignore_tracking(adapter, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2333 | break; |
| 2334 | case QDF_P2P_GO_MODE: |
| 2335 | case QDF_SAP_MODE: |
| 2336 | ret = hdd_start_ap_adapter(adapter); |
| 2337 | if (ret) |
| 2338 | goto err_start_adapter; |
| 2339 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2340 | case QDF_IBSS_MODE: |
| 2341 | /* |
| 2342 | * For IBSS interface is initialized as part of |
| 2343 | * hdd_init_station_mode() |
| 2344 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2345 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2346 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2347 | /* vdevs are dynamically managed by firmware in FTM */ |
Arun Kumar Khandavalli | f573e06 | 2019-04-16 17:17:40 +0530 | [diff] [blame] | 2348 | hdd_register_wext(adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2349 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2350 | default: |
| 2351 | hdd_err("Invalid session type %d", device_mode); |
| 2352 | QDF_ASSERT(0); |
| 2353 | goto err_start_adapter; |
| 2354 | } |
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 | if (hdd_set_fw_params(adapter)) |
| 2357 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2358 | |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 2359 | if (adapter->vdev_id != WLAN_UMAC_VDEV_ID_MAX) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2360 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2361 | if (ret < 0) { |
| 2362 | hdd_err("Failed to register frames - ret %d", ret); |
| 2363 | goto err_start_adapter; |
| 2364 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2365 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2366 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2367 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2368 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2369 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2370 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2371 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2372 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2373 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2374 | err_start_adapter: |
| 2375 | return -EINVAL; |
| 2376 | } |
| 2377 | |
| 2378 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2379 | * hdd_enable_power_management() - API to Enable Power Management |
| 2380 | * |
| 2381 | * API invokes Bus Interface Layer power management functionality |
| 2382 | * |
| 2383 | * Return: None |
| 2384 | */ |
| 2385 | static void hdd_enable_power_management(void) |
| 2386 | { |
| 2387 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2388 | |
| 2389 | if (!hif_ctx) { |
| 2390 | hdd_err("Bus Interface Context is Invalid"); |
| 2391 | return; |
| 2392 | } |
| 2393 | |
| 2394 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2395 | } |
| 2396 | |
| 2397 | /** |
| 2398 | * hdd_disable_power_management() - API to disable Power Management |
| 2399 | * |
| 2400 | * API disable Bus Interface Layer Power management functionality |
| 2401 | * |
| 2402 | * Return: None |
| 2403 | */ |
| 2404 | static void hdd_disable_power_management(void) |
| 2405 | { |
| 2406 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2407 | |
| 2408 | if (!hif_ctx) { |
| 2409 | hdd_err("Bus Interface Context is Invalid"); |
| 2410 | return; |
| 2411 | } |
| 2412 | |
| 2413 | hif_disable_power_management(hif_ctx); |
| 2414 | } |
| 2415 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2416 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2417 | { |
| 2418 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2419 | size_t target_hw_name_len; |
| 2420 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2421 | uint8_t *buf; |
| 2422 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2423 | |
| 2424 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2425 | if (!hif_sc) { |
| 2426 | hdd_err("HIF context is NULL"); |
| 2427 | return; |
| 2428 | } |
| 2429 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2430 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2431 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2432 | &target_hw_name); |
| 2433 | |
| 2434 | if (hdd_ctx->target_hw_name) |
| 2435 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2436 | |
| 2437 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2438 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2439 | if (hdd_ctx->target_hw_name) |
| 2440 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2441 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2442 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2443 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2444 | if (buf) { |
| 2445 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2446 | hdd_info("%s", buf); |
| 2447 | qdf_mem_free(buf); |
| 2448 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2449 | } |
| 2450 | |
| 2451 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2452 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2453 | * @hdd_ctx: Pointer to hdd context |
| 2454 | * |
| 2455 | * Return: none |
| 2456 | */ |
| 2457 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2458 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2459 | { |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2460 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM] = {0}; |
| 2461 | qdf_size_t out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2462 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2463 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2464 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2465 | if (!hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2466 | return; |
| 2467 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2468 | if (!hdd_ctx->config) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2469 | /* Do nothing if hdd_ctx is invalid */ |
| 2470 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2471 | return; |
| 2472 | } |
| 2473 | |
| 2474 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2475 | |
| 2476 | if (!cds_ctx) { |
| 2477 | hdd_err("Invalid CDS Context"); |
| 2478 | return; |
| 2479 | } |
| 2480 | |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2481 | for (i = 0; i < QCA_WLAN_AC_ALL; i++) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2482 | switch (i) { |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2483 | case QCA_WLAN_AC_BE: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2484 | qdf_uint8_array_parse( |
| 2485 | cfg_get(hdd_ctx->psoc, |
| 2486 | CFG_DP_ENABLE_TX_SCHED_WRR_BE), |
| 2487 | tx_sched_wrr_param, |
| 2488 | sizeof(tx_sched_wrr_param), |
| 2489 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2490 | break; |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2491 | case QCA_WLAN_AC_BK: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2492 | qdf_uint8_array_parse( |
| 2493 | cfg_get(hdd_ctx->psoc, |
| 2494 | CFG_DP_ENABLE_TX_SCHED_WRR_BK), |
| 2495 | tx_sched_wrr_param, |
| 2496 | sizeof(tx_sched_wrr_param), |
| 2497 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2498 | break; |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2499 | case QCA_WLAN_AC_VI: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2500 | qdf_uint8_array_parse( |
| 2501 | cfg_get(hdd_ctx->psoc, |
| 2502 | CFG_DP_ENABLE_TX_SCHED_WRR_VI), |
| 2503 | tx_sched_wrr_param, |
| 2504 | sizeof(tx_sched_wrr_param), |
| 2505 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2506 | break; |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2507 | case QCA_WLAN_AC_VO: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2508 | qdf_uint8_array_parse( |
| 2509 | cfg_get(hdd_ctx->psoc, |
| 2510 | CFG_DP_ENABLE_TX_SCHED_WRR_VO), |
| 2511 | tx_sched_wrr_param, |
| 2512 | sizeof(tx_sched_wrr_param), |
| 2513 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2514 | break; |
| 2515 | default: |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2516 | break; |
| 2517 | } |
| 2518 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2519 | if (out_size == TX_SCHED_WRR_PARAMS_NUM) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2520 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2521 | tx_sched_wrr_param[0]; |
| 2522 | cds_ctx->ac_specs[i].credit_threshold = |
| 2523 | tx_sched_wrr_param[1]; |
| 2524 | cds_ctx->ac_specs[i].send_limit = |
| 2525 | tx_sched_wrr_param[2]; |
| 2526 | cds_ctx->ac_specs[i].credit_reserve = |
| 2527 | tx_sched_wrr_param[3]; |
| 2528 | cds_ctx->ac_specs[i].discard_weight = |
| 2529 | tx_sched_wrr_param[4]; |
| 2530 | } |
| 2531 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2532 | out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2533 | } |
| 2534 | } |
| 2535 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2536 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2537 | const size_t version_len, uint8_t *version) |
| 2538 | { |
| 2539 | uint32_t size; |
| 2540 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2541 | |
| 2542 | if (!hdd_ctx) { |
| 2543 | hdd_err("Invalid context, HDD context is null"); |
| 2544 | return 0; |
| 2545 | } |
| 2546 | |
Ashish Kumar Dhanotiya | 7353f88 | 2018-05-15 12:50:19 +0530 | [diff] [blame] | 2547 | if (!version || version_len == 0) { |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2548 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2549 | return 0; |
| 2550 | } |
| 2551 | |
| 2552 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2553 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2554 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2555 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2556 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2557 | |
| 2558 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2559 | "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] | 2560 | QWLAN_VERSIONSTR, |
| 2561 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2562 | hdd_ctx->target_hw_name, |
| 2563 | hdd_ctx->hw_bd_info.bdf_version, |
| 2564 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2565 | hdd_ctx->hw_bd_info.customer_id, |
| 2566 | hdd_ctx->hw_bd_info.project_id, |
| 2567 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2568 | |
| 2569 | return size; |
| 2570 | } |
| 2571 | |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2572 | int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, |
| 2573 | struct sap_config *sap_config) |
| 2574 | { |
| 2575 | uint8_t preamble = 0, nss = 0, rix = 0; |
| 2576 | int ret; |
| 2577 | mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle; |
| 2578 | |
| 2579 | if (!sap_config) { |
| 2580 | if (!sme_is_feature_supported_by_fw(DOT11AX)) { |
| 2581 | hdd_err("Target does not support 11ax"); |
| 2582 | return -EIO; |
| 2583 | } |
| 2584 | } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax && |
| 2585 | sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) { |
| 2586 | hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d", |
| 2587 | sap_config->SapHw_mode, sap_config->channel); |
| 2588 | return -EIO; |
| 2589 | } |
| 2590 | |
| 2591 | if (set_value != 0xff) { |
| 2592 | rix = RC_2_RATE_IDX_11AX(set_value); |
| 2593 | preamble = WMI_RATE_PREAMBLE_HE; |
| 2594 | nss = HT_RC_2_STREAMS_11AX(set_value); |
| 2595 | |
| 2596 | set_value = hdd_assemble_rate_code(preamble, nss, rix); |
| 2597 | } else { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2598 | ret = sme_set_auto_rate_he_ltf(mac_handle, adapter->vdev_id, |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2599 | QCA_WLAN_HE_LTF_AUTO); |
| 2600 | } |
| 2601 | |
| 2602 | hdd_info("SET_11AX_RATE val %d rix %d preamble %x nss %d", |
| 2603 | set_value, rix, preamble, nss); |
| 2604 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2605 | ret = wma_cli_set_command(adapter->vdev_id, |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2606 | WMI_VDEV_PARAM_FIXED_RATE, |
| 2607 | set_value, VDEV_CMD); |
| 2608 | |
| 2609 | return ret; |
| 2610 | } |
| 2611 | |
| 2612 | int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate) |
| 2613 | { |
| 2614 | int set_value; |
| 2615 | |
| 2616 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 2617 | set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble); |
| 2618 | else |
| 2619 | set_value = (preamble << 6) | (nss << 4) | rate; |
| 2620 | |
| 2621 | return set_value; |
| 2622 | } |
| 2623 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2624 | #ifdef FEATURE_WLAN_WAPI |
| 2625 | /** |
| 2626 | * hdd_wapi_security_sta_exist() - return wapi security sta exist or not |
| 2627 | * |
| 2628 | * This API returns the wapi security station exist or not |
| 2629 | * |
| 2630 | * Return: true - wapi security station exist |
| 2631 | */ |
| 2632 | static bool hdd_wapi_security_sta_exist(void) |
| 2633 | { |
| 2634 | struct hdd_adapter *adapter = NULL; |
| 2635 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2636 | |
| 2637 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2638 | if ((adapter->device_mode == QDF_STA_MODE) && |
| 2639 | adapter->wapi_info.wapi_mode && |
| 2640 | (adapter->wapi_info.wapi_auth_mode != WAPI_AUTH_MODE_OPEN)) |
| 2641 | return true; |
| 2642 | } |
| 2643 | return false; |
| 2644 | } |
| 2645 | #else |
| 2646 | static bool hdd_wapi_security_sta_exist(void) |
| 2647 | { |
| 2648 | return false; |
| 2649 | } |
| 2650 | #endif |
| 2651 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2652 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2653 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2654 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2655 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2656 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2657 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2658 | |
| 2659 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2660 | if (!adapter) { |
| 2661 | hdd_err("Adapter is NULL"); |
| 2662 | return PM_MAX_NUM_OF_MODE; |
| 2663 | } |
| 2664 | |
| 2665 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2666 | adapter->device_mode); |
| 2667 | } |
| 2668 | |
Abhishek Singh | 3bbf6cb | 2019-03-28 14:05:43 +0530 | [diff] [blame] | 2669 | /** |
| 2670 | * hdd_is_chan_switch_in_progress() - Check if any adapter has channel switch in |
| 2671 | * progress |
| 2672 | * |
| 2673 | * Return: true, if any adapter has channel switch in |
| 2674 | * progress else false |
| 2675 | */ |
| 2676 | static bool hdd_is_chan_switch_in_progress(void) |
| 2677 | { |
| 2678 | struct hdd_adapter *adapter = NULL; |
| 2679 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2680 | |
| 2681 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2682 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 2683 | adapter->device_mode == QDF_P2P_GO_MODE) && |
| 2684 | qdf_atomic_read(&adapter->ch_switch_in_progress)) { |
| 2685 | hdd_debug("channel switch progress for vdev_id %d", |
| 2686 | adapter->vdev_id); |
| 2687 | return true; |
| 2688 | } |
| 2689 | } |
| 2690 | |
| 2691 | return false; |
| 2692 | } |
| 2693 | |
| 2694 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2695 | static void hdd_register_policy_manager_callback( |
| 2696 | struct wlan_objmgr_psoc *psoc) |
| 2697 | { |
| 2698 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2699 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2700 | qdf_mem_zero(&hdd_cbacks, sizeof(hdd_cbacks)); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2701 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2702 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2703 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2704 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2705 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2706 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2707 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2708 | hdd_cbacks.hdd_wapi_security_sta_exist = |
| 2709 | hdd_wapi_security_sta_exist; |
Abhishek Singh | 3bbf6cb | 2019-03-28 14:05:43 +0530 | [diff] [blame] | 2710 | hdd_cbacks.hdd_is_chan_switch_in_progress = |
| 2711 | hdd_is_chan_switch_in_progress; |
| 2712 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2713 | if (QDF_STATUS_SUCCESS != |
| 2714 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2715 | hdd_err("HDD callback registration with policy manager failed"); |
| 2716 | } |
| 2717 | } |
| 2718 | #else |
| 2719 | static void hdd_register_policy_manager_callback( |
| 2720 | struct wlan_objmgr_psoc *psoc) |
| 2721 | { |
| 2722 | } |
| 2723 | #endif |
| 2724 | |
Nachiket Kukade | 2fb1fdb | 2019-01-08 15:35:27 +0530 | [diff] [blame] | 2725 | #ifdef WLAN_FEATURE_NAN |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2726 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2727 | { |
| 2728 | struct nan_callbacks cb_obj = {0}; |
| 2729 | |
| 2730 | cb_obj.ndi_open = hdd_ndi_open; |
| 2731 | cb_obj.ndi_close = hdd_ndi_close; |
| 2732 | cb_obj.ndi_start = hdd_ndi_start; |
| 2733 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2734 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2735 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2736 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2737 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2738 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2739 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2740 | os_if_nan_register_hdd_callbacks(hdd_ctx->psoc, &cb_obj); |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2741 | } |
jiad | ff1ac13 | 2018-11-26 16:27:48 +0800 | [diff] [blame] | 2742 | #else |
| 2743 | static inline void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
| 2744 | { |
| 2745 | } |
| 2746 | #endif |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2747 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2748 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2749 | /** |
| 2750 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2751 | * @hdd_ctx: the global HDD context |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2752 | * @is_ssr: true if SSR is in progress |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2753 | * |
| 2754 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2755 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2756 | * |
| 2757 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2758 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2759 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2760 | * fixed. |
| 2761 | * |
| 2762 | * Return: None |
| 2763 | */ |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2764 | 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] | 2765 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2766 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2767 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2768 | wlan_objmgr_psoc_check_for_peer_leaks(hdd_ctx->psoc); |
| 2769 | wlan_objmgr_psoc_check_for_vdev_leaks(hdd_ctx->psoc); |
| 2770 | wlan_objmgr_psoc_check_for_pdev_leaks(hdd_ctx->psoc); |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2771 | |
| 2772 | /* many adapter resources are not freed by design during SSR */ |
| 2773 | if (is_ssr) |
| 2774 | return; |
| 2775 | |
Dustin Brown | c279631 | 2019-03-13 16:43:36 -0700 | [diff] [blame] | 2776 | qdf_delayed_work_check_for_leaks(); |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2777 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2778 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 2779 | qdf_periodic_work_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2780 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2781 | } |
| 2782 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2783 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2784 | #else |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2785 | static inline void hdd_check_for_leaks(struct hdd_context *hdd_ctx, bool is_ssr) |
| 2786 | { } |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2787 | |
| 2788 | #define hdd_debug_domain_set(domain) |
| 2789 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2790 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2791 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2792 | * hdd_update_country_code - Update country code |
| 2793 | * @hdd_ctx: HDD context |
| 2794 | * |
| 2795 | * Update country code based on module parameter country_code |
| 2796 | * |
| 2797 | * Return: 0 on success and errno on failure |
| 2798 | */ |
| 2799 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2800 | { |
| 2801 | if (!country_code) |
| 2802 | return 0; |
| 2803 | |
| 2804 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2805 | } |
| 2806 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2807 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2808 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2809 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2810 | qdf_device_t qdf_dev; |
| 2811 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2812 | bool unint = false; |
| 2813 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2814 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2815 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2816 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2817 | if (!qdf_dev) { |
| 2818 | hdd_err("QDF Device Context is Invalid return"); |
| 2819 | return -EINVAL; |
| 2820 | } |
| 2821 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 2822 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2823 | |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2824 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2825 | hdd_debug("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2826 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2827 | return 0; |
| 2828 | } |
| 2829 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2830 | switch (hdd_ctx->driver_status) { |
| 2831 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2832 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2833 | unint = true; |
| 2834 | /* Fall through dont add break here */ |
| 2835 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2836 | hdd_info("Wlan transitioning (CLOSED -> ENABLED)"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2837 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2838 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2839 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2840 | if (!reinit && !unint) { |
| 2841 | ret = pld_power_on(qdf_dev->dev); |
| 2842 | if (ret) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2843 | hdd_err("Failed to power up device; errno:%d", |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2844 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2845 | goto release_lock; |
| 2846 | } |
| 2847 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2848 | |
| 2849 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2850 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2851 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2852 | qdf_dev->bus_type, |
| 2853 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2854 | HIF_ENABLE_TYPE_PROBE); |
| 2855 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2856 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2857 | goto power_down; |
| 2858 | } |
| 2859 | |
| 2860 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2861 | if (!hif_ctx) { |
| 2862 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2863 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2864 | goto power_down; |
| 2865 | } |
| 2866 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2867 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2868 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2869 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2870 | status); |
| 2871 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2872 | goto hif_close; |
| 2873 | } |
| 2874 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 2875 | if (hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) { |
| 2876 | status = epping_open(); |
| 2877 | if (status) { |
| 2878 | hdd_err("Failed to open in epping mode: %d", |
| 2879 | status); |
| 2880 | ret = -EINVAL; |
| 2881 | goto cds_free; |
| 2882 | } |
| 2883 | |
| 2884 | status = epping_enable(qdf_dev->dev, false); |
| 2885 | if (status) { |
| 2886 | hdd_err("Failed to enable in epping mode : %d", |
| 2887 | status); |
| 2888 | epping_close(); |
| 2889 | goto cds_free; |
| 2890 | } |
| 2891 | |
| 2892 | hdd_info("epping mode enabled"); |
| 2893 | break; |
| 2894 | } |
| 2895 | |
jitiphil | 4c256a3 | 2018-09-07 08:51:52 +0530 | [diff] [blame] | 2896 | ucfg_ipa_component_config_update(hdd_ctx->psoc); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2897 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2898 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2899 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2900 | status = hdd_component_psoc_open(hdd_ctx->psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2901 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2902 | hdd_err("Failed to Open legacy components; status: %d", |
| 2903 | status); |
| 2904 | ret = qdf_status_to_os_return(status); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 2905 | goto cds_free; |
| 2906 | } |
| 2907 | |
| 2908 | ret = hdd_update_config(hdd_ctx); |
| 2909 | if (ret) { |
| 2910 | hdd_err("Failed to update configuration; errno: %d", |
| 2911 | ret); |
| 2912 | goto cds_free; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2913 | } |
| 2914 | |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 2915 | status = wbuff_module_init(); |
| 2916 | if (QDF_IS_STATUS_ERROR(status)) |
| 2917 | hdd_err("WBUFF init unsuccessful; status: %d", status); |
| 2918 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2919 | status = cds_open(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2920 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2921 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2922 | ret = qdf_status_to_os_return(status); |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 2923 | goto psoc_close; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2924 | } |
| 2925 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 2926 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 2927 | |
Manjunathappa Prakash | b6b4ff1 | 2018-06-04 12:32:33 -0700 | [diff] [blame] | 2928 | if (hdd_ctx->config->rx_thread_affinity_mask) |
| 2929 | cds_set_rx_thread_cpu_mask( |
| 2930 | hdd_ctx->config->rx_thread_affinity_mask); |
| 2931 | |
| 2932 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2933 | ret = hdd_update_components_config(hdd_ctx); |
| 2934 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2935 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2936 | ret); |
| 2937 | goto close; |
| 2938 | } |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2939 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2940 | status = cds_dp_open(hdd_ctx->psoc); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2941 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2942 | hdd_err("Failed to Open cds post open; status: %d", |
| 2943 | status); |
| 2944 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2945 | goto close; |
| 2946 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2947 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2948 | ret = hdd_register_cb(hdd_ctx); |
| 2949 | if (ret) { |
| 2950 | hdd_err("Failed to register HDD callbacks!"); |
| 2951 | goto cds_txrx_free; |
| 2952 | } |
| 2953 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2954 | /* |
| 2955 | * NAN compoenet requires certian operations like, open adapter, |
| 2956 | * close adapter, etc. to be initiated by HDD, for those |
| 2957 | * register HDD callbacks with UMAC's NAN componenet. |
| 2958 | */ |
| 2959 | hdd_nan_register_callbacks(hdd_ctx); |
| 2960 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2961 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2962 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2963 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2964 | ret = qdf_status_to_os_return(status); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2965 | goto deregister_cb; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2966 | } |
| 2967 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2968 | hdd_register_policy_manager_callback( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2969 | hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2970 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2971 | hdd_sysfs_create_driver_root_obj(); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2972 | hdd_sysfs_create_version_interface(hdd_ctx->psoc); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2973 | hdd_sysfs_create_powerstats_interface(); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2974 | hdd_update_hw_sw_info(hdd_ctx); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2975 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2976 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2977 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2978 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2979 | break; |
| 2980 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2981 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2982 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2983 | if (ret) { |
| 2984 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2985 | goto destroy_driver_sysfs; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2986 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2987 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2988 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2989 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2990 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2991 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2992 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2993 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2994 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2995 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2996 | goto release_lock; |
| 2997 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2998 | |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2999 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 3000 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 3001 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3002 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3003 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3004 | return 0; |
| 3005 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 3006 | destroy_driver_sysfs: |
| 3007 | hdd_sysfs_destroy_powerstats_interface(); |
| 3008 | hdd_sysfs_destroy_version_interface(); |
| 3009 | hdd_sysfs_destroy_driver_root_obj(); |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 3010 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3011 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 3012 | deregister_cb: |
| 3013 | hdd_deregister_cb(hdd_ctx); |
| 3014 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 3015 | cds_txrx_free: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3016 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 3017 | |
| 3018 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 3019 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 3020 | dispatcher_pdev_close(hdd_ctx->pdev); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 3021 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 3022 | } |
| 3023 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3024 | cds_dp_close(hdd_ctx->psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3025 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3026 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3027 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3028 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 3029 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3030 | cds_close(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3031 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 3032 | psoc_close: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3033 | hdd_component_psoc_close(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 3034 | cds_deinit_ini_config(); |
| 3035 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 3036 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3037 | ol_cds_free(); |
| 3038 | |
| 3039 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 3040 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 3041 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3042 | power_down: |
| 3043 | if (!reinit && !unint) |
| 3044 | pld_power_off(qdf_dev->dev); |
| 3045 | release_lock: |
Abhinav Kumar | 7ae9b7b | 2017-12-19 15:11:54 +0530 | [diff] [blame] | 3046 | if (hdd_ctx->target_hw_name) { |
| 3047 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 3048 | hdd_ctx->target_hw_name = NULL; |
| 3049 | } |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 3050 | |
| 3051 | hdd_check_for_leaks(hdd_ctx, reinit); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 3052 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 3053 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3054 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3055 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 3056 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3057 | } |
| 3058 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3059 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3060 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3061 | { |
| 3062 | int ret = os_if_wifi_pos_register_nl(); |
| 3063 | |
| 3064 | if (ret) |
| 3065 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 3066 | |
| 3067 | return ret; |
| 3068 | } |
| 3069 | |
| 3070 | static int hdd_deactivate_wifi_pos(void) |
| 3071 | { |
| 3072 | int ret = os_if_wifi_pos_deregister_nl(); |
| 3073 | |
| 3074 | if (ret) |
| 3075 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 3076 | |
| 3077 | return ret; |
| 3078 | } |
| 3079 | |
| 3080 | /** |
| 3081 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 3082 | * @hdd_ctx: hdd context |
| 3083 | * |
| 3084 | * Return: status of operation |
| 3085 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3086 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3087 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3088 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3089 | uint16_t neighbor_scan_max_chan_time; |
| 3090 | uint16_t neighbor_scan_min_chan_time; |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3091 | |
| 3092 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 3093 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 3094 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 3095 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 3096 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 3097 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3098 | ucfg_mlme_get_neighbor_scan_max_chan_time(psoc, |
| 3099 | &neighbor_scan_max_chan_time); |
| 3100 | ucfg_mlme_get_neighbor_scan_min_chan_time(psoc, |
| 3101 | &neighbor_scan_min_chan_time); |
| 3102 | wifi_pos_set_dwell_time_min(psoc, neighbor_scan_min_chan_time); |
| 3103 | wifi_pos_set_dwell_time_max(psoc, neighbor_scan_max_chan_time); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3104 | } |
| 3105 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3106 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3107 | { |
| 3108 | return oem_activate_service(hdd_ctx); |
| 3109 | } |
| 3110 | |
| 3111 | static int hdd_deactivate_wifi_pos(void) |
| 3112 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 3113 | return oem_deactivate_service(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3114 | } |
| 3115 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3116 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3117 | { |
| 3118 | } |
| 3119 | #endif |
| 3120 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3121 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3122 | * __hdd_open() - HDD Open function |
| 3123 | * @dev: Pointer to net_device structure |
| 3124 | * |
| 3125 | * This is called in response to ifconfig up |
| 3126 | * |
| 3127 | * Return: 0 for success; non-zero for failure |
| 3128 | */ |
| 3129 | static int __hdd_open(struct net_device *dev) |
| 3130 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3131 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3132 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3133 | int ret; |
| 3134 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3135 | hdd_enter_dev(dev); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3136 | |
| 3137 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3138 | TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3139 | adapter->vdev_id, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3140 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 3141 | /* Nothing to be done if device is unloading */ |
| 3142 | if (cds_is_driver_unloading()) { |
| 3143 | hdd_err("Driver is unloading can not open the hdd"); |
| 3144 | return -EBUSY; |
| 3145 | } |
| 3146 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 3147 | if (cds_is_driver_recovering()) { |
| 3148 | hdd_err("WLAN is currently recovering; Please try again."); |
| 3149 | return -EBUSY; |
| 3150 | } |
| 3151 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3152 | /* |
| 3153 | * This scenario can be hit in cases where in the wlan driver after |
| 3154 | * registering the netdevices and there is a failure in driver |
| 3155 | * initialization. So return error gracefully because the netdevices |
| 3156 | * will be de-registered as part of the load failure. |
| 3157 | */ |
| 3158 | |
| 3159 | if (!cds_is_driver_loaded()) { |
| 3160 | hdd_err("Failed to start the wlan driver!!"); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3161 | return -EIO; |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3162 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3163 | |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 3164 | ret = hdd_trigger_psoc_idle_restart(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3165 | if (ret) { |
| 3166 | hdd_err("Failed to start WLAN modules return"); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3167 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3168 | } |
| 3169 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3170 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3171 | ret = hdd_start_adapter(adapter); |
| 3172 | if (ret) { |
| 3173 | hdd_err("Failed to start adapter :%d", |
| 3174 | adapter->device_mode); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3175 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3176 | } |
| 3177 | } |
| 3178 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3179 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3180 | 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] | 3181 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3182 | /* Enable TX queues only when we are connected */ |
| 3183 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3184 | WLAN_START_ALL_NETIF_QUEUE, |
| 3185 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3186 | } |
| 3187 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3188 | /* Enable carrier and transmit queues for NDI */ |
| 3189 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3190 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3191 | wlan_hdd_netif_queue_control(adapter, |
| 3192 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3193 | WLAN_CONTROL_PATH); |
| 3194 | } |
| 3195 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3196 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3197 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3198 | |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3199 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3200 | } |
| 3201 | |
| 3202 | /** |
| 3203 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3204 | * @net_dev: Pointer to net_device structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3205 | * |
| 3206 | * This is called in response to ifconfig up |
| 3207 | * |
| 3208 | * Return: 0 for success; non-zero for failure |
| 3209 | */ |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3210 | static int hdd_open(struct net_device *net_dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3211 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3212 | int errno; |
| 3213 | struct osif_vdev_sync *vdev_sync; |
| 3214 | |
| 3215 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 3216 | if (errno) |
| 3217 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3218 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3219 | errno = __hdd_open(net_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3220 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3221 | osif_vdev_sync_trans_stop(vdev_sync); |
| 3222 | |
| 3223 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3224 | } |
| 3225 | |
| 3226 | /** |
| 3227 | * __hdd_stop() - HDD stop function |
| 3228 | * @dev: Pointer to net_device structure |
| 3229 | * |
| 3230 | * This is called in response to ifconfig down |
| 3231 | * |
| 3232 | * Return: 0 for success; non-zero for failure |
| 3233 | */ |
| 3234 | static int __hdd_stop(struct net_device *dev) |
| 3235 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3236 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3237 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3238 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3239 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3240 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3241 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3242 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3243 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3244 | TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3245 | adapter->vdev_id, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3246 | |
| 3247 | ret = wlan_hdd_validate_context(hdd_ctx); |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3248 | if (ret) { |
| 3249 | set_bit(DOWN_DURING_SSR, &adapter->event_flags); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3250 | return ret; |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3251 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3252 | |
| 3253 | /* Nothing to be done if the interface is not opened */ |
| 3254 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3255 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3256 | return -ENODEV; |
| 3257 | } |
| 3258 | |
| 3259 | /* Make sure the interface is marked as closed */ |
| 3260 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3261 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3262 | mac_handle = hdd_ctx->mac_handle; |
| 3263 | |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3264 | hdd_debug("Disabling Auto Power save timer"); |
| 3265 | sme_ps_disable_auto_ps_timer( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3266 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3267 | adapter->vdev_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3268 | |
| 3269 | /* |
| 3270 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3271 | * be called on that interface |
| 3272 | */ |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 3273 | hdd_debug("Disabling queues, adapter device mode: %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 3274 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3275 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3276 | wlan_hdd_netif_queue_control(adapter, |
| 3277 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3278 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3279 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3280 | if (adapter->device_mode == QDF_STA_MODE) |
| 3281 | hdd_lpass_notify_stop(hdd_ctx); |
| 3282 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3283 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3284 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3285 | * bursty in nature and depends on the need to transfer. The service |
| 3286 | * layer may down the interface after the usage and up again when |
| 3287 | * required. In some sense, the NDI is expected to be available |
| 3288 | * (like SAP) iface until NDI delete request is issued by the service |
| 3289 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3290 | * interface (NDI). |
| 3291 | */ |
| 3292 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3293 | return 0; |
| 3294 | |
| 3295 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3296 | * The interface is marked as down for outside world (aka kernel) |
| 3297 | * But the driver is pretty much alive inside. The driver needs to |
| 3298 | * tear down the existing connection on the netdev (session) |
| 3299 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3300 | * for this interface. The call also needs to wait until the above |
| 3301 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3302 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3303 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3304 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3305 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3306 | |
| 3307 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3308 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3309 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3310 | if (!hdd_is_any_interface_open(hdd_ctx)) |
| 3311 | hdd_psoc_idle_timer_start(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3312 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3313 | hdd_exit(); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3314 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3315 | return 0; |
| 3316 | } |
| 3317 | |
| 3318 | /** |
| 3319 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3320 | * @dev: pointer to net_device structure |
| 3321 | * |
| 3322 | * This is called in response to ifconfig down |
| 3323 | * |
| 3324 | * Return: 0 for success and error number for failure |
| 3325 | */ |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3326 | static int hdd_stop(struct net_device *net_dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3327 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3328 | int errno; |
| 3329 | struct osif_vdev_sync *vdev_sync; |
| 3330 | |
| 3331 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 3332 | if (errno) |
| 3333 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3334 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3335 | errno = __hdd_stop(net_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3336 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3337 | osif_vdev_sync_trans_stop(vdev_sync); |
| 3338 | |
| 3339 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3340 | } |
| 3341 | |
| 3342 | /** |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3343 | * hdd_uninit() - HDD uninit function |
| 3344 | * @dev: Pointer to net_device structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3345 | * |
| 3346 | * This is called during the netdev unregister to uninitialize all data |
| 3347 | * associated with the device |
| 3348 | * |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3349 | * This function must be protected by a transition |
| 3350 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3351 | * Return: None |
| 3352 | */ |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3353 | static void hdd_uninit(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3354 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3355 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3356 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3357 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3358 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3359 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3360 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 3361 | hdd_err("Invalid magic"); |
| 3362 | goto exit; |
| 3363 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3364 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3365 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3366 | if (!hdd_ctx) { |
| 3367 | hdd_err("NULL hdd_ctx"); |
| 3368 | goto exit; |
| 3369 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3370 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3371 | if (dev != adapter->dev) |
| 3372 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3373 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3374 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3375 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3376 | /* after uninit our adapter structure will no longer be valid */ |
| 3377 | adapter->dev = NULL; |
| 3378 | adapter->magic = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3379 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3380 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3381 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3382 | } |
| 3383 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3384 | static int hdd_open_cesium_nl_sock(void) |
| 3385 | { |
| 3386 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3387 | struct netlink_kernel_cfg cfg = { |
| 3388 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3389 | .input = NULL |
| 3390 | }; |
| 3391 | #endif |
| 3392 | int ret = 0; |
| 3393 | |
| 3394 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3395 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3396 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3397 | THIS_MODULE, |
| 3398 | #endif |
| 3399 | &cfg); |
| 3400 | #else |
| 3401 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3402 | WLAN_NLINK_MCAST_GRP_ID, |
| 3403 | NULL, NULL, THIS_MODULE); |
| 3404 | #endif |
| 3405 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3406 | if (!cesium_nl_srv_sock) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3407 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3408 | ret = -ECONNREFUSED; |
| 3409 | } |
| 3410 | |
| 3411 | return ret; |
| 3412 | } |
| 3413 | |
| 3414 | static void hdd_close_cesium_nl_sock(void) |
| 3415 | { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3416 | if (cesium_nl_srv_sock) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3417 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3418 | cesium_nl_srv_sock = NULL; |
| 3419 | } |
| 3420 | } |
| 3421 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3422 | void hdd_update_dynamic_mac(struct hdd_context *hdd_ctx, |
| 3423 | struct qdf_mac_addr *curr_mac_addr, |
| 3424 | struct qdf_mac_addr *new_mac_addr) |
| 3425 | { |
| 3426 | uint8_t i; |
| 3427 | |
| 3428 | hdd_enter(); |
| 3429 | |
| 3430 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3431 | if (!qdf_mem_cmp( |
| 3432 | curr_mac_addr->bytes, |
| 3433 | &hdd_ctx->dynamic_mac_list[i].dynamic_mac.bytes[0], |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3434 | sizeof(struct qdf_mac_addr))) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3435 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[i].dynamic_mac, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3436 | new_mac_addr->bytes, |
| 3437 | sizeof(struct qdf_mac_addr)); |
| 3438 | break; |
| 3439 | } |
| 3440 | } |
| 3441 | |
| 3442 | hdd_exit(); |
| 3443 | } |
| 3444 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3445 | /** |
| 3446 | * __hdd_set_mac_address() - set the user specified mac address |
| 3447 | * @dev: Pointer to the net device. |
| 3448 | * @addr: Pointer to the sockaddr. |
| 3449 | * |
| 3450 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3451 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3452 | * |
| 3453 | * Return: 0 for success, non zero for failure |
| 3454 | */ |
| 3455 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3456 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3457 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3458 | struct hdd_adapter *adapter_temp; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3459 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3460 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3461 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3462 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3463 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3464 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3465 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3466 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3467 | if (netif_running(dev)) { |
| 3468 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3469 | return -EBUSY; |
| 3470 | } |
| 3471 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3472 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3473 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3474 | if (0 != ret) |
| 3475 | return ret; |
| 3476 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3477 | 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] | 3478 | adapter_temp = hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes); |
| 3479 | if (adapter_temp) { |
| 3480 | if (!qdf_str_cmp(adapter_temp->dev->name, dev->name)) |
| 3481 | return 0; |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3482 | hdd_err("%s adapter exist with same address " QDF_MAC_ADDR_STR, |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3483 | adapter_temp->dev->name, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3484 | QDF_MAC_ADDR_ARRAY(mac_addr.bytes)); |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3485 | return -EINVAL; |
| 3486 | } |
| 3487 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 3488 | qdf_ret_status = wlan_hdd_validate_mac_address(&mac_addr); |
| 3489 | if (QDF_IS_STATUS_ERROR(qdf_ret_status)) |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3490 | return -EINVAL; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3491 | |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3492 | hdd_info("Changing MAC to " QDF_MAC_ADDR_STR " of the interface %s ", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3493 | QDF_MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3494 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3495 | hdd_update_dynamic_mac(hdd_ctx, &adapter->mac_addr, &mac_addr); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3496 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3497 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3498 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3499 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3500 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3501 | } |
| 3502 | |
| 3503 | /** |
| 3504 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3505 | * function from SSR |
| 3506 | * @net_dev: pointer to net_device structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3507 | * @addr: Pointer to the sockaddr |
| 3508 | * |
| 3509 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3510 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3511 | * |
| 3512 | * Return: 0 for success. |
| 3513 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3514 | 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] | 3515 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3516 | struct osif_vdev_sync *vdev_sync; |
| 3517 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3518 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3519 | errno = osif_vdev_sync_op_start(net_dev, &vdev_sync); |
| 3520 | if (errno) |
| 3521 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3522 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3523 | errno = __hdd_set_mac_address(net_dev, addr); |
| 3524 | |
| 3525 | osif_vdev_sync_op_stop(vdev_sync); |
| 3526 | |
| 3527 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3528 | } |
| 3529 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3530 | 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] | 3531 | { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3532 | int i, j; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3533 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3534 | i = qdf_ffz(hdd_ctx->derived_intf_addr_mask); |
| 3535 | if (i < 0 || i >= hdd_ctx->num_derived_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3536 | return NULL; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3537 | qdf_atomic_set_bit(i, &hdd_ctx->derived_intf_addr_mask); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3538 | hdd_info("Assigning MAC from derived list" QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3539 | QDF_MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3540 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3541 | /* Copy the mac in dynamic mac list at first free position */ |
| 3542 | for (j = 0; j < QDF_MAX_CONCURRENCY_PERSONA; j++) { |
| 3543 | if (qdf_is_macaddr_zero(&hdd_ctx-> |
| 3544 | dynamic_mac_list[j].dynamic_mac)) |
| 3545 | break; |
| 3546 | } |
| 3547 | if (j == QDF_MAX_CONCURRENCY_PERSONA) { |
| 3548 | hdd_err("Max interfaces are up"); |
| 3549 | return NULL; |
| 3550 | } |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 3551 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3552 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[j].dynamic_mac.bytes, |
| 3553 | &hdd_ctx->derived_mac_addr[i].bytes, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3554 | sizeof(struct qdf_mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3555 | hdd_ctx->dynamic_mac_list[j].is_provisioned_mac = false; |
| 3556 | hdd_ctx->dynamic_mac_list[j].bit_position = i; |
| 3557 | |
| 3558 | return hdd_ctx->derived_mac_addr[i].bytes; |
| 3559 | } |
| 3560 | |
| 3561 | static uint8_t *wlan_hdd_get_provisioned_intf_addr(struct hdd_context *hdd_ctx) |
| 3562 | { |
| 3563 | int i, j; |
| 3564 | |
| 3565 | i = qdf_ffz(hdd_ctx->provisioned_intf_addr_mask); |
| 3566 | if (i < 0 || i >= hdd_ctx->num_provisioned_addr) |
| 3567 | return NULL; |
| 3568 | qdf_atomic_set_bit(i, &hdd_ctx->provisioned_intf_addr_mask); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3569 | hdd_info("Assigning MAC from provisioned list" QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3570 | QDF_MAC_ADDR_ARRAY(hdd_ctx->provisioned_mac_addr[i].bytes)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3571 | |
| 3572 | /* Copy the mac in dynamic mac list at first free position */ |
| 3573 | for (j = 0; j < QDF_MAX_CONCURRENCY_PERSONA; j++) { |
| 3574 | if (qdf_is_macaddr_zero(&hdd_ctx-> |
| 3575 | dynamic_mac_list[j].dynamic_mac)) |
| 3576 | break; |
| 3577 | } |
| 3578 | if (j == QDF_MAX_CONCURRENCY_PERSONA) { |
| 3579 | hdd_err("Max interfaces are up"); |
| 3580 | return NULL; |
| 3581 | } |
| 3582 | |
| 3583 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[j].dynamic_mac.bytes, |
| 3584 | &hdd_ctx->provisioned_mac_addr[i].bytes, |
| 3585 | sizeof(struct qdf_mac_addr)); |
| 3586 | hdd_ctx->dynamic_mac_list[j].is_provisioned_mac = true; |
| 3587 | hdd_ctx->dynamic_mac_list[j].bit_position = i; |
| 3588 | return hdd_ctx->provisioned_mac_addr[i].bytes; |
| 3589 | } |
| 3590 | |
| 3591 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx, |
| 3592 | enum QDF_OPMODE interface_type) |
| 3593 | { |
| 3594 | uint8_t *mac_addr = NULL; |
| 3595 | |
| 3596 | if (qdf_atomic_test_bit(interface_type, |
| 3597 | (unsigned long *) |
| 3598 | (&hdd_ctx->config->provisioned_intf_pool))) |
| 3599 | mac_addr = wlan_hdd_get_provisioned_intf_addr(hdd_ctx); |
| 3600 | |
| 3601 | if ((!mac_addr) && |
| 3602 | (qdf_atomic_test_bit(interface_type, |
| 3603 | (unsigned long *) |
| 3604 | (&hdd_ctx->config->derived_intf_pool)))) |
| 3605 | mac_addr = wlan_hdd_get_derived_intf_addr(hdd_ctx); |
| 3606 | |
| 3607 | if (!mac_addr) |
| 3608 | hdd_err("MAC is not available in both the lists"); |
| 3609 | return mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3610 | } |
| 3611 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3612 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3613 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3614 | { |
| 3615 | int i; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3616 | int mac_pos_in_mask; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3617 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3618 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3619 | if (!memcmp(releaseAddr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3620 | hdd_ctx->dynamic_mac_list[i].dynamic_mac.bytes, |
| 3621 | QDF_MAC_ADDR_SIZE)) { |
| 3622 | mac_pos_in_mask = |
| 3623 | hdd_ctx->dynamic_mac_list[i].bit_position; |
| 3624 | if (hdd_ctx->dynamic_mac_list[i].is_provisioned_mac) { |
| 3625 | qdf_atomic_clear_bit( |
| 3626 | mac_pos_in_mask, |
| 3627 | &hdd_ctx-> |
| 3628 | provisioned_intf_addr_mask); |
| 3629 | hdd_info("Releasing MAC from provisioned list"); |
| 3630 | hdd_info( |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3631 | QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3632 | QDF_MAC_ADDR_ARRAY(releaseAddr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3633 | } else { |
| 3634 | qdf_atomic_clear_bit( |
| 3635 | mac_pos_in_mask, &hdd_ctx-> |
| 3636 | derived_intf_addr_mask); |
| 3637 | hdd_info("Releasing MAC from derived list"); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3638 | hdd_info(QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3639 | QDF_MAC_ADDR_ARRAY(releaseAddr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3640 | } |
| 3641 | qdf_zero_macaddr(&hdd_ctx-> |
| 3642 | dynamic_mac_list[i].dynamic_mac); |
| 3643 | hdd_ctx->dynamic_mac_list[i].is_provisioned_mac = |
| 3644 | false; |
| 3645 | hdd_ctx->dynamic_mac_list[i].bit_position = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3646 | break; |
| 3647 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3648 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3649 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3650 | if (i == QDF_MAX_CONCURRENCY_PERSONA) |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3651 | hdd_err("Releasing non existing MAC" QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3652 | QDF_MAC_ADDR_ARRAY(releaseAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3653 | } |
| 3654 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3655 | /** |
| 3656 | * __hdd_set_multicast_list() - set the multicast address list |
| 3657 | * @dev: Pointer to the WLAN device. |
| 3658 | * @skb: Pointer to OS packet (sk_buff). |
| 3659 | * |
| 3660 | * This funciton sets the multicast address list. |
| 3661 | * |
| 3662 | * Return: None |
| 3663 | */ |
| 3664 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3665 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3666 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3667 | int i = 0, errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3668 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3669 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3670 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3671 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3672 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3673 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3674 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3675 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3676 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3677 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3678 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 3679 | if (errno) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3680 | goto out; |
| 3681 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3682 | errno = hdd_validate_adapter(adapter); |
| 3683 | if (errno) |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3684 | goto out; |
| 3685 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3686 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3687 | hdd_err("%s: Driver module is closed", __func__); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3688 | goto out; |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3689 | } |
| 3690 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3691 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 3692 | if (!mc_list_request) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3693 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3694 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3695 | /* Delete already configured multicast address list */ |
| 3696 | if (adapter->mc_addr_list.mc_cnt > 0) { |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3697 | hdd_debug("clear previously configured MC address list"); |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3698 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3699 | pmo_mc_list_change_notify); |
| 3700 | } |
| 3701 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3702 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3703 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3704 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3705 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3706 | } else { |
| 3707 | mc_count = netdev_mc_count(dev); |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 3708 | if (mc_count > ucfg_pmo_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3709 | 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] | 3710 | ucfg_pmo_max_mc_addr_supported(psoc)); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3711 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3712 | pmo_mc_list_change_notify); |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3713 | adapter->mc_addr_list.mc_cnt = 0; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3714 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3715 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3716 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3717 | hdd_debug("ha_addr[%d] "QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3718 | i, QDF_MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3719 | if (i == mc_count) |
| 3720 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3721 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3722 | 0, ETH_ALEN); |
| 3723 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3724 | ha->addr, ETH_ALEN); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3725 | hdd_debug("mlist[%d] = %pM", i, |
| 3726 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3727 | i++; |
| 3728 | } |
| 3729 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3730 | |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3731 | adapter->mc_addr_list.mc_cnt = mc_count; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3732 | mc_list_request->psoc = psoc; |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3733 | mc_list_request->vdev_id = adapter->vdev_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3734 | mc_list_request->count = mc_count; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3735 | |
| 3736 | errno = hdd_cache_mc_addr_list(mc_list_request); |
| 3737 | if (errno) { |
| 3738 | 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] | 3739 | adapter->vdev_id, errno); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3740 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3741 | } |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3742 | |
| 3743 | hdd_enable_mc_addr_filtering(adapter, pmo_mc_list_change_notify); |
| 3744 | |
| 3745 | free_req: |
| 3746 | qdf_mem_free(mc_list_request); |
| 3747 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3748 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3749 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3750 | } |
| 3751 | |
| 3752 | /** |
| 3753 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3754 | * @net_dev: pointer to net_device |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3755 | * |
| 3756 | * Return: none |
| 3757 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3758 | static void hdd_set_multicast_list(struct net_device *net_dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3759 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3760 | struct osif_vdev_sync *vdev_sync; |
| 3761 | |
| 3762 | if (osif_vdev_sync_op_start(net_dev, &vdev_sync)) |
| 3763 | return; |
| 3764 | |
| 3765 | __hdd_set_multicast_list(net_dev); |
| 3766 | |
| 3767 | osif_vdev_sync_op_stop(vdev_sync); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3768 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3769 | |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3770 | #ifdef WLAN_FEATURE_TSF_PTP |
| 3771 | static const struct ethtool_ops wlan_ethtool_ops = { |
| 3772 | .get_ts_info = wlan_get_ts_info, |
| 3773 | }; |
| 3774 | #endif |
| 3775 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3776 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3777 | .ndo_open = hdd_open, |
| 3778 | .ndo_stop = hdd_stop, |
| 3779 | .ndo_uninit = hdd_uninit, |
| 3780 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3781 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3782 | .ndo_get_stats = hdd_get_stats, |
| 3783 | .ndo_do_ioctl = hdd_ioctl, |
| 3784 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3785 | .ndo_select_queue = hdd_select_queue, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3786 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3787 | }; |
| 3788 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3789 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3790 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3791 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3792 | .ndo_open = hdd_mon_open, |
| 3793 | .ndo_stop = hdd_stop, |
| 3794 | .ndo_get_stats = hdd_get_stats, |
| 3795 | }; |
| 3796 | |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3797 | #ifdef WLAN_FEATURE_TSF_PTP |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3798 | /** |
| 3799 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3800 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3801 | * Return: None |
| 3802 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3803 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3804 | { |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3805 | if (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE) { |
| 3806 | dev->netdev_ops = &wlan_mon_drv_ops; |
| 3807 | } else { |
| 3808 | dev->netdev_ops = &wlan_drv_ops; |
| 3809 | dev->ethtool_ops = &wlan_ethtool_ops; |
| 3810 | } |
| 3811 | } |
| 3812 | #else |
| 3813 | void hdd_set_station_ops(struct net_device *dev) |
| 3814 | { |
| 3815 | if (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3816 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3817 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3818 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3819 | } |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3820 | |
| 3821 | #endif |
| 3822 | #else |
| 3823 | #ifdef WLAN_FEATURE_TSF_PTP |
| 3824 | void hdd_set_station_ops(struct net_device *dev) |
| 3825 | { |
| 3826 | dev->netdev_ops = &wlan_drv_ops; |
| 3827 | dev->ethtool_ops = &wlan_ethtool_ops; |
| 3828 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3829 | #else |
| 3830 | void hdd_set_station_ops(struct net_device *dev) |
| 3831 | { |
| 3832 | dev->netdev_ops = &wlan_drv_ops; |
| 3833 | } |
| 3834 | #endif |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3835 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3836 | |
| 3837 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3838 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3839 | * @hdd_ctx: global hdd context |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3840 | * @mac_addr: mac address to assign to the interface |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3841 | * @name: User-visible name of the interface |
| 3842 | * |
| 3843 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3844 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3845 | * |
| 3846 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3847 | */ |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3848 | static struct hdd_adapter * |
| 3849 | hdd_alloc_station_adapter(struct hdd_context *hdd_ctx, tSirMacAddr mac_addr, |
| 3850 | unsigned char name_assign_type, const char *name) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3851 | { |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3852 | struct net_device *dev; |
| 3853 | struct hdd_adapter *adapter; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3854 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3855 | QDF_STATUS qdf_status; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3856 | |
| 3857 | /* cfg80211 initialization and registration */ |
| 3858 | dev = alloc_netdev_mq(sizeof(*adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3859 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3860 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3861 | #endif |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3862 | (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE ? |
| 3863 | hdd_mon_mode_ether_setup : ether_setup), |
| 3864 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3865 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3866 | if (!dev) { |
| 3867 | hdd_err("Failed to allocate new net_device '%s'", name); |
| 3868 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3869 | } |
| 3870 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3871 | adapter = netdev_priv(dev); |
| 3872 | |
| 3873 | qdf_mem_zero(adapter, sizeof(*adapter)); |
| 3874 | sta_ctx = &adapter->session.station; |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 3875 | qdf_mem_set(sta_ctx->conn_info.sta_id, |
| 3876 | sizeof(sta_ctx->conn_info.sta_id), |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3877 | HDD_WLAN_INVALID_STA_ID); |
| 3878 | adapter->dev = dev; |
| 3879 | adapter->hdd_ctx = hdd_ctx; |
| 3880 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 3881 | adapter->vdev_id = WLAN_UMAC_VDEV_ID_MAX; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3882 | |
| 3883 | qdf_status = qdf_event_create(&adapter->qdf_session_open_event); |
| 3884 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3885 | goto free_net_dev; |
| 3886 | |
| 3887 | qdf_status = qdf_event_create(&adapter->qdf_session_close_event); |
| 3888 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3889 | goto free_net_dev; |
| 3890 | |
| 3891 | adapter->offloads_configured = false; |
| 3892 | adapter->is_link_up_service_needed = false; |
| 3893 | adapter->disconnection_in_progress = false; |
| 3894 | adapter->send_mode_change = true; |
| 3895 | |
| 3896 | /* Init the net_device structure */ |
| 3897 | strlcpy(dev->name, name, IFNAMSIZ); |
| 3898 | |
| 3899 | qdf_mem_copy(dev->dev_addr, mac_addr, sizeof(tSirMacAddr)); |
| 3900 | qdf_mem_copy(adapter->mac_addr.bytes, mac_addr, sizeof(tSirMacAddr)); |
| 3901 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 3902 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3903 | hdd_set_station_ops(adapter->dev); |
| 3904 | |
| 3905 | hdd_dev_setup_destructor(dev); |
| 3906 | dev->ieee80211_ptr = &adapter->wdev; |
| 3907 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
| 3908 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 3909 | adapter->wdev.netdev = dev; |
| 3910 | |
| 3911 | /* set dev's parent to underlying device */ |
| 3912 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
| 3913 | hdd_wmm_init(adapter); |
| 3914 | spin_lock_init(&adapter->pause_map_lock); |
| 3915 | adapter->start_time = qdf_system_ticks(); |
| 3916 | adapter->last_time = adapter->start_time; |
| 3917 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3918 | return adapter; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3919 | |
| 3920 | free_net_dev: |
| 3921 | free_netdev(adapter->dev); |
| 3922 | |
| 3923 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3924 | } |
| 3925 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3926 | 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] | 3927 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3928 | struct net_device *dev = adapter->dev; |
| 3929 | int ret; |
| 3930 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3931 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3932 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3933 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3934 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3935 | |
| 3936 | ret = dev_alloc_name(dev, dev->name); |
| 3937 | if (ret < 0) { |
| 3938 | hdd_err( |
| 3939 | "unable to get dev name: %s, err = 0x%x", |
| 3940 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3941 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3942 | } |
| 3943 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3944 | |
| 3945 | ret = register_netdevice(dev); |
| 3946 | if (ret) { |
| 3947 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3948 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3949 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3950 | } |
| 3951 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3952 | ret = register_netdev(dev); |
| 3953 | if (ret) { |
| 3954 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3955 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3956 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3957 | } |
| 3958 | } |
| 3959 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3960 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3961 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3962 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3963 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3964 | } |
| 3965 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3966 | QDF_STATUS hdd_sme_open_session_callback(uint8_t vdev_id, |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3967 | QDF_STATUS qdf_status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3968 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3969 | struct hdd_adapter *adapter; |
| 3970 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3971 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3972 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3973 | if (!hdd_ctx) { |
| 3974 | hdd_err("Invalid HDD_CTX"); |
| 3975 | return QDF_STATUS_E_FAILURE; |
| 3976 | } |
| 3977 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3978 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3979 | if (!adapter) { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3980 | hdd_err("NULL adapter for %d", vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3981 | return QDF_STATUS_E_INVAL; |
| 3982 | } |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3983 | |
| 3984 | if (qdf_status == QDF_STATUS_SUCCESS) |
| 3985 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3986 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3987 | qdf_event_set(&adapter->qdf_session_open_event); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3988 | hdd_debug("session %d opened", adapter->vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3989 | |
| 3990 | return QDF_STATUS_SUCCESS; |
| 3991 | } |
| 3992 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3993 | QDF_STATUS hdd_sme_close_session_callback(uint8_t vdev_id) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3994 | { |
| 3995 | struct hdd_adapter *adapter; |
| 3996 | struct hdd_context *hdd_ctx; |
| 3997 | |
| 3998 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3999 | if (!hdd_ctx) { |
| 4000 | hdd_err("Invalid HDD_CTX"); |
| 4001 | return QDF_STATUS_E_FAILURE; |
| 4002 | } |
| 4003 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 4004 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 4005 | if (!adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4006 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4007 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4008 | } |
| 4009 | |
| 4010 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4011 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4012 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4013 | } |
| 4014 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4015 | /* |
| 4016 | * For NAN Data interface, the close session results in the final |
| 4017 | * indication to the userspace |
| 4018 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 4019 | if (adapter->device_mode == QDF_NDI_MODE) |
| 4020 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4021 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4022 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4023 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4024 | /* |
| 4025 | * We can be blocked while waiting for scheduled work to be |
| 4026 | * flushed, and the adapter structure can potentially be freed, in |
| 4027 | * which case the magic will have been reset. So make sure the |
| 4028 | * magic is still good, and hence the adapter structure is still |
| 4029 | * valid, before signaling completion |
| 4030 | */ |
| 4031 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4032 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4033 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4034 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4035 | } |
| 4036 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4037 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4038 | { |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4039 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4040 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4041 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4042 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4043 | if (!vdev) |
| 4044 | return -EINVAL; |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4045 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4046 | status = pmo_vdev_ready(vdev); |
| 4047 | if (QDF_IS_STATUS_ERROR(status)) { |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4048 | hdd_objmgr_put_vdev(vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4049 | return qdf_status_to_os_return(status); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4050 | } |
| 4051 | |
| 4052 | status = ucfg_reg_11d_vdev_created_update(vdev); |
| 4053 | if (QDF_IS_STATUS_ERROR(status)) { |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4054 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4055 | return qdf_status_to_os_return(status); |
| 4056 | } |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4057 | |
| 4058 | if (wma_capability_enhanced_mcast_filter()) |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4059 | status = ucfg_pmo_enhanced_mc_filter_enable(vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4060 | else |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4061 | status = ucfg_pmo_enhanced_mc_filter_disable(vdev); |
| 4062 | |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4063 | hdd_objmgr_put_vdev(vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4064 | |
| 4065 | return qdf_status_to_os_return(status); |
| 4066 | } |
| 4067 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4068 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4069 | { |
| 4070 | QDF_STATUS status; |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4071 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4072 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4073 | uint8_t vdev_id; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4074 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4075 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4076 | vdev_id = adapter->vdev_id; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4077 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4078 | |
| 4079 | /* vdev created sanity check */ |
| 4080 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4081 | hdd_err("vdev %u does not exist", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4082 | return -EINVAL; |
| 4083 | } |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4084 | |
Abhishek Singh | 628bb6f | 2019-03-26 14:52:40 +0530 | [diff] [blame] | 4085 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4086 | |
| 4087 | /* |
| 4088 | * if this is the last active connection check & stop the |
| 4089 | * opportunistic timer first |
| 4090 | */ |
| 4091 | if ((policy_mgr_get_connection_count(hdd_ctx->psoc) == 1 && |
| 4092 | policy_mgr_mode_specific_connection_count(hdd_ctx->psoc, |
| 4093 | policy_mgr_convert_device_mode_to_qdf_type( |
| 4094 | adapter->device_mode), NULL) == 1) || |
| 4095 | !policy_mgr_get_connection_count(hdd_ctx->psoc)) |
| 4096 | policy_mgr_check_and_stop_opportunistic_timer(hdd_ctx->psoc, |
| 4097 | adapter->vdev_id); |
| 4098 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4099 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4100 | if (!vdev) |
| 4101 | return -EINVAL; |
Ashish Kumar Dhanotiya | 68ee2e4 | 2018-11-19 21:15:14 +0530 | [diff] [blame] | 4102 | |
| 4103 | ucfg_pmo_del_wow_pattern(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4104 | status = ucfg_reg_11d_vdev_delete_update(vdev); |
Abhishek Singh | 935e477 | 2018-11-21 14:14:10 +0530 | [diff] [blame] | 4105 | ucfg_scan_vdev_set_disable(vdev, REASON_VDEV_DOWN); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4106 | hdd_objmgr_put_vdev(vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4107 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4108 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4109 | qdf_event_reset(&adapter->qdf_session_close_event); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4110 | status = sme_close_session(hdd_ctx->mac_handle, adapter->vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4111 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4112 | hdd_err("failed to close sme session; status:%d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4113 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4114 | } |
| 4115 | |
| 4116 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4117 | status = qdf_wait_for_event_completion( |
| 4118 | &adapter->qdf_session_close_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4119 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4120 | |
| 4121 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4122 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4123 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4124 | if (adapter->device_mode == QDF_NDI_MODE) |
| 4125 | hdd_ndp_session_end_handler(adapter); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4126 | |
| 4127 | if (status == QDF_STATUS_E_TIMEOUT) |
| 4128 | hdd_err("timed out waiting for sme close session"); |
| 4129 | else if (adapter->qdf_session_close_event.force_set) |
| 4130 | hdd_info("SSR occurred during sme close session"); |
| 4131 | else |
| 4132 | hdd_err("failed to wait for sme close session; status:%u", |
| 4133 | status); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4134 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4135 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4136 | release_vdev: |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4137 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4138 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4139 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4140 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4141 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4142 | return errno; |
| 4143 | } |
| 4144 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4145 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4146 | |
| 4147 | return 0; |
| 4148 | } |
| 4149 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4150 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 4151 | struct sme_session_params *session_param, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4152 | csr_roam_complete_cb callback, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4153 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4154 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4155 | uint32_t type; |
| 4156 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4157 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4158 | |
| 4159 | /* determine vdev (sub)type */ |
| 4160 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4161 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4162 | hdd_err("failed to get vdev type: %d", status); |
| 4163 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4164 | } |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4165 | session_param->sme_session_id = adapter->vdev_id; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4166 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 4167 | session_param->type_of_persona = type; |
| 4168 | session_param->subtype_of_persona = sub_type; |
| 4169 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 4170 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 4171 | session_param->callback = callback; |
| 4172 | session_param->callback_ctx = callback_ctx; |
| 4173 | |
| 4174 | return 0; |
| 4175 | } |
| 4176 | |
gaurank kathpalia | 6c4b50c | 2019-02-28 14:07:48 +0530 | [diff] [blame] | 4177 | void |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4178 | hdd_store_nss_chains_cfg_in_vdev(struct hdd_adapter *adapter) |
| 4179 | { |
| 4180 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 4181 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4182 | |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4183 | /* Populate the nss chain params from ini for this vdev type */ |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4184 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 4185 | adapter->device_mode, |
| 4186 | hdd_ctx->num_rf_chains); |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4187 | |
| 4188 | /* Store the nss chain config into the vdev */ |
| 4189 | sme_store_nss_chains_cfg_in_vdev(adapter->vdev, &vdev_ini_cfg); |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4190 | } |
gaurank kathpalia | 6982d47 | 2018-10-31 21:54:15 +0530 | [diff] [blame] | 4191 | |
| 4192 | bool hdd_is_vdev_in_conn_state(struct hdd_adapter *adapter) |
| 4193 | { |
| 4194 | switch (adapter->device_mode) { |
| 4195 | case QDF_STA_MODE: |
| 4196 | case QDF_P2P_CLIENT_MODE: |
| 4197 | case QDF_P2P_DEVICE_MODE: |
| 4198 | return hdd_conn_is_connected( |
| 4199 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)); |
| 4200 | case QDF_SAP_MODE: |
| 4201 | case QDF_P2P_GO_MODE: |
| 4202 | return (test_bit(SOFTAP_BSS_STARTED, |
| 4203 | &adapter->event_flags)); |
| 4204 | default: |
| 4205 | hdd_err("Device mode %d invalid", adapter->device_mode); |
| 4206 | return 0; |
| 4207 | } |
| 4208 | |
| 4209 | return 0; |
| 4210 | } |
| 4211 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4212 | int hdd_vdev_create(struct hdd_adapter *adapter, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4213 | csr_roam_complete_cb callback, void *ctx) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4214 | { |
| 4215 | QDF_STATUS status; |
| 4216 | int errno; |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4217 | bool bval; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4218 | struct hdd_context *hdd_ctx; |
| 4219 | struct sme_session_params sme_session_params = {0}; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4220 | struct wlan_objmgr_vdev *vdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4221 | |
| 4222 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4223 | |
| 4224 | /* do vdev create via objmgr */ |
| 4225 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 4226 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4227 | if (errno) { |
| 4228 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 4229 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4230 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4231 | |
| 4232 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4233 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 4234 | if (QDF_STATUS_SUCCESS != status) { |
| 4235 | hdd_err("failed to reinit session open event"); |
| 4236 | return -EINVAL; |
| 4237 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4238 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 4239 | callback, ctx); |
| 4240 | if (errno) { |
| 4241 | hdd_err("failed to populating SME params"); |
| 4242 | goto objmgr_vdev_destroy_procedure; |
| 4243 | } |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4244 | status = sme_open_session(hdd_ctx->mac_handle, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4245 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4246 | hdd_err("failed to open sme session: %d", status); |
| 4247 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4248 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4249 | } |
| 4250 | |
| 4251 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4252 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4253 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4254 | if (QDF_STATUS_SUCCESS != status) { |
| 4255 | if (adapter->qdf_session_open_event.force_set) { |
| 4256 | /* |
| 4257 | * SSR/PDR has caused shutdown, which has forcefully |
| 4258 | * set the event. Return without the closing session. |
| 4259 | */ |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 4260 | adapter->vdev_id = WLAN_UMAC_VDEV_ID_MAX; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4261 | hdd_err("Session open event forcefully set"); |
| 4262 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4263 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 4264 | |
| 4265 | if (QDF_STATUS_E_TIMEOUT == status) |
| 4266 | hdd_err("Session failed to open within timeout period"); |
| 4267 | else |
| 4268 | hdd_err("Failed to wait for session open event(status-%d)", |
| 4269 | status); |
| 4270 | errno = -ETIMEDOUT; |
| 4271 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4272 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4273 | } |
| 4274 | |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 4275 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 4276 | hdd_err("Session failed to open due to vdev create failure"); |
| 4277 | errno = -EINVAL; |
| 4278 | goto objmgr_vdev_destroy_procedure; |
| 4279 | } |
| 4280 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4281 | /* firmware ready for component communication, raise vdev_ready event */ |
| 4282 | errno = hdd_vdev_ready(adapter); |
| 4283 | if (errno) { |
| 4284 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4285 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4286 | } |
| 4287 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4288 | if (adapter->device_mode == QDF_STA_MODE) { |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4289 | bval = false; |
| 4290 | status = ucfg_mlme_get_rtt_mac_randomization(hdd_ctx->psoc, |
| 4291 | &bval); |
| 4292 | if (QDF_IS_STATUS_ERROR(status)) |
| 4293 | hdd_err("unable to get RTT MAC randomization value"); |
| 4294 | |
| 4295 | hdd_debug("setting RTT mac randomization param: %d", bval); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4296 | errno = sme_cli_set_command(adapter->vdev_id, |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4297 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4298 | bval, |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4299 | VDEV_CMD); |
| 4300 | if (0 != errno) |
| 4301 | hdd_err("RTT mac randomization param set failed %d", |
| 4302 | errno); |
| 4303 | } |
| 4304 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4305 | if (adapter->device_mode == QDF_STA_MODE || |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4306 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
| 4307 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4308 | if (!vdev) |
| 4309 | goto hdd_vdev_destroy_procedure; |
| 4310 | 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] | 4311 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4312 | } |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4313 | |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4314 | hdd_store_nss_chains_cfg_in_vdev(adapter); |
| 4315 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4316 | hdd_info("vdev %d created successfully", adapter->vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4317 | |
| 4318 | return 0; |
| 4319 | |
| 4320 | /* |
| 4321 | * Due to legacy constraints, we need to destroy in the same order as |
| 4322 | * create. So, split error handling into 2 cases to accommodate. |
| 4323 | */ |
| 4324 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4325 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4326 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4327 | |
| 4328 | return errno; |
| 4329 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4330 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4331 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 4332 | |
| 4333 | return errno; |
| 4334 | } |
| 4335 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4336 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4337 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4338 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4339 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4340 | QDF_STATUS status; |
| 4341 | int ret_val; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4342 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4343 | bool bval = false; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4344 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4345 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4346 | mac_handle = hdd_ctx->mac_handle; |
| 4347 | sme_set_curr_device_mode(mac_handle, adapter->device_mode); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4348 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4349 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4350 | hdd_err("unable to get vht_enable2x2"); |
| 4351 | sme_set_pdev_ht_vht_ies(mac_handle, bval); |
| 4352 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4353 | sme_set_vdev_ies_per_band(mac_handle, adapter->vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4354 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 4355 | hdd_roam_profile_init(adapter); |
| 4356 | hdd_register_wext(adapter->dev); |
| 4357 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4358 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4359 | |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 4360 | qdf_mem_set(sta_ctx->conn_info.sta_id, |
| 4361 | sizeof(sta_ctx->conn_info.sta_id), |
| 4362 | HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4363 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4364 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4365 | status = sme_config_fast_roaming(mac_handle, adapter->vdev_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4366 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4367 | /* Set the default operation channel */ |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 4368 | sta_ctx->conn_info.channel = |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 4369 | hdd_ctx->config->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4370 | |
| 4371 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 4372 | sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4373 | |
| 4374 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4375 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4376 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4377 | status, status); |
| 4378 | goto error_init_txrx; |
| 4379 | } |
| 4380 | |
| 4381 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4382 | |
| 4383 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4384 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4385 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4386 | status, status); |
| 4387 | goto error_wmm_init; |
| 4388 | } |
| 4389 | |
| 4390 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4391 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4392 | ret_val = sme_cli_set_command(adapter->vdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4393 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4394 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4395 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4396 | if (ret_val) |
| 4397 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4398 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4399 | /* |
| 4400 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4401 | * during that time, then as part of SSR init, do not enable |
| 4402 | * the LRO again. Keep the LRO state same as before SSR. |
| 4403 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 4404 | if (cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 4405 | cfg_dp_lro_enable) && |
| 4406 | !(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4407 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4408 | |
Rakshith Suresh Patkar | 9f5c586 | 2019-02-04 16:23:02 +0530 | [diff] [blame] | 4409 | if (cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 4410 | cfg_dp_enable_ip_tcp_udp_checksum_offload)) |
| 4411 | adapter->dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 4412 | adapter->dev->features |= NETIF_F_RXCSUM; |
| 4413 | |
| 4414 | hdd_set_tso_flags(hdd_ctx, adapter->dev); |
| 4415 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4416 | /* rcpi info initialization */ |
| 4417 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4418 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4419 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4420 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4421 | error_wmm_init: |
| 4422 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4423 | hdd_deinit_tx_rx(adapter); |
| 4424 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4425 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4426 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4427 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4428 | return status; |
| 4429 | } |
| 4430 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4431 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4432 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4433 | * @hdd_ctx: global hdd context |
| 4434 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4435 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4436 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4437 | * |
| 4438 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4439 | * |
| 4440 | * Return: None. |
| 4441 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4442 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4443 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4444 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4445 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4446 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4447 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4448 | if (adapter->dev) { |
| 4449 | if (rtnl_held) |
| 4450 | adapter->dev->wireless_handlers = NULL; |
| 4451 | else { |
| 4452 | rtnl_lock(); |
| 4453 | adapter->dev->wireless_handlers = NULL; |
| 4454 | rtnl_unlock(); |
| 4455 | } |
| 4456 | } |
| 4457 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4458 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4459 | hdd_deinit_tx_rx(adapter); |
| 4460 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4461 | } |
| 4462 | |
| 4463 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4464 | hdd_wmm_adapter_close(adapter); |
| 4465 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4466 | } |
| 4467 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4468 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4469 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4470 | } |
| 4471 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4472 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4473 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4474 | bool rtnl_held) |
| 4475 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4476 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4477 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4478 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4479 | case QDF_STA_MODE: |
| 4480 | case QDF_P2P_CLIENT_MODE: |
| 4481 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4482 | case QDF_IBSS_MODE: |
| 4483 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4484 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4485 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4486 | break; |
| 4487 | } |
| 4488 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4489 | case QDF_SAP_MODE: |
| 4490 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4491 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4492 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4493 | break; |
| 4494 | } |
| 4495 | |
| 4496 | default: |
| 4497 | break; |
| 4498 | } |
| 4499 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4500 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4501 | } |
| 4502 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4503 | static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx, |
| 4504 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4505 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4506 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4507 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4508 | |
| 4509 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4510 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4511 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4512 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4513 | return; |
| 4514 | } |
| 4515 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4516 | hdd_nud_deinit_tracking(adapter); |
| 4517 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4518 | hdd_apf_context_destroy(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4519 | qdf_spinlock_destroy(&adapter->vdev_lock); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4520 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4521 | wlan_hdd_debugfs_csr_deinit(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 4522 | if (adapter->device_mode == QDF_STA_MODE) |
| 4523 | hdd_sysfs_destroy_adapter_root_obj(adapter); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4524 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4525 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4526 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4527 | /* |
| 4528 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4529 | * the driver is almost closed and cannot handle either control |
| 4530 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4531 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4532 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4533 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4534 | * the interface is closed and restricts any operations on that |
| 4535 | */ |
| 4536 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4537 | |
| 4538 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4539 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4540 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4541 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4542 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4543 | /* |
| 4544 | * Note that the adapter is no longer valid at this point |
| 4545 | * since the memory has been reclaimed |
| 4546 | */ |
| 4547 | } |
| 4548 | } |
| 4549 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4550 | 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] | 4551 | tSirMacAddr mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4552 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4553 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4554 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4555 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4556 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 4557 | mac_addr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4558 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4559 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4560 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4561 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4562 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4563 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4564 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4565 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4566 | /** |
| 4567 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4568 | * @hdd_ctx: HDD Context |
| 4569 | * @adapter: HDD Adapter |
| 4570 | * |
| 4571 | * This function set the FW Debug log level based on the INI. |
| 4572 | * |
| 4573 | * Return: None |
| 4574 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4575 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4576 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4577 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4578 | QDF_STATUS status; |
| 4579 | uint16_t enable_fw_log_level, enable_fw_log_type; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4580 | int ret; |
| 4581 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4582 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4583 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4584 | 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] | 4585 | return; |
| 4586 | } |
| 4587 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4588 | /* Enable FW logs based on INI configuration */ |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4589 | status = ucfg_fwol_get_enable_fw_log_type(hdd_ctx->psoc, |
| 4590 | &enable_fw_log_type); |
| 4591 | if (QDF_IS_STATUS_ERROR(status)) |
| 4592 | return; |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4593 | ret = sme_cli_set_command(adapter->vdev_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4594 | WMI_DBGLOG_TYPE, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4595 | enable_fw_log_type, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4596 | DBG_CMD); |
| 4597 | if (ret != 0) |
| 4598 | hdd_err("Failed to enable FW log type ret %d", |
| 4599 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4600 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4601 | status = ucfg_fwol_get_enable_fw_log_level(hdd_ctx->psoc, |
| 4602 | &enable_fw_log_level); |
| 4603 | if (QDF_IS_STATUS_ERROR(status)) |
| 4604 | return; |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4605 | ret = sme_cli_set_command(adapter->vdev_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4606 | WMI_DBGLOG_LOG_LEVEL, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4607 | enable_fw_log_level, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4608 | DBG_CMD); |
| 4609 | if (ret != 0) |
| 4610 | hdd_err("Failed to enable FW log level ret %d", |
| 4611 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4612 | |
lifeng | faa83cb | 2018-11-24 01:53:56 +0800 | [diff] [blame] | 4613 | sme_enable_fw_module_log_level(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4614 | adapter->vdev_id); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4615 | } |
| 4616 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4617 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4618 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4619 | { |
| 4620 | } |
| 4621 | |
| 4622 | #endif |
| 4623 | |
| 4624 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4625 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4626 | * @adapter: HDD adapter |
| 4627 | * |
| 4628 | * Return: 0 on success or errno on failure |
| 4629 | */ |
| 4630 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4631 | { |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4632 | QDF_STATUS status; |
| 4633 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4634 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4635 | bool enable2x2 = false, enable_bt_chain_sep = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4636 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
| 4637 | |
| 4638 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 4639 | &dual_mac_feature); |
| 4640 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4641 | hdd_err("unable to get dual mac feature"); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4642 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4643 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &enable2x2); |
| 4644 | if (QDF_IS_STATUS_ERROR(status)) |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4645 | hdd_err("unable to get vht_enable2x2"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4646 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4647 | status = ucfg_mlme_get_bt_chain_separation_flag(hdd_ctx->psoc, |
| 4648 | &enable_bt_chain_sep); |
| 4649 | if (QDF_IS_STATUS_ERROR(status)) |
| 4650 | hdd_debug("unable to get BT chain separation. using default"); |
| 4651 | |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4652 | hdd_debug("enable2x2: %d, lte_coex: %d, disable_DBS: %d", |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4653 | enable2x2, hdd_ctx->lte_coex_ant_share, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4654 | dual_mac_feature); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4655 | hdd_debug("enable_bt_chain_separation %d", enable_bt_chain_sep); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4656 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4657 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4658 | HW_MODE_DBS_NONE, |
| 4659 | CDS_BAND_ALL); |
| 4660 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4661 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4662 | return qdf_status_to_os_return(status); |
| 4663 | } |
| 4664 | |
| 4665 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4666 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4667 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4668 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4669 | hdd_debug("firmware not capable. skip chain mask programming"); |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4670 | return 0; |
| 4671 | } |
| 4672 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4673 | if (enable2x2 && !enable_bt_chain_sep) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4674 | hdd_debug("2x2 enabled. skip chain mask programming"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4675 | return 0; |
| 4676 | } |
| 4677 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4678 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4679 | hdd_debug("DBS enabled(%d). skip chain mask programming", |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4680 | dual_mac_feature); |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4681 | return 0; |
| 4682 | } |
| 4683 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4684 | if (hdd_ctx->lte_coex_ant_share) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4685 | hdd_debug("lte ant sharing enabled. skip chainmask programming"); |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4686 | return 0; |
| 4687 | } |
| 4688 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4689 | status = ucfg_mlme_configure_chain_mask(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4690 | adapter->vdev_id); |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4691 | if (status != QDF_STATUS_SUCCESS) |
| 4692 | goto error; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4693 | |
| 4694 | return 0; |
| 4695 | |
| 4696 | error: |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4697 | hdd_err("WMI PDEV set param failed"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4698 | return -EINVAL; |
| 4699 | } |
| 4700 | |
| 4701 | /** |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4702 | * hdd_send_coex_config_params() - Send coex config params to FW |
| 4703 | * @hdd_ctx: HDD context |
| 4704 | * @adapter: Primary adapter context |
| 4705 | * |
| 4706 | * This function is used to send all coex config related params to FW |
| 4707 | * |
| 4708 | * Return: 0 on success and -EINVAL on failure |
| 4709 | */ |
| 4710 | static int hdd_send_coex_config_params(struct hdd_context *hdd_ctx, |
| 4711 | struct hdd_adapter *adapter) |
| 4712 | { |
| 4713 | struct coex_config_params coex_cfg_params = {0}; |
| 4714 | struct wlan_fwol_coex_config config = {0}; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 4715 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4716 | QDF_STATUS status; |
| 4717 | |
| 4718 | if (!hdd_ctx) { |
| 4719 | hdd_err("hdd_ctx is invalid"); |
| 4720 | goto err; |
| 4721 | } |
| 4722 | |
| 4723 | if (!adapter) { |
| 4724 | hdd_err("adapter is invalid"); |
| 4725 | goto err; |
| 4726 | } |
| 4727 | |
| 4728 | if (!psoc) { |
| 4729 | hdd_err("HDD psoc is invalid"); |
| 4730 | goto err; |
| 4731 | } |
| 4732 | |
| 4733 | status = ucfg_fwol_get_coex_config_params(psoc, &config); |
| 4734 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4735 | hdd_err("Unable to get coex config params"); |
| 4736 | goto err; |
| 4737 | } |
| 4738 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4739 | coex_cfg_params.vdev_id = adapter->vdev_id; |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4740 | coex_cfg_params.config_type = WMI_COEX_CONFIG_TX_POWER; |
| 4741 | coex_cfg_params.config_arg1 = config.max_tx_power_for_btc; |
| 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 Tx power"); |
| 4746 | goto err; |
| 4747 | } |
| 4748 | |
| 4749 | coex_cfg_params.config_type = WMI_COEX_CONFIG_HANDOVER_RSSI; |
| 4750 | coex_cfg_params.config_arg1 = config.wlan_low_rssi_threshold; |
| 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 handover RSSI"); |
| 4755 | goto err; |
| 4756 | } |
| 4757 | |
| 4758 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BTC_MODE; |
| 4759 | coex_cfg_params.config_arg1 = config.btc_mode; |
| 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 BTC mode"); |
| 4764 | goto err; |
| 4765 | } |
| 4766 | |
| 4767 | coex_cfg_params.config_type = WMI_COEX_CONFIG_ANTENNA_ISOLATION; |
| 4768 | coex_cfg_params.config_arg1 = config.antenna_isolation; |
| 4769 | |
| 4770 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4771 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4772 | hdd_err("Failed to send coex antenna isolation"); |
| 4773 | goto err; |
| 4774 | } |
| 4775 | |
| 4776 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_LOW_RSSI_THRESHOLD; |
| 4777 | coex_cfg_params.config_arg1 = config.bt_low_rssi_threshold; |
| 4778 | |
| 4779 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4780 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4781 | hdd_err("Failed to send coex BT low RSSI threshold"); |
| 4782 | goto err; |
| 4783 | } |
| 4784 | |
| 4785 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_INTERFERENCE_LEVEL; |
| 4786 | coex_cfg_params.config_arg1 = config.bt_interference_low_ll; |
| 4787 | coex_cfg_params.config_arg2 = config.bt_interference_low_ul; |
| 4788 | coex_cfg_params.config_arg3 = config.bt_interference_medium_ll; |
| 4789 | coex_cfg_params.config_arg4 = config.bt_interference_medium_ul; |
| 4790 | coex_cfg_params.config_arg5 = config.bt_interference_high_ll; |
| 4791 | coex_cfg_params.config_arg6 = config.bt_interference_high_ul; |
| 4792 | |
| 4793 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4794 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4795 | hdd_err("Failed to send coex BT interference level"); |
| 4796 | goto err; |
| 4797 | } |
stonez | c9936cb | 2019-03-11 16:41:22 +0800 | [diff] [blame] | 4798 | |
| 4799 | if (wlan_hdd_mpta_helper_enable(&coex_cfg_params, &config)) |
| 4800 | goto err; |
| 4801 | |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4802 | return 0; |
| 4803 | err: |
| 4804 | return -EINVAL; |
| 4805 | } |
| 4806 | |
| 4807 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4808 | * hdd_set_fw_params() - Set parameters to firmware |
| 4809 | * @adapter: HDD adapter |
| 4810 | * |
| 4811 | * This function Sets various parameters to fw once the |
| 4812 | * adapter is started. |
| 4813 | * |
| 4814 | * Return: 0 on success or errno on failure |
| 4815 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4816 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4817 | { |
| 4818 | int ret; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4819 | uint16_t upper_brssi_thresh, lower_brssi_thresh, rts_profile; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4820 | bool enable_dtim_1chrx; |
| 4821 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4822 | struct hdd_context *hdd_ctx; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4823 | bool bval = false; |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4824 | uint8_t max_amsdu_len, enable_tx_sch_delay; |
| 4825 | uint32_t dtim_sel_diversity, enable_secondary_rate; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4826 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4827 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4828 | |
| 4829 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4830 | if (!hdd_ctx) |
| 4831 | return -EINVAL; |
| 4832 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4833 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4834 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4835 | return 0; |
| 4836 | } |
| 4837 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4838 | ret = -1; |
| 4839 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_lprx_enable(hdd_ctx->psoc, |
| 4840 | &bval))) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4841 | ret = sme_cli_set_command(adapter->vdev_id, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4842 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4843 | bval, PDEV_CMD); |
| 4844 | } |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4845 | if (ret) { |
| 4846 | hdd_err("Failed to set LPRx"); |
| 4847 | goto error; |
| 4848 | } |
| 4849 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 4850 | ucfg_mlme_get_dtim_selection_diversity(hdd_ctx->psoc, |
| 4851 | &dtim_sel_diversity); |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4852 | |
| 4853 | ret = sme_cli_set_command( |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4854 | adapter->vdev_id, |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4855 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 4856 | dtim_sel_diversity, PDEV_CMD); |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4857 | if (ret) { |
| 4858 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4859 | goto error; |
| 4860 | } |
| 4861 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4862 | ret = -1; |
| 4863 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_enable_tx_sch_delay( |
| 4864 | hdd_ctx->psoc, &enable_tx_sch_delay))) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4865 | ret = sme_cli_set_command(adapter->vdev_id, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4866 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4867 | enable_tx_sch_delay, PDEV_CMD); |
| 4868 | } |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4869 | if (ret) { |
| 4870 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4871 | goto error; |
| 4872 | } |
| 4873 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4874 | ret = -1; |
| 4875 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_enable_secondary_rate( |
| 4876 | hdd_ctx->psoc, &enable_secondary_rate))) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4877 | ret = sme_cli_set_command(adapter->vdev_id, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4878 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4879 | enable_secondary_rate, PDEV_CMD); |
| 4880 | } |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4881 | if (ret) { |
| 4882 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4883 | goto error; |
| 4884 | } |
| 4885 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4886 | if (adapter->device_mode == QDF_STA_MODE) { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4887 | status = ucfg_get_upper_brssi_thresh(hdd_ctx->psoc, |
| 4888 | &upper_brssi_thresh); |
| 4889 | if (QDF_IS_STATUS_ERROR(status)) |
| 4890 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 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_UPPER_BRSSI_THRESH, |
| 4894 | upper_brssi_thresh); |
| 4895 | |
| 4896 | status = ucfg_get_lower_brssi_thresh(hdd_ctx->psoc, |
| 4897 | &lower_brssi_thresh); |
| 4898 | if (QDF_IS_STATUS_ERROR(status)) |
| 4899 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4900 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4901 | sme_set_smps_cfg(adapter->vdev_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4902 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4903 | lower_brssi_thresh); |
| 4904 | |
| 4905 | status = ucfg_get_enable_dtim_1chrx(hdd_ctx->psoc, |
| 4906 | &enable_dtim_1chrx); |
| 4907 | if (QDF_IS_STATUS_ERROR(status)) |
| 4908 | return -EINVAL; |
| 4909 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4910 | sme_set_smps_cfg(adapter->vdev_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4911 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4912 | enable_dtim_1chrx); |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4913 | } |
| 4914 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4915 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4916 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4917 | hdd_err("unable to get vht_enable2x2"); |
| 4918 | |
| 4919 | if (bval) { |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4920 | hdd_debug("configuring 2x2 mode fw params"); |
| 4921 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4922 | ret = sme_set_cck_tx_fir_override(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4923 | adapter->vdev_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4924 | if (ret) { |
| 4925 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4926 | ret); |
| 4927 | goto error; |
| 4928 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4929 | |
| 4930 | if (hdd_configure_chain_mask(adapter)) |
| 4931 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4932 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4933 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4934 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4935 | hdd_debug("configuring 1x1 mode fw params"); |
| 4936 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4937 | /* |
| 4938 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4939 | * we are passing two value |
| 4940 | * as param_id << 29 | param_value. |
| 4941 | * Below param_value = 0(disable) |
| 4942 | */ |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4943 | ret = sme_cli_set_command(adapter->vdev_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4944 | WMI_STA_SMPS_PARAM_CMDID, |
| 4945 | HDD_DTIM_1CHAIN_RX_ID << |
| 4946 | HDD_SMPS_PARAM_VALUE_S, |
| 4947 | VDEV_CMD); |
| 4948 | if (ret) { |
| 4949 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4950 | goto error; |
| 4951 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4952 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4953 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4954 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4955 | |
| 4956 | if (hdd_configure_chain_mask(adapter)) |
| 4957 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4958 | } |
| 4959 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4960 | ret = sme_set_enable_mem_deep_sleep(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4961 | adapter->vdev_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4962 | if (ret) { |
| 4963 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4964 | goto error; |
| 4965 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4966 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4967 | status = ucfg_fwol_get_rts_profile(hdd_ctx->psoc, &rts_profile); |
| 4968 | if (QDF_IS_STATUS_ERROR(status)) |
| 4969 | return -EINVAL; |
| 4970 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4971 | ret = sme_cli_set_command(adapter->vdev_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4972 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4973 | rts_profile, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4974 | VDEV_CMD); |
| 4975 | if (ret) { |
| 4976 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4977 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4978 | } |
| 4979 | |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4980 | status = ucfg_mlme_get_max_amsdu_num(hdd_ctx->psoc, &max_amsdu_len); |
| 4981 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4982 | hdd_err("Failed to get Max AMSDU Num"); |
| 4983 | goto error; |
| 4984 | } |
| 4985 | |
| 4986 | hdd_debug("SET AMSDU num %d", max_amsdu_len); |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4987 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4988 | ret = wma_cli_set_command(adapter->vdev_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4989 | GEN_VDEV_PARAM_AMSDU, |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4990 | max_amsdu_len, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4991 | GEN_CMD); |
| 4992 | if (ret != 0) { |
| 4993 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4994 | goto error; |
| 4995 | } |
| 4996 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4997 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4998 | |
| 4999 | ret = hdd_send_coex_config_params(hdd_ctx, adapter); |
| 5000 | if (ret) { |
| 5001 | hdd_warn("Error initializing coex config params"); |
| 5002 | goto error; |
| 5003 | } |
| 5004 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5005 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 5006 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 5007 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5008 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 5009 | error: |
| 5010 | return -EINVAL; |
| 5011 | } |
| 5012 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5013 | /** |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5014 | * hdd_init_completion() - Initialize Completion Variables |
| 5015 | * @adapter: HDD adapter |
| 5016 | * |
| 5017 | * This function Initialize the completion variables for |
| 5018 | * a particular adapter |
| 5019 | * |
| 5020 | * Return: None |
| 5021 | */ |
| 5022 | static void hdd_init_completion(struct hdd_adapter *adapter) |
| 5023 | { |
| 5024 | init_completion(&adapter->disconnect_comp_var); |
| 5025 | init_completion(&adapter->roaming_comp_var); |
| 5026 | init_completion(&adapter->linkup_event_var); |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5027 | init_completion(&adapter->sta_authorized_event); |
| 5028 | init_completion(&adapter->offchannel_tx_event); |
| 5029 | init_completion(&adapter->tx_action_cnf_event); |
| 5030 | init_completion(&adapter->ibss_peer_info_comp); |
| 5031 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
| 5032 | } |
| 5033 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5034 | static void hdd_reset_locally_admin_bit(struct hdd_context *hdd_ctx, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5035 | tSirMacAddr mac_addr) |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5036 | { |
| 5037 | int i; |
| 5038 | /* |
| 5039 | * Reset locally administered bit for dynamic_mac_list |
| 5040 | * also as while releasing the MAC address for any |
| 5041 | * interface mac will be compared with dynamic mac list |
| 5042 | */ |
| 5043 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
| 5044 | if (!qdf_mem_cmp( |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5045 | mac_addr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5046 | &hdd_ctx-> |
| 5047 | dynamic_mac_list[i].dynamic_mac.bytes[0], |
| 5048 | sizeof(struct qdf_mac_addr))) { |
| 5049 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT( |
| 5050 | hdd_ctx-> |
| 5051 | dynamic_mac_list[i].dynamic_mac.bytes); |
| 5052 | break; |
| 5053 | } |
| 5054 | } |
| 5055 | /* |
| 5056 | * Reset locally administered bit if the device mode is |
| 5057 | * STA |
| 5058 | */ |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5059 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(mac_addr); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5060 | hdd_debug("locally administered bit reset in sta mode: " |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 5061 | QDF_MAC_ADDR_STR, QDF_MAC_ADDR_ARRAY(mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5062 | } |
| 5063 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 5064 | static void wlan_hdd_cfg80211_scan_block_cb(struct work_struct *work) |
| 5065 | { |
| 5066 | struct hdd_adapter *adapter = |
| 5067 | container_of(work, struct hdd_adapter, scan_block_work); |
| 5068 | struct osif_vdev_sync *vdev_sync; |
| 5069 | |
| 5070 | if (osif_vdev_sync_op_start(adapter->dev, &vdev_sync)) |
| 5071 | return; |
| 5072 | |
| 5073 | wlan_hdd_cfg80211_scan_block(adapter); |
| 5074 | |
| 5075 | osif_vdev_sync_op_stop(vdev_sync); |
| 5076 | } |
| 5077 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5078 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5079 | * hdd_open_adapter() - open and setup the hdd adatper |
| 5080 | * @hdd_ctx: global hdd context |
| 5081 | * @session_type: type of the interface to be created |
| 5082 | * @iface_name: User-visible name of the interface |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5083 | * @mac_addr: MAC address to assign to the interface |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5084 | * @name_assign_type: the name of assign type of the netdev |
| 5085 | * @rtnl_held: the rtnl lock hold flag |
| 5086 | * |
| 5087 | * This function open and setup the hdd adpater according to the device |
| 5088 | * type request, assign the name, the mac address assigned, and then prepared |
| 5089 | * the hdd related parameters, queue, lock and ready to start. |
| 5090 | * |
| 5091 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 5092 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5093 | 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] | 5094 | const char *iface_name, tSirMacAddr mac_addr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5095 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5096 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5097 | { |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5098 | struct net_device *ndev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5099 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5100 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5101 | |
| 5102 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 5103 | /* |
| 5104 | * Max limit reached on the number of vdevs configured by the |
| 5105 | * host. Return error |
| 5106 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5107 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 5108 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5109 | return NULL; |
| 5110 | } |
| 5111 | |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5112 | status = wlan_hdd_validate_mac_address((struct qdf_mac_addr *)mac_addr); |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5113 | if (QDF_IS_STATUS_ERROR(status)) { |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5114 | /* Not received valid mac_addr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5115 | 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] | 5116 | return NULL; |
| 5117 | } |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5118 | |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5119 | status = hdd_check_for_existing_macaddr(hdd_ctx, mac_addr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5120 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 5121 | hdd_err("Duplicate MAC addr: " QDF_MAC_ADDR_STR |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5122 | " already exists", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 5123 | QDF_MAC_ADDR_ARRAY(mac_addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5124 | return NULL; |
| 5125 | } |
| 5126 | |
| 5127 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5128 | case QDF_STA_MODE: |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5129 | if (!hdd_ctx->config->mac_provision) { |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5130 | hdd_reset_locally_admin_bit(hdd_ctx, mac_addr); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5131 | /* |
| 5132 | * After resetting locally administered bit |
| 5133 | * again check if the new mac address is already |
| 5134 | * exists. |
| 5135 | */ |
| 5136 | status = hdd_check_for_existing_macaddr(hdd_ctx, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5137 | mac_addr); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5138 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 5139 | hdd_err("Duplicate MAC addr: " QDF_MAC_ADDR_STR |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5140 | " already exists", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 5141 | QDF_MAC_ADDR_ARRAY(mac_addr)); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5142 | return NULL; |
| 5143 | } |
| 5144 | } |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 5145 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5146 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5147 | case QDF_P2P_CLIENT_MODE: |
| 5148 | case QDF_P2P_DEVICE_MODE: |
| 5149 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 5150 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5151 | case QDF_MONITOR_MODE: |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5152 | adapter = hdd_alloc_station_adapter(hdd_ctx, mac_addr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5153 | name_assign_type, |
| 5154 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5155 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5156 | if (!adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5157 | hdd_err("failed to allocate adapter for session %d", |
| 5158 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5159 | return NULL; |
| 5160 | } |
| 5161 | |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5162 | ndev = adapter->dev; |
| 5163 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5164 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5165 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5166 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5167 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5168 | else if (QDF_MONITOR_MODE == session_type) |
| 5169 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5170 | else |
| 5171 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5172 | |
| 5173 | adapter->device_mode = session_type; |
| 5174 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5175 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5176 | /* |
| 5177 | * Workqueue which gets scheduled in IPv4 notification |
| 5178 | * callback |
| 5179 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5180 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5181 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5182 | |
| 5183 | #ifdef WLAN_NS_OFFLOAD |
| 5184 | /* |
| 5185 | * Workqueue which gets scheduled in IPv6 |
| 5186 | * notification callback. |
| 5187 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5188 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5189 | hdd_ipv6_notifier_work_queue); |
| 5190 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5191 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5192 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5193 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5194 | |
| 5195 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5196 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5197 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5198 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5199 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5200 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5201 | hdd_nud_init_tracking(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 5202 | if (adapter->device_mode == QDF_STA_MODE || |
| 5203 | adapter->device_mode == QDF_P2P_DEVICE_MODE) |
| 5204 | hdd_sysfs_create_adapter_root_obj(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5205 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 5206 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 5207 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5208 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5209 | case QDF_P2P_GO_MODE: |
| 5210 | case QDF_SAP_MODE: |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5211 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, mac_addr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5212 | name_assign_type, |
| 5213 | (uint8_t *) iface_name); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5214 | if (!adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5215 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5216 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5217 | return NULL; |
| 5218 | } |
| 5219 | |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5220 | ndev = adapter->dev; |
| 5221 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5222 | adapter->wdev.iftype = |
| 5223 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5224 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5225 | NL80211_IFTYPE_P2P_GO; |
| 5226 | adapter->device_mode = session_type; |
| 5227 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 5228 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5229 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5230 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5231 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5232 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5233 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5234 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5235 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5236 | |
| 5237 | /* |
| 5238 | * Workqueue which gets scheduled in IPv4 notification |
| 5239 | * callback |
| 5240 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5241 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5242 | hdd_ipv4_notifier_work_queue); |
| 5243 | |
| 5244 | #ifdef WLAN_NS_OFFLOAD |
| 5245 | /* |
| 5246 | * Workqueue which gets scheduled in IPv6 |
| 5247 | * notification callback. |
| 5248 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5249 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5250 | hdd_ipv6_notifier_work_queue); |
| 5251 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5252 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5253 | case QDF_FTM_MODE: |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5254 | adapter = hdd_alloc_station_adapter(hdd_ctx, mac_addr, |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5255 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 5256 | iface_name); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5257 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5258 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 5259 | return NULL; |
| 5260 | } |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5261 | |
| 5262 | ndev = adapter->dev; |
| 5263 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5264 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5265 | adapter->device_mode = session_type; |
| 5266 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5267 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5268 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5269 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5270 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5271 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5272 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5273 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5274 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5275 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5276 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5277 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5278 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5279 | return NULL; |
| 5280 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5281 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5282 | qdf_spinlock_create(&adapter->vdev_lock); |
| 5283 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5284 | hdd_init_completion(adapter); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5285 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 5286 | qdf_list_create(&adapter->blocked_scan_request_q, WLAN_MAX_SCAN_COUNT); |
| 5287 | qdf_mutex_create(&adapter->blocked_scan_request_q_lock); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5288 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5289 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5290 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5291 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5292 | } |
| 5293 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5294 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5295 | if (adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5296 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5297 | adapter = NULL; |
| 5298 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5299 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5300 | return NULL; |
| 5301 | } |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 5302 | hdd_apf_context_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5303 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5304 | if (QDF_STATUS_SUCCESS == status) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5305 | policy_mgr_set_concurrency_mode(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5306 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5307 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5308 | /* Adapter successfully added. Increment the vdev count */ |
| 5309 | hdd_ctx->current_intf_count++; |
| 5310 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5311 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5312 | hdd_ctx->current_intf_count); |
| 5313 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 5314 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5315 | } |
| 5316 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 5317 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 5318 | hdd_err("Interface %s wow debug_fs init failed", |
| 5319 | netdev_name(adapter->dev)); |
| 5320 | |
| 5321 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 5322 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5323 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 5324 | if (adapter->device_mode == QDF_STA_MODE) |
| 5325 | wlan_hdd_debugfs_csr_init(adapter); |
| 5326 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5327 | return adapter; |
| 5328 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5329 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5330 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5331 | |
| 5332 | if (ndev) |
| 5333 | free_netdev(ndev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5334 | |
| 5335 | return NULL; |
| 5336 | } |
| 5337 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5338 | static void __hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5339 | struct hdd_adapter *adapter, |
| 5340 | bool rtnl_held) |
| 5341 | { |
| 5342 | qdf_list_destroy(&adapter->blocked_scan_request_q); |
| 5343 | qdf_mutex_destroy(&adapter->blocked_scan_request_q_lock); |
| 5344 | policy_mgr_clear_concurrency_mode(hdd_ctx->psoc, adapter->device_mode); |
| 5345 | |
| 5346 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5347 | |
| 5348 | if (hdd_ctx->current_intf_count != 0) |
| 5349 | hdd_ctx->current_intf_count--; |
| 5350 | } |
| 5351 | |
| 5352 | void hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5353 | struct hdd_adapter *adapter, |
| 5354 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5355 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5356 | /* |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5357 | * Stop the global bus bandwidth timer while touching the adapter list |
| 5358 | * to avoid bad memory access by the timer handler. |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5359 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5360 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5361 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5362 | hdd_remove_adapter(hdd_ctx, adapter); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5363 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5364 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5365 | /* conditionally restart the bw timer */ |
| 5366 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5367 | } |
| 5368 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5369 | 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] | 5370 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5371 | struct hdd_adapter *adapter; |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5372 | struct osif_vdev_sync *vdev_sync; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5373 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5374 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5375 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5376 | while (QDF_IS_STATUS_SUCCESS(hdd_remove_front_adapter(hdd_ctx, |
| 5377 | &adapter))) { |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5378 | vdev_sync = osif_vdev_sync_unregister(adapter->dev); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5379 | if (vdev_sync) |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5380 | osif_vdev_sync_wait_for_ops(vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5381 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5382 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
| 5383 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5384 | |
| 5385 | if (vdev_sync) |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5386 | osif_vdev_sync_destroy(vdev_sync); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5387 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5388 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5389 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5390 | } |
| 5391 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5392 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5393 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5394 | struct qdf_mac_addr *bssid = NULL; |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5395 | tSirUpdateIE update_ie; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5396 | mac_handle_t mac_handle; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5397 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5398 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5399 | case QDF_STA_MODE: |
| 5400 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5401 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5402 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5403 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 5404 | bssid = &sta_ctx->conn_info.bssid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5405 | break; |
| 5406 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5407 | case QDF_SAP_MODE: |
| 5408 | case QDF_P2P_GO_MODE: |
| 5409 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5410 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5411 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5412 | break; |
| 5413 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5414 | case QDF_FTM_MODE: |
| 5415 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5416 | default: |
| 5417 | /* |
| 5418 | * wlan_hdd_reset_prob_rspies should not have been called |
| 5419 | * for these kind of devices |
| 5420 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5421 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5422 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5423 | return; |
| 5424 | } |
| 5425 | |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5426 | qdf_copy_macaddr(&update_ie.bssid, bssid); |
| 5427 | update_ie.smeSessionId = adapter->vdev_id; |
| 5428 | update_ie.ieBufferlength = 0; |
| 5429 | update_ie.pAdditionIEBuffer = NULL; |
| 5430 | update_ie.append = true; |
| 5431 | update_ie.notify = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5432 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 5433 | if (sme_update_add_ie(mac_handle, |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5434 | &update_ie, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5435 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5436 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5437 | } |
| 5438 | } |
| 5439 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5440 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 5441 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5442 | { |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5443 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 5444 | struct hdd_station_ctx *sta_ctx; |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5445 | struct sap_context *sap_ctx; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5446 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5447 | union iwreq_data wrqu; |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5448 | tSirUpdateIE update_ie; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5449 | unsigned long rc; |
Jeff Johnson | 8f8ceb9 | 2019-03-24 08:16:55 -0700 | [diff] [blame] | 5450 | struct sap_config *sap_config; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5451 | mac_handle_t mac_handle; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5452 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5453 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5454 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5455 | |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 5456 | if (adapter->vdev_id != WLAN_UMAC_VDEV_ID_MAX) |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 5457 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5458 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5459 | hdd_nud_ignore_tracking(adapter, true); |
| 5460 | hdd_nud_reset_tracking(adapter); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5461 | hdd_nud_flush_work(adapter); |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5462 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5463 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5464 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5465 | wlan_hdd_netif_queue_control(adapter, |
| 5466 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5467 | WLAN_CONTROL_PATH); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5468 | |
| 5469 | mac_handle = hdd_ctx->mac_handle; |
| 5470 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5471 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5472 | case QDF_STA_MODE: |
| 5473 | case QDF_P2P_CLIENT_MODE: |
| 5474 | case QDF_IBSS_MODE: |
| 5475 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5476 | case QDF_NDI_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5477 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5478 | |
| 5479 | if (adapter->device_mode == QDF_NDI_MODE || |
| 5480 | hdd_conn_is_connected(sta_ctx) || |
| 5481 | hdd_is_connecting(sta_ctx)) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5482 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5483 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5484 | roam_profile = hdd_roam_profile(adapter); |
| 5485 | /* For NDI do not use roam_profile */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5486 | if (adapter->device_mode == QDF_NDI_MODE) |
| 5487 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5488 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5489 | adapter->vdev_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5490 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5491 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5492 | eCSR_BSS_TYPE_START_IBSS) |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5493 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5494 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5495 | adapter->vdev_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5496 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Abhinav Kumar | 19a7a40 | 2018-07-12 17:36:57 +0530 | [diff] [blame] | 5497 | else if (adapter->device_mode == QDF_STA_MODE) |
| 5498 | wlan_hdd_disconnect(adapter, |
| 5499 | eCSR_DISCONNECT_REASON_DEAUTH); |
| 5500 | else |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5501 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5502 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5503 | adapter->vdev_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5504 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5505 | /* success implies disconnect is queued */ |
| 5506 | if (QDF_IS_STATUS_SUCCESS(status) && |
| 5507 | adapter->device_mode != QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5508 | rc = wait_for_completion_timeout( |
| 5509 | &adapter->disconnect_comp_var, |
| 5510 | msecs_to_jiffies |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 5511 | (SME_DISCONNECT_TIMEOUT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5512 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5513 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5514 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5515 | if (QDF_IS_STATUS_ERROR(status)) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5516 | hdd_warn("failed to post disconnect"); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5517 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5518 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5519 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5520 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5521 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5522 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5523 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5524 | |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5525 | wlan_hdd_scan_abort(adapter); |
Wu Gao | 4a1ec8c | 2018-07-23 19:18:40 +0800 | [diff] [blame] | 5526 | wlan_hdd_cleanup_actionframe(adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5527 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5528 | hdd_clear_fils_connection_info(adapter); |
Ashish Kumar Dhanotiya | 3651083 | 2019-02-20 22:13:25 +0530 | [diff] [blame] | 5529 | |
Liangwei Dong | a44d55b | 2019-03-20 03:22:08 -0400 | [diff] [blame] | 5530 | status = wlan_hdd_flush_pmksa_cache(adapter); |
Ashish Kumar Dhanotiya | 3651083 | 2019-02-20 22:13:25 +0530 | [diff] [blame] | 5531 | if (QDF_IS_STATUS_ERROR(status)) |
| 5532 | hdd_err("Cannot flush PMKIDCache"); |
| 5533 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5534 | hdd_deregister_hl_netdev_fc_timer(adapter); |
| 5535 | |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5536 | hdd_deregister_tx_flow_control(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5537 | |
| 5538 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5539 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5540 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5541 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5542 | #endif |
| 5543 | #endif |
| 5544 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5545 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5546 | struct wlan_objmgr_vdev *vdev; |
| 5547 | |
| 5548 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5549 | if (vdev) { |
| 5550 | wlan_cfg80211_sched_scan_stop(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5551 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5552 | } |
| 5553 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5554 | |
Pragaspathi Thilagaraj | e6f37e0 | 2019-01-04 12:24:33 +0530 | [diff] [blame] | 5555 | /* |
| 5556 | * During vdev destroy, if any STA is in connecting state the |
| 5557 | * roam command will be in active queue and thus vdev destroy is |
| 5558 | * queued in pending queue. In case STA tries to connect to |
| 5559 | * multiple BSSID and fails to connect, due to auth/assoc |
| 5560 | * timeouts it may take more than vdev destroy time to get |
| 5561 | * completed. On vdev destroy timeout vdev is moved to logically |
| 5562 | * deleted state. Once connection is completed, vdev destroy is |
| 5563 | * activated and to release the self-peer ref count it try to |
| 5564 | * get the ref of the vdev, which fails as vdev is logically |
| 5565 | * deleted and this leads to peer ref leak. So before vdev |
| 5566 | * destroy is queued abort any STA ongoing connection to avoid |
| 5567 | * vdev destroy timeout. |
| 5568 | */ |
| 5569 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5570 | hdd_abort_ongoing_sta_connection(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5571 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5572 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5573 | break; |
| 5574 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5575 | case QDF_MONITOR_MODE: |
| 5576 | wlan_hdd_scan_abort(adapter); |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5577 | hdd_deregister_hl_netdev_fc_timer(adapter); |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5578 | hdd_deregister_tx_flow_control(adapter); |
| 5579 | hdd_vdev_destroy(adapter); |
| 5580 | break; |
| 5581 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5582 | case QDF_SAP_MODE: |
Will Huang | 7049bae | 2018-08-13 17:25:02 +0800 | [diff] [blame] | 5583 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5584 | cds_flush_delayed_work(&adapter->acs_pending_work); |
| 5585 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5586 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5587 | |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5588 | wlan_hdd_scan_abort(adapter); |
gaurank kathpalia | b7a9f70 | 2019-02-15 18:09:58 +0530 | [diff] [blame] | 5589 | /* Diassociate with all the peers before stop ap post */ |
| 5590 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) |
| 5591 | wlan_hdd_del_station(adapter); |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5592 | sap_config = &adapter->session.ap.sap_config; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5593 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 5594 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 5595 | ucfg_ipa_flush(hdd_ctx->pdev); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5596 | |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5597 | /* don't flush pre-cac destroy if we are destroying pre-cac */ |
| 5598 | sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(adapter); |
| 5599 | if (!wlan_sap_is_pre_cac_context(sap_ctx)) |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5600 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5601 | |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5602 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5603 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5604 | case QDF_P2P_GO_MODE: |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5605 | cds_flush_work(&adapter->sap_stop_bss_work); |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5606 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5607 | wlan_hdd_undo_acs(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5608 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5609 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5610 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5611 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5612 | hdd_deregister_hl_netdev_fc_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5613 | hdd_deregister_tx_flow_control(adapter); |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5614 | hdd_destroy_acs_timer(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5615 | |
Pragaspathi Thilagaraj | e6f37e0 | 2019-01-04 12:24:33 +0530 | [diff] [blame] | 5616 | /** |
| 5617 | * During vdev destroy, If any STA is in connecting state the |
| 5618 | * roam command will be in active queue and thus vdev destroy is |
| 5619 | * queued in pending queue. In case STA is tries to connected to |
| 5620 | * multiple BSSID and fails to connect, due to auth/assoc |
| 5621 | * timeouts it may take more than vdev destroy time to get |
| 5622 | * completes. If vdev destroy timeout vdev is moved to logically |
| 5623 | * deleted state. Once connection is completed, vdev destroy is |
| 5624 | * activated and to release the self-peer ref count it try to |
| 5625 | * get the ref of the vdev, which fails as vdev is logically |
| 5626 | * deleted and this leads to peer ref leak. So before vdev |
| 5627 | * destroy is queued abort any STA ongoing connection to avoid |
| 5628 | * vdev destroy timeout. |
| 5629 | */ |
| 5630 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5631 | hdd_abort_ongoing_sta_connection(hdd_ctx); |
| 5632 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5633 | mutex_lock(&hdd_ctx->sap_lock); |
| 5634 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5635 | status = wlansap_stop_bss( |
| 5636 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5637 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5638 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5639 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5640 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5641 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5642 | qdf_stop_bss_event); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5643 | status = qdf_wait_for_event_completion( |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5644 | &hostapd_state->qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 5645 | SME_CMD_STOP_BSS_TIMEOUT); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5646 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5647 | hdd_err("failure waiting for wlansap_stop_bss %d", |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5648 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5649 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5650 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5651 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5652 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5653 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5654 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5655 | adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5656 | adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5657 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5658 | adapter->device_mode, |
| 5659 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5660 | |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5661 | qdf_copy_macaddr(&update_ie.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5662 | &adapter->mac_addr); |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5663 | update_ie.smeSessionId = adapter->vdev_id; |
| 5664 | update_ie.ieBufferlength = 0; |
| 5665 | update_ie.pAdditionIEBuffer = NULL; |
| 5666 | update_ie.append = false; |
| 5667 | update_ie.notify = false; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5668 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5669 | /* Probe bcn reset */ |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5670 | status = sme_update_add_ie(mac_handle, &update_ie, |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5671 | eUPDATE_IE_PROBE_BCN); |
| 5672 | if (status == QDF_STATUS_E_FAILURE) |
| 5673 | hdd_err("Could not pass PROBE_RSP_BCN to PE"); |
| 5674 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5675 | /* Assoc resp reset */ |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5676 | status = sme_update_add_ie(mac_handle, &update_ie, |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5677 | eUPDATE_IE_ASSOC_RESP); |
| 5678 | if (status == QDF_STATUS_E_FAILURE) |
| 5679 | hdd_err("Could not pass ASSOC_RSP to PE"); |
| 5680 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5681 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5682 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5683 | } |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5684 | clear_bit(SOFTAP_INIT_DONE, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5685 | qdf_mem_free(adapter->session.ap.beacon); |
| 5686 | adapter->session.ap.beacon = NULL; |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5687 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5688 | /* |
| 5689 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5690 | */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5691 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5692 | if (vdev) { |
| 5693 | if (policy_mgr_is_dnsc_set(vdev)) |
| 5694 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5695 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5696 | } |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5697 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5698 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5699 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5700 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5701 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5702 | #endif |
| 5703 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5704 | |
| 5705 | hdd_vdev_destroy(adapter); |
| 5706 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5707 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5708 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5709 | case QDF_OCB_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5710 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5711 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5712 | cds_get_context(QDF_MODULE_ID_TXRX), |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 5713 | sta_ctx->conn_info.sta_id[0]); |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5714 | hdd_deregister_hl_netdev_fc_timer(adapter); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5715 | hdd_deregister_tx_flow_control(adapter); |
| 5716 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5717 | break; |
| 5718 | default: |
| 5719 | break; |
| 5720 | } |
| 5721 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5722 | if (adapter->scan_info.default_scan_ies) { |
| 5723 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5724 | adapter->scan_info.default_scan_ies = NULL; |
| 5725 | } |
| 5726 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5727 | hdd_exit(); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5728 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5729 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5730 | } |
| 5731 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5732 | /** |
| 5733 | * hdd_deinit_all_adapters - deinit all adapters |
| 5734 | * @hdd_ctx: HDD context |
| 5735 | * @rtnl_held: True if RTNL lock held |
| 5736 | * |
| 5737 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5738 | 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] | 5739 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5740 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5741 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5742 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5743 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5744 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5745 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5746 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5747 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5748 | } |
| 5749 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5750 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5751 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5752 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5753 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5754 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5755 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5756 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5757 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5758 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5759 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5760 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5761 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5762 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5763 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5764 | } |
| 5765 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5766 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5767 | struct hdd_adapter *adapter) |
| 5768 | { |
| 5769 | switch (adapter->device_mode) { |
| 5770 | case QDF_STA_MODE: |
| 5771 | case QDF_P2P_CLIENT_MODE: |
| 5772 | case QDF_IBSS_MODE: |
| 5773 | case QDF_P2P_DEVICE_MODE: |
| 5774 | case QDF_NDI_MODE: |
| 5775 | wlan_hdd_scan_abort(adapter); |
| 5776 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5777 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5778 | struct wlan_objmgr_vdev *vdev; |
| 5779 | |
| 5780 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5781 | if (vdev) { |
| 5782 | wlan_cfg80211_sched_scan_stop(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5783 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5784 | } |
| 5785 | } |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5786 | break; |
| 5787 | case QDF_P2P_GO_MODE: |
| 5788 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5789 | break; |
| 5790 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5791 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5792 | wlan_hdd_undo_acs(adapter); |
| 5793 | break; |
| 5794 | default: |
| 5795 | break; |
| 5796 | } |
| 5797 | } |
| 5798 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5799 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5800 | /** |
| 5801 | * hdd_adapter_abort_tx_flow() - Abort the tx flow control |
| 5802 | * @pAdapter: pointer to hdd_adapter_t |
| 5803 | * |
| 5804 | * Resume tx and stop the tx flow control timer if the tx is paused |
| 5805 | * and the flow control timer is running. This function is called by |
| 5806 | * SSR to avoid the inconsistency of tx status before and after SSR. |
| 5807 | * |
| 5808 | * Return: void |
| 5809 | */ |
| 5810 | static void hdd_adapter_abort_tx_flow(struct hdd_adapter *adapter) |
| 5811 | { |
| 5812 | if (adapter->hdd_stats.tx_rx_stats.is_txflow_paused && |
| 5813 | QDF_TIMER_STATE_RUNNING == |
| 5814 | qdf_mc_timer_get_current_state( |
| 5815 | &adapter->tx_flow_control_timer)) { |
| 5816 | hdd_tx_resume_timer_expired_handler(adapter); |
| 5817 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 5818 | } |
| 5819 | } |
| 5820 | #endif |
| 5821 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5822 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5823 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5824 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5825 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 2d04461 | 2019-02-26 20:08:43 -0800 | [diff] [blame] | 5826 | struct qdf_mac_addr peer_macaddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5827 | int sta_id; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5828 | bool value; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5829 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5830 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5831 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5832 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5833 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5834 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5835 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5836 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5837 | qdf_opmode_str(adapter->device_mode), |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5838 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5839 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5840 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5841 | hdd_adapter_abort_tx_flow(adapter); |
| 5842 | #endif |
| 5843 | |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5844 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5845 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5846 | /* Stop tdls timers */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5847 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5848 | if (vdev) { |
| 5849 | hdd_notify_tdls_reset_adapter(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5850 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5851 | } |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5852 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5853 | } |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 5854 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5855 | if (value && |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5856 | adapter->device_mode == QDF_SAP_MODE) { |
| 5857 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5858 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5859 | WLAN_CONTROL_PATH); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5860 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5861 | cds_flush_delayed_work( |
| 5862 | &adapter->acs_pending_work); |
| 5863 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5864 | } |
| 5865 | |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5866 | if (test_bit(SOFTAP_BSS_STARTED, |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5867 | &adapter->event_flags)) { |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5868 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5869 | clear_bit(SOFTAP_BSS_STARTED, |
| 5870 | &adapter->event_flags); |
| 5871 | } |
| 5872 | |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5873 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5874 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5875 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5876 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5877 | } |
Nijun Gong | 104ccc7 | 2018-08-07 10:43:56 +0800 | [diff] [blame] | 5878 | /* |
| 5879 | * Clear fc flag if it was set before SSR to avoid TX queues |
| 5880 | * permanently stopped after SSR. |
| 5881 | * Here WLAN_START_ALL_NETIF_QUEUE will actually not start any |
| 5882 | * queue since it's blocked by reason WLAN_CONTROL_PATH. |
| 5883 | */ |
| 5884 | if (adapter->pause_map & (1 << WLAN_DATA_FLOW_CONTROL)) |
| 5885 | wlan_hdd_netif_queue_control(adapter, |
| 5886 | WLAN_START_ALL_NETIF_QUEUE, |
| 5887 | WLAN_DATA_FLOW_CONTROL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5888 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5889 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5890 | |
| 5891 | hdd_deinit_tx_rx(adapter); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5892 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5893 | adapter->device_mode, adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5894 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5895 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5896 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5897 | hdd_wmm_adapter_close(adapter); |
| 5898 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5899 | } |
| 5900 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5901 | if (adapter->device_mode == QDF_STA_MODE) |
| 5902 | hdd_clear_fils_connection_info(adapter); |
| 5903 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5904 | if (adapter->device_mode == QDF_SAP_MODE) { |
Jingxiang Ge | ec11359 | 2018-08-09 15:40:39 +0800 | [diff] [blame] | 5905 | wlansap_cleanup_cac_timer( |
| 5906 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5907 | /* |
| 5908 | * If adapter is SAP, set session ID to invalid |
| 5909 | * since SAP session will be cleanup during SSR. |
| 5910 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5911 | wlansap_set_invalid_session( |
| 5912 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5913 | } |
| 5914 | |
Abhishek Singh | 8f4aa18 | 2019-03-06 10:29:24 +0530 | [diff] [blame] | 5915 | /* Release vdev ref count to avoid vdev object leak */ |
| 5916 | if (adapter->device_mode == QDF_P2P_GO_MODE || |
| 5917 | adapter->device_mode == QDF_SAP_MODE) |
| 5918 | wlansap_release_vdev_ref( |
| 5919 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5920 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5921 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5922 | if (adapter->device_mode == QDF_STA_MODE || |
| 5923 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5924 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 2d04461 | 2019-02-26 20:08:43 -0800 | [diff] [blame] | 5925 | qdf_copy_macaddr(&peer_macaddr, |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 5926 | &sta_ctx->conn_info.bssid); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5927 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5928 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
Wu Gao | 6b81fc5 | 2018-05-24 19:27:27 +0800 | [diff] [blame] | 5929 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5930 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5931 | if (adapter->sta_info[sta_id].in_use) { |
| 5932 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5933 | sta_id); |
| 5934 | hdd_softap_deregister_sta(adapter, |
| 5935 | sta_id); |
| 5936 | adapter->sta_info[sta_id].in_use = 0; |
| 5937 | } |
| 5938 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5939 | } |
| 5940 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5941 | hdd_nud_ignore_tracking(adapter, true); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5942 | hdd_nud_reset_tracking(adapter); |
| 5943 | hdd_nud_flush_work(adapter); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5944 | |
| 5945 | if (adapter->device_mode != QDF_SAP_MODE && |
| 5946 | adapter->device_mode != QDF_P2P_GO_MODE && |
| 5947 | adapter->device_mode != QDF_FTM_MODE) |
| 5948 | hdd_set_disconnect_status(adapter, false); |
| 5949 | |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5950 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5951 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5952 | hdd_softap_deinit_tx_rx(adapter); |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5953 | hdd_deregister_hl_netdev_fc_timer(adapter); |
Tiger Yu | 8c38770 | 2018-07-06 16:56:42 +0800 | [diff] [blame] | 5954 | hdd_deregister_tx_flow_control(adapter); |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5955 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5956 | /* Destroy vdev which will be recreated during reinit. */ |
| 5957 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5958 | } |
| 5959 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5960 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5961 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5962 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5963 | } |
| 5964 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5965 | bool hdd_is_any_interface_open(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5966 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5967 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5968 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5969 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5970 | hdd_info("FTM mode, don't close the module"); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5971 | return true; |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5972 | } |
| 5973 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5974 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5975 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5976 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5977 | return true; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5978 | } |
| 5979 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5980 | return false; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5981 | } |
| 5982 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5983 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5984 | { |
| 5985 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5986 | return true; |
| 5987 | else |
| 5988 | return false; |
| 5989 | } |
| 5990 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5991 | #if defined CFG80211_CONNECT_BSS || \ |
| 5992 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5993 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5994 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5995 | /** |
| 5996 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5997 | * @timeout_reason: reason for connect timeout |
| 5998 | * |
| 5999 | * This function is used to convert host timeout |
| 6000 | * reason enum to kernel specific enum. |
| 6001 | * |
| 6002 | * Return: nl timeout enum |
| 6003 | */ |
| 6004 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 6005 | tSirResultCodes timeout_reason) |
| 6006 | { |
| 6007 | switch (timeout_reason) { |
| 6008 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 6009 | return NL80211_TIMEOUT_SCAN; |
| 6010 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 6011 | return NL80211_TIMEOUT_AUTH; |
| 6012 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 6013 | return NL80211_TIMEOUT_ASSOC; |
| 6014 | default: |
| 6015 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 6016 | } |
| 6017 | } |
| 6018 | |
| 6019 | /** |
| 6020 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 6021 | * @dev: network device |
| 6022 | * @bssid: bssid to which we want to associate |
| 6023 | * @timeout_reason: reason for connect timeout |
| 6024 | * |
| 6025 | * This API is used to send connection timeout reason to supplicant |
| 6026 | * |
| 6027 | * Return: void |
| 6028 | */ |
| 6029 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 6030 | const u8 *bssid, |
| 6031 | tSirResultCodes timeout_reason) |
| 6032 | { |
| 6033 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6034 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6035 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 6036 | |
| 6037 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 6038 | nl_timeout_reason); |
| 6039 | } |
| 6040 | |
| 6041 | /** |
| 6042 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 6043 | * @dev: network device |
| 6044 | * @bssid: bssid to which we want to associate |
| 6045 | * @req_ie: Request Information Element |
| 6046 | * @req_ie_len: len of the req IE |
| 6047 | * @resp_ie: Response IE |
| 6048 | * @resp_ie_len: len of ht response IE |
| 6049 | * @status: status |
| 6050 | * @gfp: Kernel Flag |
| 6051 | * @timeout_reason: reason for connect timeout |
| 6052 | * |
| 6053 | * Return: void |
| 6054 | */ |
| 6055 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6056 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6057 | size_t req_ie_len, const u8 *resp_ie, |
| 6058 | size_t resp_ie_len, int status, gfp_t gfp, |
| 6059 | tSirResultCodes timeout_reason) |
| 6060 | { |
| 6061 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6062 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6063 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 6064 | |
| 6065 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 6066 | resp_ie, resp_ie_len, status, gfp, |
| 6067 | nl_timeout_reason); |
| 6068 | } |
| 6069 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6070 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 6071 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6072 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 6073 | const u8 *bssid, |
| 6074 | tSirResultCodes timeout_reason) |
| 6075 | { |
| 6076 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 6077 | } |
| 6078 | #endif |
| 6079 | |
| 6080 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6081 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6082 | size_t req_ie_len, const u8 *resp_ie, |
| 6083 | size_t resp_ie_len, int status, gfp_t gfp, |
| 6084 | tSirResultCodes timeout_reason) |
| 6085 | { |
| 6086 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 6087 | resp_ie, resp_ie_len, status, gfp); |
| 6088 | } |
| 6089 | #endif |
| 6090 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6091 | /** |
| 6092 | * hdd_connect_bss() - API to send connection status to supplicant |
| 6093 | * @dev: network device |
| 6094 | * @bssid: bssid to which we want to associate |
| 6095 | * @req_ie: Request Information Element |
| 6096 | * @req_ie_len: len of the req IE |
| 6097 | * @resp_ie: Response IE |
| 6098 | * @resp_ie_len: len of ht response IE |
| 6099 | * @status: status |
| 6100 | * @gfp: Kernel Flag |
| 6101 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6102 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6103 | * |
| 6104 | * The API is a wrapper to send connection status to supplicant |
| 6105 | * |
| 6106 | * Return: Void |
| 6107 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6108 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 6109 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6110 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6111 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6112 | size_t req_ie_len, const u8 *resp_ie, |
| 6113 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6114 | bool connect_timeout, |
| 6115 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6116 | { |
| 6117 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6118 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6119 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6120 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6121 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6122 | } |
| 6123 | #else |
| 6124 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6125 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6126 | size_t req_ie_len, const u8 *resp_ie, |
| 6127 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6128 | bool connect_timeout, |
| 6129 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6130 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6131 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6132 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6133 | } |
| 6134 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6135 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6136 | #if defined(WLAN_FEATURE_FILS_SK) |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6137 | #if (defined(CFG80211_CONNECT_DONE) || \ |
| 6138 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) && \ |
| 6139 | (LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0)) |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6140 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 6141 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6142 | /** |
| 6143 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 6144 | * @fils_params: connect response to supplicant |
| 6145 | * @fils_kek: FILS kek |
| 6146 | * @fils_kek_len: FILS kek length |
| 6147 | * @pmk: FILS PMK |
| 6148 | * @pmk_len: FILS PMK length |
| 6149 | * @pmkid: PMKID |
| 6150 | * @fils_seq_num: FILS Seq number |
| 6151 | * |
| 6152 | * Return: None |
| 6153 | */ |
| 6154 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6155 | *fils_params, const uint8_t *fils_kek, |
| 6156 | size_t fils_kek_len, const uint8_t *pmk, |
| 6157 | size_t pmk_len, const uint8_t *pmkid, |
| 6158 | uint16_t fils_seq_num) |
| 6159 | { |
| 6160 | /* Increament seq number to be used for next FILS */ |
| 6161 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 6162 | fils_params->update_erp_next_seq_num = true; |
| 6163 | fils_params->fils_kek = fils_kek; |
| 6164 | fils_params->fils_kek_len = fils_kek_len; |
| 6165 | fils_params->pmk = pmk; |
| 6166 | fils_params->pmk_len = pmk_len; |
| 6167 | fils_params->pmkid = pmkid; |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6168 | hdd_debug("FILS erp_next_seq_num:%d", |
| 6169 | fils_params->fils_erp_next_seq_num); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6170 | } |
| 6171 | #else |
| 6172 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6173 | *fils_params, const uint8_t |
| 6174 | *fils_kek, size_t fils_kek_len, |
| 6175 | const uint8_t *pmk, size_t pmk_len, |
| 6176 | const uint8_t *pmkid, |
| 6177 | uint16_t fils_seq_num) |
| 6178 | { } |
| 6179 | #endif |
| 6180 | |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6181 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) |
| 6182 | /** |
| 6183 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 6184 | * @fils_params: connect response to supplicant |
| 6185 | * @fils_kek: FILS kek |
| 6186 | * @fils_kek_len: FILS kek length |
| 6187 | * @pmk: FILS PMK |
| 6188 | * @pmk_len: FILS PMK length |
| 6189 | * @pmkid: PMKID |
| 6190 | * @fils_seq_num: FILS Seq number |
| 6191 | * |
| 6192 | * Return: None |
| 6193 | */ |
| 6194 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6195 | *fils_params, const uint8_t *fils_kek, |
| 6196 | size_t fils_kek_len, const uint8_t *pmk, |
| 6197 | size_t pmk_len, const uint8_t *pmkid, |
| 6198 | uint16_t fils_seq_num) |
| 6199 | { |
| 6200 | /* Increament seq number to be used for next FILS */ |
| 6201 | fils_params->fils.erp_next_seq_num = fils_seq_num + 1; |
| 6202 | fils_params->fils.update_erp_next_seq_num = true; |
| 6203 | fils_params->fils.kek = fils_kek; |
| 6204 | fils_params->fils.kek_len = fils_kek_len; |
| 6205 | fils_params->fils.pmk = pmk; |
| 6206 | fils_params->fils.pmk_len = pmk_len; |
| 6207 | fils_params->fils.pmkid = pmkid; |
| 6208 | hdd_debug("FILS erp_next_seq_num:%d", |
| 6209 | fils_params->fils.erp_next_seq_num); |
| 6210 | } |
| 6211 | #endif /* CFG80211_CONNECT_DONE */ |
| 6212 | |
| 6213 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 6214 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 6215 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6216 | void hdd_update_hlp_info(struct net_device *dev, |
| 6217 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6218 | { |
| 6219 | struct sk_buff *skb; |
| 6220 | uint16_t skb_len; |
| 6221 | struct llc_snap_hdr_t *llc_hdr; |
| 6222 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6223 | uint8_t *hlp_data; |
| 6224 | uint16_t hlp_data_len; |
| 6225 | struct fils_join_rsp_params *roam_fils_params |
| 6226 | = roam_info->fils_join_rsp; |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6227 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6228 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6229 | if (!roam_fils_params) { |
| 6230 | hdd_err("FILS Roam Param NULL"); |
| 6231 | return; |
| 6232 | } |
| 6233 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 6234 | if (!roam_fils_params->hlp_data_len) { |
Jianmin Zhu | cc6b3d0 | 2019-03-07 14:19:34 +0800 | [diff] [blame] | 6235 | hdd_debug("FILS HLP Data NULL, len %d", |
| 6236 | roam_fils_params->hlp_data_len); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6237 | return; |
| 6238 | } |
| 6239 | |
| 6240 | hlp_data = roam_fils_params->hlp_data; |
| 6241 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 6242 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6243 | /* Calculate skb length */ |
| 6244 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 6245 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 6246 | if (!skb) { |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6247 | hdd_err("HLP packet nbuf alloc fails"); |
| 6248 | return; |
| 6249 | } |
| 6250 | |
| 6251 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 6252 | QDF_MAC_ADDR_SIZE); |
| 6253 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 6254 | QDF_MAC_ADDR_SIZE); |
| 6255 | |
| 6256 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 6257 | if (IS_SNAP(llc_hdr)) { |
| 6258 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6259 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6260 | } |
| 6261 | |
| 6262 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 6263 | |
| 6264 | /* |
| 6265 | * This HLP packet is formed from HLP info encapsulated |
| 6266 | * in assoc response frame which is AEAD encrypted. |
| 6267 | * Hence, this checksum validation can be set unnecessary. |
| 6268 | * i.e. network layer need not worry about checksum. |
| 6269 | */ |
| 6270 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 6271 | |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6272 | status = hdd_rx_packet_cbk(adapter, skb); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6273 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6274 | hdd_err("Sending HLP packet fails"); |
| 6275 | return; |
| 6276 | } |
| 6277 | hdd_debug("send HLP packet to netif successfully"); |
| 6278 | } |
| 6279 | |
| 6280 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6281 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 6282 | * @dev: network device |
| 6283 | * @bssid: bssid to which we want to associate |
| 6284 | * @bss: cfg80211 bss info |
| 6285 | * @roam_info: information about connected bss |
| 6286 | * @req_ie: Request Information Element |
| 6287 | * @req_ie_len: len of the req IE |
| 6288 | * @resp_ie: Response IE |
| 6289 | * @resp_ie_len: len of ht response IE |
| 6290 | * @status: status |
| 6291 | * @gfp: allocation flags |
| 6292 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6293 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6294 | * |
| 6295 | * This API is used as wrapper to send FILS key/sequence number |
| 6296 | * params etc. to supplicant in case of FILS connection |
| 6297 | * |
| 6298 | * Return: None |
| 6299 | */ |
| 6300 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6301 | struct cfg80211_bss *bss, |
| 6302 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6303 | const u8 *req_ie, size_t req_ie_len, |
| 6304 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6305 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6306 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6307 | { |
| 6308 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6309 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6310 | struct fils_join_rsp_params *roam_fils_params = |
| 6311 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6312 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6313 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 6314 | |
| 6315 | if (!roam_fils_params) { |
| 6316 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 6317 | } else { |
| 6318 | fils_params.status = status; |
| 6319 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 6320 | fils_params.timeout_reason = |
| 6321 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6322 | fils_params.req_ie = req_ie; |
| 6323 | fils_params.req_ie_len = req_ie_len; |
| 6324 | fils_params.resp_ie = resp_ie; |
| 6325 | fils_params.resp_ie_len = resp_ie_len; |
| 6326 | fils_params.bss = bss; |
| 6327 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 6328 | roam_fils_params->kek_len, |
| 6329 | roam_fils_params->fils_pmk, |
| 6330 | roam_fils_params->fils_pmk_len, |
| 6331 | roam_fils_params->fils_pmkid, |
| 6332 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 6333 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6334 | } |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6335 | hdd_debug("FILS indicate connect status %d", fils_params.status); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6336 | |
| 6337 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 6338 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6339 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6340 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6341 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6342 | /* Clear all the FILS key info */ |
| 6343 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 6344 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 6345 | if (roam_fils_params) |
| 6346 | qdf_mem_free(roam_fils_params); |
| 6347 | roam_info->fils_join_rsp = NULL; |
| 6348 | } |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6349 | #else /* CFG80211_CONNECT_DONE */ |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6350 | static inline void |
| 6351 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6352 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6353 | const u8 *req_ie, size_t req_ie_len, |
| 6354 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 6355 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6356 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6357 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6358 | #endif |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6359 | #endif /* WLAN_FEATURE_FILS_SK */ |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6360 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6361 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 6362 | (defined(CFG80211_CONNECT_DONE) || \ |
| 6363 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6364 | /** |
| 6365 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 6366 | * supplicant. |
| 6367 | * @dev: network device |
| 6368 | * @bssid: bssid to which we want to associate |
| 6369 | * @bss: cfg80211 bss info |
| 6370 | * @roam_info: information about connected bss |
| 6371 | * @req_ie: Request Information Element |
| 6372 | * @req_ie_len: len of the req IE |
| 6373 | * @resp_ie: Response IE |
| 6374 | * @resp_ie_len: len of ht response IE |
| 6375 | * @status: status |
| 6376 | * @gfp: allocation flags |
| 6377 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6378 | * @timeout_reason: reason for connect timeout |
| 6379 | * |
| 6380 | * The API is a wrapper to send connection status to supplicant |
| 6381 | * |
| 6382 | * Return: 0 if success else failure |
| 6383 | */ |
| 6384 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 6385 | const u8 *bssid, |
| 6386 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6387 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6388 | size_t req_ie_len, const u8 *resp_ie, |
| 6389 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6390 | bool connect_timeout, |
| 6391 | tSirResultCodes timeout_reason) |
| 6392 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6393 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6394 | if (!roam_info || !roam_info->is_fils_connection) |
| 6395 | return -EINVAL; |
| 6396 | |
| 6397 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 6398 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6399 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6400 | return 0; |
| 6401 | } |
| 6402 | #else |
| 6403 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 6404 | const u8 *bssid, |
| 6405 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6406 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6407 | size_t req_ie_len, const u8 *resp_ie, |
| 6408 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6409 | bool connect_timeout, |
| 6410 | tSirResultCodes timeout_reason) |
| 6411 | { |
| 6412 | return -EINVAL; |
| 6413 | } |
| 6414 | #endif |
| 6415 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6416 | /** |
| 6417 | * hdd_connect_result() - API to send connection status to supplicant |
| 6418 | * @dev: network device |
| 6419 | * @bssid: bssid to which we want to associate |
| 6420 | * @roam_info: information about connected bss |
| 6421 | * @req_ie: Request Information Element |
| 6422 | * @req_ie_len: len of the req IE |
| 6423 | * @resp_ie: Response IE |
| 6424 | * @resp_ie_len: len of ht response IE |
| 6425 | * @status: status |
| 6426 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6427 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6428 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6429 | * |
| 6430 | * The API is a wrapper to send connection status to supplicant |
| 6431 | * and allow runtime suspend |
| 6432 | * |
| 6433 | * Return: Void |
| 6434 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6435 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6436 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6437 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6438 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6439 | bool connect_timeout, |
| 6440 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6441 | { |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6442 | struct hdd_adapter *adapter = netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6443 | struct cfg80211_bss *bss = NULL; |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6444 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6445 | |
| 6446 | if (WLAN_STATUS_SUCCESS == status) { |
| 6447 | struct ieee80211_channel *chan; |
| 6448 | int freq; |
| 6449 | int chan_no = roam_info->pBssDesc->channelId; |
| 6450 | |
| 6451 | if (chan_no <= 14) |
| 6452 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6453 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6454 | else |
| 6455 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6456 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6457 | |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6458 | chan = ieee80211_get_channel(adapter->wdev.wiphy, freq); |
| 6459 | bss = wlan_cfg80211_get_bss(adapter->wdev.wiphy, chan, bssid, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6460 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 6461 | roam_info->u.pConnectedProfile->SSID.length); |
| 6462 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6463 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6464 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 6465 | roam_info, req_ie, req_ie_len, resp_ie, |
| 6466 | resp_ie_len, status, gfp, connect_timeout, |
| 6467 | timeout_reason) != 0) { |
| 6468 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 6469 | req_ie_len, resp_ie, resp_ie_len, |
| 6470 | status, gfp, connect_timeout, timeout_reason); |
| 6471 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6472 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6473 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6474 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6475 | } |
| 6476 | #else |
| 6477 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6478 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6479 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6480 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6481 | bool connect_timeout, |
| 6482 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6483 | { |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6484 | struct hdd_adapter *adapter = netdev_priv(dev); |
| 6485 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6486 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6487 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 6488 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 6489 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6490 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6491 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6492 | } |
| 6493 | #endif |
| 6494 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6495 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6496 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 6497 | uint32_t bandwidth) |
| 6498 | { |
| 6499 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6500 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 6501 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 6502 | QDF_STATUS status; |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6503 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6504 | struct qdf_mac_addr bssid; |
| 6505 | struct csr_roam_profile roam_profile; |
| 6506 | struct ch_params ch_params; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6507 | eConnectionState connstate; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6508 | |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6509 | if (hdd_get_conparam() != QDF_GLOBAL_MONITOR_MODE && |
| 6510 | adapter->device_mode != QDF_STA_MODE) { |
| 6511 | 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] | 6512 | return -EINVAL; |
| 6513 | } |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6514 | if (adapter->device_mode == QDF_STA_MODE && |
Pragaspathi Thilagaraj | a889375 | 2019-02-06 19:58:59 +0530 | [diff] [blame] | 6515 | ucfg_mlme_is_change_channel_bandwidth_enabled(hdd_ctx->psoc)) { |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6516 | connstate = sta_ctx->conn_info.conn_state; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6517 | if (eConnectionState_Associated == connstate || |
| 6518 | eConnectionState_Connecting == connstate) { |
| 6519 | return -EINVAL; |
| 6520 | } |
| 6521 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6522 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 6523 | /* Validate Channel */ |
| 6524 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6525 | hdd_err("Channel %d Not supported", chan); |
| 6526 | return -EINVAL; |
| 6527 | } |
| 6528 | |
| 6529 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 6530 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 6531 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 6532 | return -EINVAL; |
| 6533 | } |
| 6534 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 6535 | (bandwidth != CH_WIDTH_MAX)) { |
| 6536 | hdd_err("Only BW20 possible on channel 14"); |
| 6537 | return -EINVAL; |
| 6538 | } |
| 6539 | } |
| 6540 | |
| 6541 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6542 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 6543 | (bandwidth != CH_WIDTH_MAX)) { |
| 6544 | hdd_err("Only BW20 possible on channel 165"); |
| 6545 | return -EINVAL; |
| 6546 | } |
| 6547 | } |
| 6548 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6549 | hdd_debug("Set monitor mode Channel %d", chan); |
| 6550 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 6551 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 6552 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 6553 | roam_profile.phyMode = ch_info->phy_mode; |
| 6554 | roam_profile.ch_params.ch_width = bandwidth; |
| 6555 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
Pragaspathi Thilagaraj | a889375 | 2019-02-06 19:58:59 +0530 | [diff] [blame] | 6556 | if (ucfg_mlme_is_change_channel_bandwidth_enabled(hdd_ctx->psoc) && |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6557 | (!sme_find_session_by_bssid(mac_handle, adapter->mac_addr.bytes))) { |
| 6558 | status = sme_create_mon_session(mac_handle, |
Rajeev Kumar Sirasanagandla | e3b5991 | 2018-08-24 15:53:31 +0530 | [diff] [blame] | 6559 | adapter->mac_addr.bytes, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6560 | adapter->vdev_id); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6561 | if (status != QDF_STATUS_SUCCESS) { |
| 6562 | hdd_err("Status: %d Failed to create session.", |
| 6563 | status); |
| 6564 | return qdf_status_to_os_return(status); |
| 6565 | } |
| 6566 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6567 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 6568 | QDF_MAC_ADDR_SIZE); |
| 6569 | |
| 6570 | ch_params.ch_width = bandwidth; |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6571 | wlan_reg_set_channel_params(hdd_ctx->pdev, chan, 0, &ch_params); |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6572 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 6573 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 6574 | return -EINVAL; |
| 6575 | } |
| 6576 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 6577 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 6578 | hdd_err("Failed to change hw mode"); |
| 6579 | return -EINVAL; |
| 6580 | } |
| 6581 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 6582 | status = sme_roam_channel_change_req(hdd_ctx->mac_handle, |
| 6583 | bssid, &ch_params, |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6584 | &roam_profile); |
| 6585 | if (status) { |
| 6586 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 6587 | status); |
| 6588 | } |
| 6589 | |
| 6590 | adapter->mon_chan = chan; |
| 6591 | adapter->mon_bandwidth = bandwidth; |
| 6592 | return qdf_status_to_os_return(status); |
| 6593 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6594 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6595 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6596 | #ifdef MSM_PLATFORM |
| 6597 | /** |
| 6598 | * hdd_stop_p2p_go() - call cfg80211 API to stop P2P GO |
| 6599 | * @adapter: pointer to adapter |
| 6600 | * |
| 6601 | * This function calls cfg80211 API to stop P2P GO |
| 6602 | * |
| 6603 | * Return: None |
| 6604 | */ |
| 6605 | static void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6606 | { |
| 6607 | hdd_debug("[SSR] send stop ap to supplicant"); |
| 6608 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 6609 | } |
| 6610 | |
| 6611 | static inline void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6612 | { |
| 6613 | } |
| 6614 | #else |
| 6615 | static inline void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6616 | { |
| 6617 | } |
| 6618 | |
| 6619 | /** |
| 6620 | * hdd_delete_sta() - call cfg80211 API to delete STA |
| 6621 | * @adapter: pointer to adapter |
| 6622 | * |
| 6623 | * This function calls cfg80211 API to delete STA |
| 6624 | * |
| 6625 | * Return: None |
| 6626 | */ |
| 6627 | static void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6628 | { |
| 6629 | struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT; |
| 6630 | |
| 6631 | hdd_debug("[SSR] send restart supplicant"); |
| 6632 | /* event supplicant to restart */ |
| 6633 | cfg80211_del_sta(adapter->dev, |
| 6634 | (const u8 *)&bcast_mac.bytes[0], |
| 6635 | GFP_KERNEL); |
| 6636 | } |
| 6637 | #endif |
| 6638 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6639 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6640 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6641 | struct hdd_adapter *adapter; |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6642 | eConnectionState conn_state; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6643 | bool value; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6644 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6645 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6646 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6647 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6648 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6649 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6650 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6651 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 6652 | qdf_opmode_str(adapter->device_mode), |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6653 | adapter->device_mode); |
| 6654 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6655 | hdd_wmm_init(adapter); |
| 6656 | |
| 6657 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6658 | case QDF_STA_MODE: |
| 6659 | case QDF_P2P_CLIENT_MODE: |
| 6660 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6661 | |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6662 | conn_state = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 6663 | ->conn_info.conn_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6664 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6665 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6666 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 6667 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6668 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6669 | /* Indicate disconnect event to supplicant |
| 6670 | * if associated previously |
| 6671 | */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6672 | if (eConnectionState_Associated == conn_state || |
| 6673 | eConnectionState_IbssConnected == conn_state || |
| 6674 | eConnectionState_NotConnected == conn_state || |
| 6675 | eConnectionState_IbssDisconnected == conn_state || |
| 6676 | eConnectionState_Disconnecting == conn_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6677 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6678 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6679 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6680 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6681 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 6682 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 6683 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 6684 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 6685 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6686 | |
| 6687 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 6688 | wlan_hdd_cfg80211_indicate_disconnect( |
| 6689 | adapter->dev, false, |
| 6690 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6691 | } else if (eConnectionState_Connecting == conn_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6692 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6693 | * Indicate connect failure to supplicant if we |
| 6694 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6695 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6696 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6697 | NULL, 0, NULL, 0, |
| 6698 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6699 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6700 | } |
| 6701 | |
| 6702 | hdd_register_tx_flow_control(adapter, |
| 6703 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6704 | hdd_tx_resume_cb, |
| 6705 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6706 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 6707 | hdd_register_hl_netdev_fc_timer( |
| 6708 | adapter, |
| 6709 | hdd_tx_resume_timer_expired_handler); |
| 6710 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 6711 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6712 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6713 | break; |
| 6714 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6715 | case QDF_SAP_MODE: |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 6716 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6717 | &value); |
| 6718 | if (value) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6719 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6720 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6721 | break; |
| 6722 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6723 | case QDF_P2P_GO_MODE: |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6724 | hdd_delete_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6725 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6726 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6727 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6728 | hdd_set_mon_rx_cb(adapter->dev); |
| 6729 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6730 | adapter->mon_bandwidth); |
| 6731 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6732 | default: |
| 6733 | break; |
| 6734 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6735 | /* |
| 6736 | * Action frame registered in one adapter which will |
| 6737 | * applicable to all interfaces |
| 6738 | */ |
| 6739 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6740 | } |
| 6741 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6742 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6743 | if (!hdd_is_interface_up(adapter)) |
| 6744 | continue; |
| 6745 | |
| 6746 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 6747 | hdd_stop_p2p_go(adapter); |
| 6748 | } |
| 6749 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6750 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6751 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6752 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6753 | } |
| 6754 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6755 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6756 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6757 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6758 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6759 | qdf_list_node_t *node; |
| 6760 | |
| 6761 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6762 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6763 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6764 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6765 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6766 | |
| 6767 | if (QDF_IS_STATUS_ERROR(status)) |
| 6768 | return status; |
| 6769 | |
| 6770 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6771 | |
| 6772 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6773 | } |
| 6774 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6775 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6776 | struct hdd_adapter *current_adapter, |
| 6777 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6778 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6779 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6780 | qdf_list_node_t *node; |
| 6781 | |
| 6782 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6783 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6784 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6785 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6786 | ¤t_adapter->node, |
| 6787 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6788 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6789 | |
| 6790 | if (QDF_IS_STATUS_ERROR(status)) |
| 6791 | return status; |
| 6792 | |
| 6793 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6794 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6795 | return status; |
| 6796 | } |
| 6797 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6798 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6799 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6800 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6801 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6802 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6803 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6804 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6805 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6806 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6807 | return status; |
| 6808 | } |
| 6809 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6810 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6811 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6812 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6813 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6814 | qdf_list_node_t *node; |
| 6815 | |
| 6816 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6817 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6818 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6819 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6820 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6821 | |
| 6822 | if (QDF_IS_STATUS_ERROR(status)) |
| 6823 | return status; |
| 6824 | |
| 6825 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6826 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6827 | return status; |
| 6828 | } |
| 6829 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6830 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6831 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6832 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6833 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6834 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6835 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6836 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6837 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6838 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6839 | return status; |
| 6840 | } |
| 6841 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6842 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6843 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6844 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6845 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6846 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6847 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6848 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6849 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6850 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6851 | return status; |
| 6852 | } |
| 6853 | |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 6854 | struct hdd_adapter *hdd_get_adapter_by_rand_macaddr( |
| 6855 | struct hdd_context *hdd_ctx, tSirMacAddr mac_addr) |
| 6856 | { |
| 6857 | struct hdd_adapter *adapter; |
| 6858 | |
| 6859 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6860 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6861 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6862 | adapter->device_mode == QDF_P2P_DEVICE_MODE) && |
| 6863 | ucfg_p2p_check_random_mac(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6864 | adapter->vdev_id, mac_addr)) |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 6865 | return adapter; |
| 6866 | } |
| 6867 | |
| 6868 | return NULL; |
| 6869 | } |
| 6870 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6871 | 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] | 6872 | tSirMacAddr mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6873 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6874 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6875 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6876 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6877 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 6878 | mac_addr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6879 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6880 | } |
| 6881 | |
| 6882 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6883 | } |
| 6884 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6885 | 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] | 6886 | uint32_t vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6887 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6888 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6889 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6890 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6891 | if (adapter->vdev_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6892 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6893 | } |
| 6894 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6895 | return NULL; |
| 6896 | } |
| 6897 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6898 | 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] | 6899 | const char *iface_name) |
| 6900 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6901 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6902 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6903 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6904 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6905 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6906 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6907 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6908 | return NULL; |
| 6909 | } |
| 6910 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6911 | /** |
| 6912 | * hdd_get_adapter() - to get adapter matching the mode |
| 6913 | * @hdd_ctx: hdd context |
| 6914 | * @mode: adapter mode |
| 6915 | * |
| 6916 | * This routine will return the pointer to adapter matching |
| 6917 | * with the passed mode. |
| 6918 | * |
| 6919 | * Return: pointer to adapter or null |
| 6920 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6921 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6922 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6923 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6924 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6925 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6926 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6927 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6928 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6929 | } |
| 6930 | |
| 6931 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6932 | } |
| 6933 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 6934 | enum QDF_OPMODE hdd_get_device_mode(uint32_t vdev_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6935 | { |
| 6936 | struct hdd_context *hdd_ctx; |
| 6937 | struct hdd_adapter *adapter; |
| 6938 | |
| 6939 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6940 | if (!hdd_ctx) { |
| 6941 | hdd_err("Invalid HDD context"); |
| 6942 | return QDF_MAX_NO_OF_MODE; |
| 6943 | } |
| 6944 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 6945 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6946 | if (!adapter) { |
| 6947 | hdd_err("Invalid HDD adapter"); |
| 6948 | return QDF_MAX_NO_OF_MODE; |
| 6949 | } |
| 6950 | |
| 6951 | return adapter->device_mode; |
| 6952 | } |
| 6953 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6954 | /** |
| 6955 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6956 | * @hdd_ctx: Pointer to the HDD context. |
| 6957 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6958 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6959 | * QDF_STA_MODE, |
| 6960 | * QDF_P2P_CLIENT_MODE, |
| 6961 | * QDF_SAP_MODE, |
| 6962 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6963 | * |
| 6964 | * This API returns the operating channel of the requested device mode |
| 6965 | * |
| 6966 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6967 | * not connected. |
| 6968 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6969 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6970 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6971 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6972 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6973 | uint8_t operatingChannel = 0; |
| 6974 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6975 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6976 | if (mode == adapter->device_mode) { |
| 6977 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6978 | case QDF_STA_MODE: |
| 6979 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6980 | if (hdd_conn_is_connected |
| 6981 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6982 | (adapter))) { |
| 6983 | operatingChannel = |
| 6984 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6985 | (adapter))->conn_info. |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 6986 | channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6987 | } |
| 6988 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6989 | case QDF_SAP_MODE: |
| 6990 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6991 | /* softap connection info */ |
| 6992 | if (test_bit |
| 6993 | (SOFTAP_BSS_STARTED, |
| 6994 | &adapter->event_flags)) |
| 6995 | operatingChannel = |
| 6996 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6997 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6998 | break; |
| 6999 | default: |
| 7000 | break; |
| 7001 | } |
| 7002 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7003 | /* Found the device of interest. break the loop */ |
| 7004 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7005 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7006 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7007 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7008 | return operatingChannel; |
| 7009 | } |
| 7010 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7011 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7012 | hdd_ctx) |
| 7013 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7014 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7015 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7016 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7017 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7018 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7019 | if (adapter->device_mode == QDF_STA_MODE || |
| 7020 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 7021 | adapter->device_mode == QDF_IBSS_MODE || |
| 7022 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 7023 | adapter->device_mode == QDF_SAP_MODE || |
| 7024 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7025 | hdd_unregister_wext(adapter->dev); |
| 7026 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7027 | } |
| 7028 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7029 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7030 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7031 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7032 | } |
| 7033 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7034 | 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] | 7035 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7036 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7037 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7038 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7039 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7040 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7041 | if (adapter->device_mode == QDF_STA_MODE || |
| 7042 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 7043 | adapter->device_mode == QDF_IBSS_MODE || |
| 7044 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 7045 | adapter->device_mode == QDF_SAP_MODE || |
| 7046 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7047 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 7048 | adapter->vdev_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 7049 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7050 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7051 | } |
| 7052 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7053 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7054 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7055 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7056 | } |
| 7057 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7058 | /** |
| 7059 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 7060 | * adapters |
| 7061 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 7062 | * |
| 7063 | * return: QDF_STATUS_SUCCESS |
| 7064 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7065 | 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] | 7066 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7067 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7068 | int err; |
| 7069 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7070 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7071 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7072 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7073 | if (adapter->device_mode == QDF_STA_MODE || |
| 7074 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 7075 | adapter->device_mode == QDF_IBSS_MODE || |
| 7076 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 7077 | adapter->device_mode == QDF_SAP_MODE || |
| 7078 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7079 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 7080 | if (err) |
| 7081 | hdd_err("Unable to stop scheduled scan"); |
| 7082 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7083 | } |
| 7084 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7085 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7086 | |
| 7087 | return QDF_STATUS_SUCCESS; |
| 7088 | } |
| 7089 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7090 | #ifdef WLAN_NS_OFFLOAD |
| 7091 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7092 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7093 | * @hdd_ctx: Pointer to hdd context |
| 7094 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7095 | * Unregister for IPv6 address change notifications. |
| 7096 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7097 | * Return: None |
| 7098 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7099 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7100 | { |
| 7101 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7102 | } |
| 7103 | |
| 7104 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7105 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7106 | * @hdd_ctx: Pointer to hdd context |
| 7107 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7108 | * Register for IPv6 address change notifications. |
| 7109 | * |
| 7110 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7111 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7112 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7113 | { |
| 7114 | int ret; |
| 7115 | |
| 7116 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 7117 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7118 | if (ret) { |
| 7119 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 7120 | goto out; |
| 7121 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7122 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7123 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7124 | out: |
| 7125 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7126 | } |
| 7127 | #else |
| 7128 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7129 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7130 | * @hdd_ctx: Pointer to hdd context |
| 7131 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7132 | * Unregister for IPv6 address change notifications. |
| 7133 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7134 | * Return: None |
| 7135 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7136 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7137 | { |
| 7138 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7139 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7140 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7141 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7142 | * @hdd_ctx: Pointer to hdd context |
| 7143 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7144 | * Register for IPv6 address change notifications. |
| 7145 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7146 | * Return: None |
| 7147 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7148 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7149 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7150 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7151 | } |
| 7152 | #endif |
| 7153 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7154 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 7155 | { |
| 7156 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 7157 | adapter->disconnection_in_progress = status; |
| 7158 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 7159 | hdd_debug("setting disconnection status: %d", status); |
| 7160 | } |
| 7161 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7162 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7163 | * hdd_register_notifiers - Register netdev notifiers. |
| 7164 | * @hdd_ctx: HDD context |
| 7165 | * |
| 7166 | * Register netdev notifiers like IPv4 and IPv6. |
| 7167 | * |
| 7168 | * Return: 0 on success and errno on failure |
| 7169 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7170 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7171 | { |
| 7172 | int ret; |
| 7173 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7174 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 7175 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7176 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7177 | |
| 7178 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 7179 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 7180 | if (ret) { |
| 7181 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 7182 | goto unregister_ip6_notifier; |
| 7183 | } |
| 7184 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7185 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 7186 | if (ret) { |
| 7187 | hdd_err("Failed to register netevent notifier: %d", |
| 7188 | ret); |
| 7189 | goto unregister_inetaddr_notifier; |
| 7190 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7191 | return 0; |
| 7192 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7193 | unregister_inetaddr_notifier: |
| 7194 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7195 | unregister_ip6_notifier: |
| 7196 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7197 | out: |
| 7198 | return ret; |
| 7199 | |
| 7200 | } |
| 7201 | |
| 7202 | /** |
| 7203 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 7204 | * @hdd_ctx: HDD context |
| 7205 | * |
| 7206 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 7207 | * |
| 7208 | * Return: None. |
| 7209 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7210 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7211 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7212 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7213 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 7214 | |
| 7215 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7216 | } |
| 7217 | |
| 7218 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7219 | * hdd_exit_netlink_services - Exit netlink services |
| 7220 | * @hdd_ctx: HDD context |
| 7221 | * |
| 7222 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7223 | * nl service. |
| 7224 | * |
| 7225 | * Return: None. |
| 7226 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7227 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7228 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7229 | spectral_scan_deactivate_service(); |
| 7230 | cnss_diag_deactivate_service(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7231 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7232 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7233 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7234 | |
| 7235 | nl_srv_exit(); |
| 7236 | } |
| 7237 | |
| 7238 | /** |
| 7239 | * hdd_init_netlink_services- Init netlink services |
| 7240 | * @hdd_ctx: HDD context |
| 7241 | * |
| 7242 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7243 | * nl service. |
| 7244 | * |
| 7245 | * Return: 0 on success and errno on failure. |
| 7246 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7247 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7248 | { |
| 7249 | int ret; |
| 7250 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7251 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7252 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7253 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7254 | goto out; |
| 7255 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7256 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7257 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 7258 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7259 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7260 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7261 | goto err_nl_srv; |
| 7262 | } |
| 7263 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7264 | ptt_sock_activate_svc(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7265 | |
| 7266 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 7267 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7268 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7269 | |
| 7270 | ret = cnss_diag_activate_service(); |
| 7271 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7272 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7273 | goto err_close_cesium; |
| 7274 | } |
| 7275 | |
Dustin Brown | 0152085 | 2019-02-27 12:14:16 -0800 | [diff] [blame] | 7276 | spectral_scan_activate_service(hdd_ctx); |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 7277 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7278 | return 0; |
| 7279 | |
| 7280 | err_close_cesium: |
| 7281 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7282 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7283 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7284 | err_nl_srv: |
| 7285 | nl_srv_exit(); |
| 7286 | out: |
| 7287 | return ret; |
| 7288 | } |
| 7289 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7290 | /** |
| 7291 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 7292 | * @hdd_ctx: HDD context. |
| 7293 | * |
| 7294 | * Destroy RX wakelock. |
| 7295 | * |
| 7296 | * Return: None. |
| 7297 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7298 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7299 | { |
| 7300 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 7301 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7302 | |
| 7303 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7304 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 7305 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7306 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7307 | * Create RX wakelock. |
| 7308 | * |
| 7309 | * Return: None. |
| 7310 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7311 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7312 | { |
| 7313 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 7314 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7315 | |
| 7316 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7317 | * hdd_context_deinit() - Deinitialize HDD context |
| 7318 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7319 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7320 | * Deinitialize HDD context along with all the feature specific contexts but |
| 7321 | * do not free hdd context itself. Caller of this API is supposed to free |
| 7322 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7323 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7324 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7325 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7326 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7327 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7328 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 7329 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7330 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7331 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7332 | hdd_sap_context_destroy(hdd_ctx); |
| 7333 | |
| 7334 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 7335 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7336 | hdd_scan_context_destroy(hdd_ctx); |
| 7337 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 7338 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7339 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7340 | return 0; |
| 7341 | } |
| 7342 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7343 | void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7344 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 7345 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 7346 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7347 | hdd_exit_netlink_services(hdd_ctx); |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 7348 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 7349 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7350 | hdd_context_deinit(hdd_ctx); |
| 7351 | |
Dustin Brown | db2df2e | 2018-10-31 15:29:24 -0700 | [diff] [blame] | 7352 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 7353 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7354 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7355 | hdd_ctx->config = NULL; |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 7356 | cfg_release(); |
| 7357 | |
Min Liu | 4710404 | 2019-04-09 17:49:21 +0800 | [diff] [blame] | 7358 | qdf_delayed_work_destroy(&hdd_ctx->psoc_idle_timeout_work); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7359 | wiphy_free(hdd_ctx->wiphy); |
| 7360 | } |
| 7361 | |
| 7362 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7363 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 7364 | * |
| 7365 | * This function is used to destroy bug report lock |
| 7366 | * |
| 7367 | * Return: None |
| 7368 | */ |
| 7369 | static void wlan_destroy_bug_report_lock(void) |
| 7370 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 7371 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7372 | |
| 7373 | p_cds_context = cds_get_global_context(); |
| 7374 | if (!p_cds_context) { |
| 7375 | hdd_err("cds context is NULL"); |
| 7376 | return; |
| 7377 | } |
| 7378 | |
| 7379 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 7380 | } |
| 7381 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7382 | #ifdef DISABLE_CHANNEL_LIST |
| 7383 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7384 | { |
| 7385 | qdf_mutex_destroy(&hdd_ctx->cache_channel_lock); |
| 7386 | } |
| 7387 | #else |
| 7388 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7389 | { |
| 7390 | } |
| 7391 | #endif |
| 7392 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 7393 | void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7394 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7395 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7396 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7397 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7398 | |
Arun Kumar Khandavalli | deda5a8 | 2019-03-11 15:32:19 +0530 | [diff] [blame] | 7399 | hdd_debugfs_mws_coex_info_deinit(hdd_ctx); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 7400 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Dustin Brown | 6470aba | 2018-09-05 09:49:58 -0700 | [diff] [blame] | 7401 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7402 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7403 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7404 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7405 | if (QDF_TIMER_STATE_RUNNING == |
| 7406 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 7407 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7408 | } |
| 7409 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7410 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7411 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 7412 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7413 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7414 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7415 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7416 | hdd_ctx->last_acs_channel_list = NULL; |
| 7417 | hdd_ctx->num_of_channels = 0; |
| 7418 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7419 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7420 | |
| 7421 | /* |
| 7422 | * Powersave Offload Case |
| 7423 | * Disable Idle Power Save Mode |
| 7424 | */ |
| 7425 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 7426 | /* clear the scan queue in all the scenarios */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7427 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7428 | |
Dustin Brown | f688ea1 | 2019-03-19 17:02:32 -0700 | [diff] [blame] | 7429 | if (hdd_ctx->driver_status != DRIVER_MODULES_CLOSED) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7430 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 7431 | /* |
| 7432 | * Cancel any outstanding scan requests. We are about to close |
| 7433 | * all of our adapters, but an adapter structure is what SME |
| 7434 | * passes back to our callback function. Hence if there |
| 7435 | * are any outstanding scan requests then there is a |
| 7436 | * race condition between when the adapter is closed and |
| 7437 | * when the callback is invoked. We try to resolve that |
| 7438 | * race condition here by canceling any outstanding scans |
| 7439 | * before we close the adapters. |
| 7440 | * Note that the scans may be cancelled in an asynchronous |
| 7441 | * manner, so ideally there needs to be some kind of |
| 7442 | * synchronization. Rather than introduce a new |
| 7443 | * synchronization here, we will utilize the fact that we are |
| 7444 | * about to Request Full Power, and since that is synchronized, |
| 7445 | * the expectation is that by the time Request Full Power has |
| 7446 | * completed, all scans will be cancelled |
| 7447 | */ |
| 7448 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7449 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 7450 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 7451 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7452 | } |
| 7453 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7454 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 7455 | |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 7456 | qdf_dp_trace_deinit(); |
| 7457 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 7458 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 7459 | |
Visweswara Tanuku | c029a20 | 2018-11-27 10:42:10 +0530 | [diff] [blame] | 7460 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 7461 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 7462 | hdd_driver_memdump_deinit(); |
| 7463 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 7464 | qdf_nbuf_deinit_replenish_timer(); |
| 7465 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7466 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 7467 | hdd_info("Release wakelock for monitor mode!"); |
| 7468 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 7469 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 7470 | } |
| 7471 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7472 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7473 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7474 | wlan_hdd_cache_chann_mutex_destroy(hdd_ctx); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7475 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 7476 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7477 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 7478 | hdd_close_all_adapters(hdd_ctx, false); |
| 7479 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 7480 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7481 | /* |
| 7482 | * If there is re_init failure wiphy would have already de-registered |
| 7483 | * check the wiphy status before un-registering again |
| 7484 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 7485 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7486 | wiphy_unregister(wiphy); |
| 7487 | wlan_hdd_cfg80211_deinit(wiphy); |
| 7488 | hdd_lpass_notify_stop(hdd_ctx); |
| 7489 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 7490 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7491 | hdd_exit_netlink_services(hdd_ctx); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7492 | #ifdef FEATURE_WLAN_CH_AVOID |
| 7493 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 7494 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7495 | } |
| 7496 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7497 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7498 | /** |
| 7499 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7500 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7501 | * |
| 7502 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 7503 | * Then new ACS request will do a fresh scan without reusing the cached |
| 7504 | * scan information. |
| 7505 | * |
| 7506 | * Return: void |
| 7507 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 7508 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7509 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7510 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7511 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7512 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7513 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7514 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7515 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7516 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7517 | hdd_ctx->last_acs_channel_list = NULL; |
| 7518 | hdd_ctx->num_of_channels = 0; |
| 7519 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7520 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7521 | mac_handle = hdd_ctx->mac_handle; |
| 7522 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7523 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7524 | } |
| 7525 | #endif |
| 7526 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7527 | /** |
| 7528 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 7529 | * @state: state |
| 7530 | * |
| 7531 | * This function notifies FW with modem power status |
| 7532 | * |
| 7533 | * Return: 0 if successful, error number otherwise |
| 7534 | */ |
| 7535 | int hdd_wlan_notify_modem_power_state(int state) |
| 7536 | { |
| 7537 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7538 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7539 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7540 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7541 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7542 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7543 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7544 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7545 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7546 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7547 | mac_handle = hdd_ctx->mac_handle; |
| 7548 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7549 | return -EINVAL; |
| 7550 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7551 | qdf_status = sme_notify_modem_power_state(mac_handle, state); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7552 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7553 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7554 | state); |
| 7555 | return -EINVAL; |
| 7556 | } |
| 7557 | return 0; |
| 7558 | } |
| 7559 | |
| 7560 | /** |
| 7561 | * |
| 7562 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 7563 | * @adapter - Pointer to the HDD |
| 7564 | * |
| 7565 | * Return: None |
| 7566 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7567 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7568 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7569 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7570 | |
| 7571 | /* |
| 7572 | * Send ready indication to the HDD. This will kick off the MAC |
| 7573 | * into a 'running' state and should kick off an initial scan. |
| 7574 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7575 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->mac_handle); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7576 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7577 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 7578 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7579 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7580 | } |
| 7581 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7582 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7583 | } |
| 7584 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 7585 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 7586 | { |
| 7587 | struct hdd_adapter *adapter; |
| 7588 | |
| 7589 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7590 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 7591 | return adapter; |
| 7592 | } |
| 7593 | |
| 7594 | return NULL; |
| 7595 | } |
| 7596 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7597 | /* wake lock APIs for HDD */ |
| 7598 | void hdd_prevent_suspend(uint32_t reason) |
| 7599 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7600 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7601 | } |
| 7602 | |
| 7603 | void hdd_allow_suspend(uint32_t reason) |
| 7604 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7605 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7606 | } |
| 7607 | |
| 7608 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 7609 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 7610 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 7611 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7612 | } |
| 7613 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7614 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7615 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7616 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7617 | return sme_init_chan_list(hdd_ctx->mac_handle, |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 7618 | hdd_ctx->reg.alpha2, |
| 7619 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7620 | } |
| 7621 | |
| 7622 | /** |
| 7623 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 7624 | * @hdd_ctx: Pointer to the hdd context |
| 7625 | * |
| 7626 | * HDD function to know if hardware supports 5GHz |
| 7627 | * |
| 7628 | * Return: true if hardware supports 5GHz |
| 7629 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7630 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7631 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7632 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7633 | return true; |
| 7634 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7635 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7636 | return true; |
| 7637 | else |
| 7638 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7639 | } |
| 7640 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7641 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7642 | { |
| 7643 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7644 | int ret_val; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7645 | uint32_t channel_bonding_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7646 | |
| 7647 | wiphy = hdd_ctx->wiphy; |
| 7648 | |
| 7649 | /* |
| 7650 | * The channel information in |
| 7651 | * wiphy needs to be initialized before wiphy registration |
| 7652 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7653 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7654 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7655 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7656 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7657 | } |
| 7658 | |
| 7659 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7660 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7661 | #else |
| 7662 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7663 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7664 | WIPHY_WOWLAN_DISCONNECT | |
| 7665 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7666 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7667 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7668 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7669 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7670 | |
| 7671 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7672 | WOW_MAX_FILTERS_PER_LIST); |
| 7673 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7674 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7675 | #endif |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7676 | ucfg_mlme_get_channel_bonding_24ghz(hdd_ctx->psoc, |
| 7677 | &channel_bonding_mode); |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7678 | if (hdd_ctx->obss_scan_offload) { |
| 7679 | hdd_debug("wmi_service_obss_scan supported"); |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7680 | } else if (channel_bonding_mode) { |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7681 | hdd_debug("enable wpa_supp obss_scan"); |
| 7682 | wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; |
| 7683 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7684 | |
| 7685 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7686 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7687 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7688 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7689 | return ret_val; |
| 7690 | } |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7691 | |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7692 | /* Check the kernel version for upstream commit aced43ce780dc5 that |
| 7693 | * has support for processing user cell_base hints when wiphy is |
| 7694 | * self managed or check the backport flag for the same. |
| 7695 | */ |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7696 | #if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \ |
| 7697 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7698 | hdd_send_wiphy_regd_sync_event(hdd_ctx); |
| 7699 | #endif |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7700 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7701 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7702 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7703 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7704 | } |
| 7705 | |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 7706 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7707 | /** |
| 7708 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7709 | * @hdd_ctx - handle to hdd context |
| 7710 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7711 | * |
| 7712 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7713 | * Stats show up in wlan driver logs. |
| 7714 | * |
| 7715 | * Returns: None |
| 7716 | */ |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7717 | static void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7718 | bool data_in_interval) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7719 | { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7720 | static uint32_t counter; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7721 | static bool data_in_time_period; |
| 7722 | ol_txrx_pdev_handle pdev; |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7723 | ol_txrx_soc_handle soc; |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7724 | uint32_t periodic_stats_disp_time = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7725 | |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7726 | ucfg_mlme_stats_get_periodic_display_time(hdd_ctx->psoc, |
| 7727 | &periodic_stats_disp_time); |
| 7728 | if (!periodic_stats_disp_time) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7729 | return; |
| 7730 | |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7731 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 7732 | if (!soc) { |
| 7733 | hdd_err("soc is NULL"); |
| 7734 | return; |
| 7735 | } |
| 7736 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7737 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7738 | if (!pdev) { |
| 7739 | hdd_err("pdev is NULL"); |
| 7740 | return; |
| 7741 | } |
| 7742 | |
| 7743 | counter++; |
| 7744 | if (data_in_interval) |
| 7745 | data_in_time_period = data_in_interval; |
| 7746 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7747 | if (counter * hdd_ctx->config->bus_bw_compute_interval >= |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7748 | periodic_stats_disp_time * 1000) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7749 | if (data_in_time_period) { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7750 | wlan_hdd_display_txrx_stats(hdd_ctx); |
Mohit Khanna | c964965 | 2018-11-28 18:10:28 -0800 | [diff] [blame] | 7751 | dp_txrx_ext_dump_stats(soc, CDP_DP_RX_THREAD_STATS); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7752 | cdp_display_stats(soc, |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7753 | CDP_RX_RING_STATS, |
| 7754 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7755 | cdp_display_stats(soc, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7756 | CDP_TXRX_PATH_STATS, |
| 7757 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7758 | wlan_hdd_display_netif_queue_history |
| 7759 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7760 | qdf_dp_trace_dump_stats(); |
| 7761 | } |
| 7762 | counter = 0; |
| 7763 | data_in_time_period = false; |
| 7764 | } |
| 7765 | } |
| 7766 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7767 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7768 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7769 | * @hdd_ctx: pointer to struct hdd_context |
| 7770 | * |
| 7771 | * Return: none |
| 7772 | */ |
| 7773 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7774 | { |
| 7775 | struct hdd_adapter *adapter; |
| 7776 | |
| 7777 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7778 | hdd_send_rps_disable_ind(adapter); |
| 7779 | } |
| 7780 | |
| 7781 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7782 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7783 | * @hdd_ctx - handle to hdd context |
| 7784 | * @tx_packets - transmit packet count |
| 7785 | * @rx_packets - receive packet count |
| 7786 | * |
| 7787 | * The function controls the bus bandwidth and dynamic control of |
| 7788 | * tcp delayed ack configuration |
| 7789 | * |
| 7790 | * Returns: None |
| 7791 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7792 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7793 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7794 | const uint64_t tx_packets, |
| 7795 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7796 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7797 | u64 total_pkts = tx_packets + rx_packets; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7798 | uint64_t temp_tx = 0, avg_rx = 0; |
| 7799 | uint64_t no_rx_offload_pkts = 0, avg_no_rx_offload_pkts = 0; |
| 7800 | uint64_t rx_offload_pkts = 0, avg_rx_offload_pkts = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7801 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7802 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7803 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7804 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7805 | uint16_t index = 0; |
| 7806 | bool vote_level_change = false; |
| 7807 | bool rx_level_change = false; |
| 7808 | bool tx_level_change = false; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7809 | bool rxthread_high_tput_req = false; |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7810 | bool dptrace_high_tput_req; |
Srinivas Girigowda | 5033534 | 2018-09-07 15:21:01 -0700 | [diff] [blame] | 7811 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7812 | if (total_pkts > hdd_ctx->config->bus_bw_high_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7813 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7814 | else if (total_pkts > hdd_ctx->config->bus_bw_medium_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7815 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7816 | else if (total_pkts > hdd_ctx->config->bus_bw_low_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7817 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7818 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7819 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7820 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7821 | dptrace_high_tput_req = |
| 7822 | next_vote_level > PLD_BUS_WIDTH_NONE ? true : false; |
| 7823 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7824 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7825 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7826 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7827 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7828 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7829 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7830 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7831 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7832 | if (hdd_ctx->hbw_requested) { |
| 7833 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7834 | hdd_ctx->hbw_requested = false; |
| 7835 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7836 | if (hdd_ctx->dynamic_rps) |
| 7837 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7838 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7839 | if (!hdd_ctx->hbw_requested) { |
| 7840 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7841 | hdd_ctx->hbw_requested = true; |
| 7842 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7843 | if (hdd_ctx->dynamic_rps) |
| 7844 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7845 | } |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7846 | |
Manjunathappa Prakash | cb6df76 | 2018-05-29 18:54:58 -0700 | [diff] [blame] | 7847 | if (hdd_ctx->config->napi_cpu_affinity_mask) |
| 7848 | hdd_napi_apply_throughput_policy(hdd_ctx, |
| 7849 | tx_packets, |
| 7850 | rx_packets); |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7851 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7852 | if (rx_packets < hdd_ctx->config->bus_bw_low_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7853 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
| 7854 | else |
| 7855 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7856 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7857 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7858 | qdf_dp_trace_apply_tput_policy(dptrace_high_tput_req); |
| 7859 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7860 | /* |
| 7861 | * Includes tcp+udp, if perf core is required for tcp, then |
| 7862 | * perf core is also required for udp. |
| 7863 | */ |
| 7864 | no_rx_offload_pkts = hdd_ctx->no_rx_offload_pkt_cnt; |
| 7865 | hdd_ctx->no_rx_offload_pkt_cnt = 0; |
| 7866 | rx_offload_pkts = rx_packets - no_rx_offload_pkts; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7867 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7868 | avg_no_rx_offload_pkts = (no_rx_offload_pkts + |
| 7869 | hdd_ctx->prev_no_rx_offload_pkts) / 2; |
| 7870 | hdd_ctx->prev_no_rx_offload_pkts = no_rx_offload_pkts; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7871 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7872 | avg_rx_offload_pkts = (rx_offload_pkts + |
| 7873 | hdd_ctx->prev_rx_offload_pkts) / 2; |
| 7874 | hdd_ctx->prev_rx_offload_pkts = rx_offload_pkts; |
| 7875 | |
| 7876 | avg_rx = avg_no_rx_offload_pkts + avg_rx_offload_pkts; |
| 7877 | /* |
| 7878 | * Takes care to set Rx_thread affinity for below case |
| 7879 | * 1)LRO/GRO not supported ROME case |
| 7880 | * 2)when rx_ol is disabled in cases like concurrency etc |
| 7881 | * 3)For UDP cases |
| 7882 | */ |
| 7883 | if (avg_no_rx_offload_pkts > |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7884 | hdd_ctx->config->bus_bw_high_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7885 | rxthread_high_tput_req = true; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7886 | else |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7887 | rxthread_high_tput_req = false; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7888 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7889 | if (cds_sched_handle_throughput_req(rxthread_high_tput_req)) |
| 7890 | hdd_warn("Rx thread high_tput(%d) affinity request failed", |
| 7891 | rxthread_high_tput_req); |
| 7892 | |
| 7893 | /* fine-tuning parameters for RX Flows */ |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7894 | if (avg_rx > hdd_ctx->config->tcp_delack_thres_high) { |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7895 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7896 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7897 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7898 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7899 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7900 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7901 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7902 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7903 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7904 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7905 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7906 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7907 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Jeff Johnson | b9feee4 | 2018-07-08 10:34:48 -0700 | [diff] [blame] | 7908 | next_rx_level, avg_rx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7909 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7910 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7911 | /* Send throughput indication only if it is enabled. |
| 7912 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7913 | * to default delayed ack. Note that this will disable the |
| 7914 | * dynamic delayed ack mechanism across the system |
| 7915 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7916 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7917 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7918 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7919 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7920 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7921 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7922 | rx_tp_data.level = next_rx_level; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7923 | wlan_hdd_update_tcp_rx_param(hdd_ctx, &rx_tp_data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7924 | } |
| 7925 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7926 | /* fine-tuning parameters for TX Flows */ |
| 7927 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7928 | hdd_ctx->prev_tx = tx_packets; |
| 7929 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7930 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7931 | else |
| 7932 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7933 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7934 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7935 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7936 | struct wlan_tx_tp_data tx_tp_data = {0}; |
| 7937 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7938 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7939 | next_tx_level, temp_tx); |
| 7940 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7941 | tx_level_change = true; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7942 | tx_tp_data.level = next_tx_level; |
| 7943 | tx_tp_data.tcp_limit_output = true; |
| 7944 | wlan_hdd_update_tcp_tx_param(hdd_ctx, &tx_tp_data); |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7945 | } |
| 7946 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7947 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7948 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7949 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7950 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7951 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7952 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7953 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7954 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7955 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7956 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7957 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7958 | |
| 7959 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7960 | } |
| 7961 | |
| 7962 | #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] | 7963 | static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7964 | { |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7965 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7966 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7967 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7968 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7969 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7970 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7971 | bool connected = false; |
| 7972 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7973 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7974 | if (wlan_hdd_validate_context(hdd_ctx)) |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7975 | goto stop_work; |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7976 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7977 | if (hdd_ctx->is_wiphy_suspended) |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7978 | return; |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7979 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7980 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7981 | /* |
| 7982 | * Validate magic so we don't end up accessing |
| 7983 | * an invalid adapter. |
| 7984 | */ |
| 7985 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7986 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7987 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7988 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7989 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 7990 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.conn_state |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7991 | != eConnectionState_Associated) { |
| 7992 | |
| 7993 | continue; |
| 7994 | } |
| 7995 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7996 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7997 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7998 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7999 | |
| 8000 | continue; |
| 8001 | } |
| 8002 | |
| 8003 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 8004 | adapter->prev_tx_packets); |
| 8005 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 8006 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 8007 | |
| 8008 | if (adapter->device_mode == QDF_SAP_MODE || |
| 8009 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 8010 | adapter->device_mode == QDF_IBSS_MODE) { |
| 8011 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 8012 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 8013 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8014 | adapter->vdev_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 8015 | &fwd_tx_packets, &fwd_rx_packets); |
| 8016 | if (ret == A_OK) { |
| 8017 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 8018 | fwd_tx_packets, |
| 8019 | adapter->prev_fwd_tx_packets); |
| 8020 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 8021 | fwd_tx_packets, |
| 8022 | adapter->prev_fwd_rx_packets); |
| 8023 | } |
| 8024 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8025 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 8026 | if (adapter->device_mode == QDF_SAP_MODE) |
| 8027 | con_sap_adapter = adapter; |
| 8028 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8029 | total_rx += adapter->stats.rx_packets; |
| 8030 | total_tx += adapter->stats.tx_packets; |
| 8031 | |
| 8032 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 8033 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 8034 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 8035 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 8036 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8037 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 8038 | connected = true; |
| 8039 | } |
| 8040 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8041 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 8042 | hdd_err("bus bandwidth timer running in disconnected state"); |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8043 | goto stop_work; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8044 | } |
| 8045 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 8046 | /* add intra bss forwarded tx and rx packets */ |
| 8047 | tx_packets += fwd_tx_packets_diff; |
| 8048 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8049 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8050 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->pdev)) { |
| 8051 | ucfg_ipa_uc_stat_query(hdd_ctx->pdev, &ipa_tx_packets, |
| 8052 | &ipa_rx_packets); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 8053 | tx_packets += (uint64_t)ipa_tx_packets; |
| 8054 | rx_packets += (uint64_t)ipa_rx_packets; |
| 8055 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 8056 | if (con_sap_adapter) { |
| 8057 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 8058 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 8059 | } |
| 8060 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8061 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, tx_packets, rx_packets); |
| 8062 | ucfg_ipa_uc_stat_request(hdd_ctx->pdev, 2); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 8063 | } |
| 8064 | |
| 8065 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8066 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8067 | return; |
| 8068 | |
| 8069 | stop_work: |
| 8070 | qdf_periodic_work_stop_async(&hdd_ctx->bus_bw_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8071 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8072 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8073 | static void hdd_bus_bw_work_handler(void *context) |
Rajeev Kumar | b2b5e69 | 2018-08-31 15:12:40 -0700 | [diff] [blame] | 8074 | { |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 8075 | struct hdd_context *hdd_ctx = context; |
| 8076 | struct qdf_op_sync *op_sync; |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8077 | |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 8078 | if (qdf_op_protect(&op_sync)) |
| 8079 | return; |
| 8080 | |
| 8081 | __hdd_bus_bw_work_handler(hdd_ctx); |
| 8082 | |
| 8083 | qdf_op_unprotect(op_sync); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 8084 | } |
| 8085 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8086 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8087 | { |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8088 | QDF_STATUS status; |
| 8089 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8090 | hdd_enter(); |
| 8091 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8092 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8093 | status = qdf_periodic_work_create(&hdd_ctx->bus_bw_work, |
| 8094 | hdd_bus_bw_work_handler, |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 8095 | hdd_ctx); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8096 | |
| 8097 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8098 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8099 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8100 | } |
| 8101 | |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 8102 | void hdd_bus_bandwidth_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8103 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8104 | hdd_enter(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8105 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8106 | QDF_BUG(!qdf_periodic_work_stop_sync(&hdd_ctx->bus_bw_work)); |
| 8107 | qdf_periodic_work_destroy(&hdd_ctx->bus_bw_work); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8108 | |
| 8109 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8110 | } |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 8111 | #endif /*WLAN_FEATURE_DP_BUS_BANDWIDTH*/ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8112 | |
| 8113 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8114 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 8115 | * @hdd_ctx: hdd context |
| 8116 | * |
| 8117 | * Return: 0 for success or error code |
| 8118 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8119 | 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] | 8120 | { |
| 8121 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 8122 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8123 | if (!hdd_ctx->hdd_txrx_hist) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8124 | return -ENOMEM; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8125 | return 0; |
| 8126 | } |
| 8127 | |
| 8128 | /** |
| 8129 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 8130 | * @hdd_ctx: hdd context |
| 8131 | * |
| 8132 | * Return: none |
| 8133 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8134 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8135 | { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 8136 | if (!hdd_ctx || !hdd_ctx->hdd_txrx_hist) |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 8137 | return; |
| 8138 | |
| 8139 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 8140 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8141 | } |
| 8142 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8143 | static uint8_t *convert_level_to_string(uint32_t level) |
| 8144 | { |
| 8145 | switch (level) { |
| 8146 | /* initialize the wlan sub system */ |
| 8147 | case WLAN_SVC_TP_NONE: |
| 8148 | return "NONE"; |
| 8149 | case WLAN_SVC_TP_LOW: |
| 8150 | return "LOW"; |
| 8151 | case WLAN_SVC_TP_MEDIUM: |
| 8152 | return "MED"; |
| 8153 | case WLAN_SVC_TP_HIGH: |
| 8154 | return "HIGH"; |
| 8155 | default: |
| 8156 | return "INVAL"; |
| 8157 | } |
| 8158 | } |
| 8159 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8160 | |
| 8161 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8162 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 8163 | * @hdd_ctx: hdd context |
| 8164 | * |
| 8165 | * Return: none |
| 8166 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8167 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8168 | { |
| 8169 | int i; |
| 8170 | |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 8171 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8172 | hdd_nofl_info("BW compute Interval: %dms", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8173 | hdd_ctx->config->bus_bw_compute_interval); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8174 | 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] | 8175 | hdd_ctx->config->bus_bw_high_threshold, |
| 8176 | hdd_ctx->config->bus_bw_medium_threshold, |
| 8177 | hdd_ctx->config->bus_bw_low_threshold); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8178 | hdd_nofl_info("Enable TCP DEL ACK: %d", |
| 8179 | hdd_ctx->en_tcp_delack_no_lro); |
| 8180 | hdd_nofl_info("TCP DEL High TH: %d TCP DEL Low TH: %d", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8181 | hdd_ctx->config->tcp_delack_thres_high, |
| 8182 | hdd_ctx->config->tcp_delack_thres_low); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8183 | hdd_nofl_info("TCP TX HIGH TP TH: %d (Use to set tcp_output_bytes_limit)", |
| 8184 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 8185 | #endif /*WLAN_FEATURE_DP_BUS_BANDWIDTH*/ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8186 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8187 | hdd_nofl_info("Total entries: %d Current index: %d", |
| 8188 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8189 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8190 | 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] | 8191 | |
| 8192 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8193 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 8194 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8195 | hdd_nofl_info("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 8196 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 8197 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 8198 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 8199 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8200 | hdd_ctx->hdd_txrx_hist[i]. |
| 8201 | next_vote_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8202 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8203 | hdd_ctx->hdd_txrx_hist[i]. |
| 8204 | next_rx_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8205 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8206 | hdd_ctx->hdd_txrx_hist[i]. |
| 8207 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8208 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8209 | } |
| 8210 | |
| 8211 | /** |
| 8212 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 8213 | * @hdd_ctx: hdd context |
| 8214 | * |
| 8215 | * Return: none |
| 8216 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8217 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8218 | { |
| 8219 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8220 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 8221 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8222 | } |
| 8223 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8224 | /* length of the netif queue log needed per adapter */ |
| 8225 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 8226 | |
| 8227 | /** |
| 8228 | * |
| 8229 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 8230 | * @hdd_ctx: hdd context |
| 8231 | * |
| 8232 | * Return: none |
| 8233 | */ |
| 8234 | static void |
| 8235 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 8236 | { |
| 8237 | int adapter_num = 0; |
| 8238 | int i; |
| 8239 | int bytes_written; |
| 8240 | u32 tbytes; |
| 8241 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8242 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8243 | char *comb_log_str; |
| 8244 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8245 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8246 | |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 8247 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * WLAN_MAX_VDEVS) + 1; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8248 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8249 | if (!comb_log_str) |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8250 | return; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8251 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8252 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8253 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8254 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8255 | curr_time = qdf_system_ticks(); |
| 8256 | total = curr_time - adapter->start_time; |
| 8257 | delta = curr_time - adapter->last_time; |
| 8258 | |
| 8259 | if (adapter->pause_map) { |
| 8260 | pause = adapter->total_pause_time + delta; |
| 8261 | unpause = adapter->total_unpause_time; |
| 8262 | } else { |
| 8263 | unpause = adapter->total_unpause_time + delta; |
| 8264 | pause = adapter->total_pause_time; |
| 8265 | } |
| 8266 | |
| 8267 | tbytes = 0; |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 8268 | qdf_mem_zero(temp_str, sizeof(temp_str)); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8269 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8270 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 8271 | continue; |
| 8272 | tbytes += |
| 8273 | snprintf( |
| 8274 | &temp_str[tbytes], |
| 8275 | (tbytes >= sizeof(temp_str) ? |
| 8276 | 0 : sizeof(temp_str) - tbytes), |
| 8277 | "%d(%d,%d) ", |
| 8278 | i, |
| 8279 | adapter->queue_oper_stats[i]. |
| 8280 | pause_count, |
| 8281 | adapter->queue_oper_stats[i]. |
| 8282 | unpause_count); |
| 8283 | } |
| 8284 | if (tbytes >= sizeof(temp_str)) |
| 8285 | hdd_warn("log truncated"); |
| 8286 | |
| 8287 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8288 | bytes_written >= comb_log_str_size ? 0 : |
| 8289 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8290 | "[%d %d] (%d) %u/%ums %s|", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8291 | adapter->vdev_id, adapter->device_mode, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8292 | adapter->pause_map, |
| 8293 | qdf_system_ticks_to_msecs(pause), |
| 8294 | qdf_system_ticks_to_msecs(total), |
| 8295 | temp_str); |
| 8296 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8297 | adapter_num++; |
| 8298 | } |
| 8299 | |
| 8300 | /* using QDF_TRACE to avoid printing function name */ |
| 8301 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 8302 | "STATS |%s", comb_log_str); |
| 8303 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8304 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8305 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8306 | |
| 8307 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8308 | } |
| 8309 | |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8310 | /* Max size of a single netdev tx queue state string. e.g. "1: 0x1" */ |
| 8311 | #define HDD_NETDEV_TX_Q_STATE_STRLEN 15 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8312 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 8313 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 8314 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8315 | * |
| 8316 | * Return: none |
| 8317 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8318 | void |
| 8319 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 8320 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8321 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8322 | int i; |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8323 | struct hdd_adapter *adapter = NULL; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8324 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8325 | struct hdd_netif_queue_history *q_hist_ptr; |
| 8326 | 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] | 8327 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8328 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 8329 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 8330 | return; |
| 8331 | } |
| 8332 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8333 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8334 | if (adapter->vdev_id == CDP_INVALID_VDEV_ID) |
| 8335 | continue; |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8336 | hdd_nofl_info("Netif queue operation statistics:"); |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 8337 | hdd_nofl_info("vdev_id %d device mode %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8338 | adapter->vdev_id, adapter->device_mode); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8339 | hdd_nofl_info("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8340 | curr_time = qdf_system_ticks(); |
| 8341 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8342 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8343 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8344 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8345 | unpause = adapter->total_unpause_time; |
| 8346 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8347 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8348 | pause = adapter->total_pause_time; |
| 8349 | } |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8350 | hdd_nofl_info("Total: %ums Pause: %ums Unpause: %ums", |
| 8351 | qdf_system_ticks_to_msecs(total), |
| 8352 | qdf_system_ticks_to_msecs(pause), |
| 8353 | qdf_system_ticks_to_msecs(unpause)); |
| 8354 | hdd_nofl_info("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8355 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8356 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8357 | qdf_time_t pause_delta = 0; |
| 8358 | |
| 8359 | if (adapter->pause_map & (1 << i)) |
| 8360 | pause_delta = delta; |
| 8361 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8362 | /* using hdd_log to avoid printing function name */ |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8363 | hdd_nofl_info("%s: %d: %d: %ums", |
| 8364 | hdd_reason_type_to_string(i), |
| 8365 | adapter->queue_oper_stats[i].pause_count, |
| 8366 | adapter->queue_oper_stats[i]. |
| 8367 | unpause_count, |
| 8368 | qdf_system_ticks_to_msecs( |
| 8369 | adapter->queue_oper_stats[i]. |
| 8370 | total_pause_time + pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8371 | } |
| 8372 | |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8373 | 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] | 8374 | WLAN_HDD_MAX_HISTORY_ENTRY, |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8375 | adapter->history_index, |
| 8376 | qdf_system_ticks_to_msecs(qdf_system_ticks())); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8377 | |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8378 | hdd_nofl_info("%2s%20s%50s%30s%10s %s", |
| 8379 | "#", "time(ms)", "action_type", "reason_type", |
| 8380 | "pause_map", "netdev-queue-status"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8381 | |
| 8382 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8383 | /* using hdd_log to avoid printing function name */ |
| 8384 | if (adapter->queue_oper_history[i].time == 0) |
| 8385 | continue; |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8386 | q_hist_ptr = &adapter->queue_oper_history[i]; |
| 8387 | wlan_hdd_dump_queue_history_state(q_hist_ptr, |
| 8388 | q_status_buf, |
| 8389 | sizeof(q_status_buf)); |
| 8390 | hdd_nofl_info("%2d%20u%50s%30s%10x %s", |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8391 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8392 | adapter->queue_oper_history[i].time), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8393 | hdd_action_type_to_string( |
| 8394 | adapter->queue_oper_history[i]. |
| 8395 | netif_action), |
| 8396 | hdd_reason_type_to_string( |
| 8397 | adapter->queue_oper_history[i]. |
| 8398 | netif_reason), |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8399 | adapter->queue_oper_history[i].pause_map, |
| 8400 | q_status_buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8401 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8402 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8403 | } |
| 8404 | |
| 8405 | /** |
| 8406 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 8407 | * @hdd_ctx: hdd context |
| 8408 | * |
| 8409 | * Return: none |
| 8410 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8411 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8412 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8413 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8414 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8415 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8416 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8417 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8418 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8419 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8420 | adapter->history_index = 0; |
| 8421 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 8422 | adapter->total_pause_time = 0; |
| 8423 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8424 | } |
| 8425 | } |
| 8426 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8427 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 8428 | /** |
| 8429 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 8430 | * @hdd_ctx: hdd global context |
| 8431 | * |
| 8432 | * Return: none |
| 8433 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8434 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8435 | { |
| 8436 | uint8_t i; |
| 8437 | |
| 8438 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 8439 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 8440 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 8441 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 8442 | } |
| 8443 | } |
| 8444 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8445 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8446 | { |
| 8447 | } |
| 8448 | #endif |
| 8449 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8450 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 8451 | /** |
| 8452 | * 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] | 8453 | * @hdd_ctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8454 | * @enable: enable or disable this behaviour |
| 8455 | * |
| 8456 | * Return: int |
| 8457 | */ |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8458 | 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] | 8459 | { |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8460 | struct wow_pulse_mode wow_pulse_set_info; |
| 8461 | QDF_STATUS status; |
| 8462 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8463 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8464 | |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8465 | if (!ucfg_pmo_is_wow_pulse_enabled(hdd_ctx->psoc)) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8466 | return 0; |
| 8467 | |
| 8468 | /* prepare the request to send to SME */ |
| 8469 | if (enable == true) { |
| 8470 | wow_pulse_set_info.wow_pulse_enable = true; |
| 8471 | wow_pulse_set_info.wow_pulse_pin = |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8472 | ucfg_pmo_get_wow_pulse_pin(hdd_ctx->psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8473 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8474 | wow_pulse_set_info.wow_pulse_interval_high = |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8475 | ucfg_pmo_get_wow_pulse_interval_high(hdd_ctx->psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8476 | |
| 8477 | wow_pulse_set_info.wow_pulse_interval_low = |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8478 | ucfg_pmo_get_wow_pulse_interval_low(hdd_ctx->psoc); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8479 | } else { |
| 8480 | wow_pulse_set_info.wow_pulse_enable = false; |
| 8481 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 8482 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 8483 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 8484 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8485 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8486 | wow_pulse_set_info.wow_pulse_enable, |
| 8487 | wow_pulse_set_info.wow_pulse_pin, |
| 8488 | wow_pulse_set_info.wow_pulse_interval_low, |
| 8489 | wow_pulse_set_info.wow_pulse_interval_high); |
| 8490 | |
| 8491 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 8492 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8493 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8494 | return -EIO; |
| 8495 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8496 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8497 | return 0; |
| 8498 | } |
| 8499 | #else |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8500 | 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] | 8501 | { |
| 8502 | return 0; |
| 8503 | } |
| 8504 | #endif |
| 8505 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8506 | #ifdef WLAN_FEATURE_FASTPATH |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8507 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8508 | /** |
| 8509 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 8510 | * @hdd_cfg: hdd config |
| 8511 | * @context: lower layer context |
| 8512 | * |
| 8513 | * Return: none |
| 8514 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8515 | void hdd_enable_fastpath(struct hdd_context *hdd_ctx, |
| 8516 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8517 | { |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8518 | if (cfg_get(hdd_ctx->psoc, CFG_DP_ENABLE_FASTPATH)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8519 | hif_enable_fastpath(context); |
| 8520 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8521 | #endif |
| 8522 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8523 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8524 | /** |
| 8525 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8526 | * @hdd_handle: opaque handle for the hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8527 | * @level: thermal level |
| 8528 | * |
| 8529 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8530 | * than 0, and restore the original data path when throttle level is 0 |
| 8531 | * |
| 8532 | * Return: none |
| 8533 | */ |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8534 | 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] | 8535 | { |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8536 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8537 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8538 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 8539 | if (level > THROTTLE_LEVEL_0) |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8540 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8541 | else |
| 8542 | /* restore original concurrency mode */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8543 | 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] | 8544 | } |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8545 | #else |
| 8546 | /** |
| 8547 | * hdd_set_thermal_level_cb() - set thermal level callback function |
| 8548 | * @hdd_handle: opaque handle for the hdd context |
| 8549 | * @level: thermal level |
| 8550 | * |
| 8551 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8552 | * than 0, and restore the original data path when throttle level is 0 |
| 8553 | * |
| 8554 | * Return: none |
| 8555 | */ |
| 8556 | static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level) |
| 8557 | { |
| 8558 | } |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8559 | #endif |
| 8560 | |
| 8561 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8562 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8563 | * @adapter: AP adapter |
| 8564 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8565 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8566 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8567 | * Moves the SAP interface by invoking the function which |
| 8568 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8569 | * |
| 8570 | * Return: None |
| 8571 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8572 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8573 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8574 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8575 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8576 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8577 | mac_handle_t mac_handle; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8578 | |
| 8579 | if (!adapter) { |
| 8580 | hdd_err("invalid adapter"); |
| 8581 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8582 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8583 | |
| 8584 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8585 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8586 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 8587 | if (!mac_handle) { |
| 8588 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8589 | return; |
| 8590 | } |
| 8591 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8592 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8593 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8594 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8595 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8596 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8597 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8598 | adapter->vdev_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8599 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8600 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8601 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8602 | 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] | 8603 | { |
| 8604 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8605 | int status; |
| 8606 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8607 | |
| 8608 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8609 | |
| 8610 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8611 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8612 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8613 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8614 | } |
| 8615 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8616 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8617 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8618 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8619 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8620 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8621 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8622 | hdd_err("failed to start external acs timer"); |
| 8623 | return -ENOSPC; |
| 8624 | } |
| 8625 | /* Update config to application */ |
| 8626 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8627 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8628 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8629 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8630 | } |
| 8631 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8632 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8633 | /** |
| 8634 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8635 | * @hdd_ctx: hdd context pointer |
| 8636 | * |
| 8637 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8638 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8639 | * sap. User space on LTE coex indication restart driver. |
| 8640 | * |
| 8641 | * Return - none |
| 8642 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8643 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8644 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8645 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8646 | uint32_t i; |
| 8647 | bool found = false; |
| 8648 | uint8_t restart_chan; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8649 | uint8_t scc_on_lte_coex = 0; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8650 | bool value; |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8651 | QDF_STATUS status; |
| 8652 | bool is_acs_support_for_dfs_ltecoex = cfg_default(CFG_USER_ACS_DFS_LTE); |
| 8653 | bool is_vendor_acs_support = |
| 8654 | cfg_default(CFG_USER_AUTO_CHANNEL_SELECTION); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8655 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8656 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8657 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8658 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8659 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8660 | adapter->device_mode, |
| 8661 | adapter->session.ap.sap_config. |
| 8662 | acs_cfg.acs_mode); |
| 8663 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8664 | } |
| 8665 | |
| 8666 | found = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8667 | status = |
| 8668 | ucfg_policy_mgr_get_sta_sap_scc_lte_coex_chnl(hdd_ctxt->psoc, |
| 8669 | &scc_on_lte_coex); |
| 8670 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8671 | hdd_err("can't get scc on lte coex chnl, use def"); |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8672 | /* |
| 8673 | * If STA+SAP is doing SCC & g_sta_sap_scc_on_lte_coex_chan |
| 8674 | * is set, no need to move SAP. |
| 8675 | */ |
Manikandan Mohan | 956b69e | 2019-02-14 13:08:14 -0800 | [diff] [blame] | 8676 | if ((policy_mgr_is_sta_sap_scc( |
| 8677 | hdd_ctxt->psoc, |
| 8678 | adapter->session.ap.operating_channel) && |
| 8679 | scc_on_lte_coex) || |
| 8680 | policy_mgr_nan_sap_scc_on_unsafe_ch_chk( |
| 8681 | hdd_ctxt->psoc, |
| 8682 | adapter->session.ap.operating_channel)) { |
| 8683 | hdd_debug("SAP allowed in unsafe SCC channel"); |
| 8684 | } else { |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8685 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
| 8686 | if (adapter->session.ap.operating_channel == |
| 8687 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8688 | found = true; |
| 8689 | hdd_debug("operating ch:%d is unsafe", |
| 8690 | adapter->session.ap.operating_channel); |
| 8691 | break; |
| 8692 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8693 | } |
| 8694 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8695 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8696 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8697 | adapter->session.ap.operating_channel); |
| 8698 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8699 | } |
| 8700 | |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8701 | status = ucfg_mlme_get_acs_support_for_dfs_ltecoex( |
| 8702 | hdd_ctxt->psoc, |
| 8703 | &is_acs_support_for_dfs_ltecoex); |
| 8704 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8705 | hdd_err("get_acs_support_for_dfs_ltecoex failed,set def"); |
| 8706 | |
| 8707 | status = ucfg_mlme_get_vendor_acs_support( |
| 8708 | hdd_ctxt->psoc, |
| 8709 | &is_vendor_acs_support); |
| 8710 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8711 | hdd_err("get_vendor_acs_support failed, set default"); |
| 8712 | |
| 8713 | if (is_vendor_acs_support && is_acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8714 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8715 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8716 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8717 | } else |
| 8718 | restart_chan = |
bings | 6c4672b | 2019-03-19 16:00:19 +0800 | [diff] [blame] | 8719 | wlansap_get_safe_channel_from_pcl_and_acs_range( |
| 8720 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8721 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8722 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8723 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8724 | /* |
| 8725 | * SAP restart due to unsafe channel. While |
| 8726 | * restarting the SAP, make sure to clear |
| 8727 | * acs_channel, channel to reset to |
| 8728 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8729 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8730 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8731 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8732 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8733 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8734 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 8735 | ucfg_mlme_get_sap_internal_restart(hdd_ctxt->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8736 | &value); |
| 8737 | hdd_debug("driver to start sap: %d", value); |
| 8738 | if (value) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8739 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8740 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8741 | else |
| 8742 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8743 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8744 | } |
| 8745 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8746 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8747 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8748 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8749 | * @hdd_ctx: HDD global context |
| 8750 | * |
| 8751 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8752 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8753 | * down to the lower layers. Then subscribe to subsequent channel |
| 8754 | * avoidance events. |
| 8755 | * |
| 8756 | * Return: None |
| 8757 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8758 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8759 | { |
| 8760 | uint16_t unsafe_channel_count; |
| 8761 | int index; |
| 8762 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8763 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8764 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8765 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8766 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8767 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8768 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8769 | hdd_ctx->unsafe_channel_count); |
| 8770 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8771 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8772 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8773 | |
| 8774 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8775 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8776 | hdd_ctx->unsafe_channel_list[index]); |
| 8777 | |
| 8778 | } |
| 8779 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8780 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8781 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8782 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8783 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8784 | { |
| 8785 | uint8_t restart_chan; |
| 8786 | |
bings | 6c4672b | 2019-03-19 16:00:19 +0800 | [diff] [blame] | 8787 | restart_chan = wlansap_get_safe_channel_from_pcl_and_acs_range( |
| 8788 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8789 | if (!restart_chan) { |
| 8790 | hdd_alert("fail to restart SAP"); |
| 8791 | return; |
| 8792 | } |
| 8793 | |
| 8794 | /* SAP restart due to unsafe channel. While restarting |
| 8795 | * the SAP, make sure to clear acs_channel, channel to |
| 8796 | * reset to 0. Otherwise these settings will override |
| 8797 | * the ACS while restart. |
| 8798 | */ |
| 8799 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8800 | |
| 8801 | hdd_debug("sending coex indication"); |
| 8802 | |
| 8803 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8804 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8805 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8806 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8807 | |
| 8808 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8809 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8810 | { |
| 8811 | uint32_t size; |
| 8812 | uint16_t *unsafe_list; |
| 8813 | uint16_t chan_count; |
| 8814 | |
| 8815 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8816 | return -EINVAL; |
| 8817 | |
| 8818 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8819 | NUM_CHANNELS); |
| 8820 | if (chan_count) { |
| 8821 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8822 | unsafe_list = qdf_mem_malloc(size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8823 | if (!unsafe_list) |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8824 | return -ENOMEM; |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8825 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8826 | } else { |
| 8827 | unsafe_list = NULL; |
| 8828 | } |
| 8829 | |
| 8830 | *local_unsafe_list = unsafe_list; |
| 8831 | *local_unsafe_list_count = chan_count; |
| 8832 | |
| 8833 | return 0; |
| 8834 | } |
| 8835 | |
| 8836 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8837 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8838 | { |
| 8839 | int i, j; |
| 8840 | |
| 8841 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8842 | return true; |
| 8843 | if (local_unsafe_list_count == 0) |
| 8844 | return false; |
| 8845 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8846 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8847 | if (local_unsafe_list[i] == |
| 8848 | hdd_ctx->unsafe_channel_list[j]) |
| 8849 | break; |
| 8850 | if (j >= local_unsafe_list_count) |
| 8851 | break; |
| 8852 | } |
| 8853 | if (i >= local_unsafe_list_count) { |
| 8854 | hdd_info("unsafe chan list same"); |
| 8855 | return false; |
| 8856 | } |
| 8857 | |
| 8858 | return true; |
| 8859 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8860 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8861 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8862 | { |
| 8863 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8864 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8865 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8866 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8867 | { |
| 8868 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8869 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8870 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8871 | |
| 8872 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8873 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8874 | * user space |
| 8875 | * @frame_ind: Management frame data to be informed. |
| 8876 | * |
| 8877 | * This function is used to indicate management frame to |
| 8878 | * user space |
| 8879 | * |
| 8880 | * Return: None |
| 8881 | * |
| 8882 | */ |
| 8883 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8884 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8885 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8886 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8887 | int i; |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8888 | struct ieee80211_mgmt *mgmt = |
| 8889 | (struct ieee80211_mgmt *)frame_ind->frameBuf; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8890 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 8891 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8892 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8893 | return; |
| 8894 | |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8895 | if (frame_ind->frame_len < ieee80211_hdrlen(mgmt->frame_control)) { |
| 8896 | hdd_err(" Invalid frame length"); |
| 8897 | return; |
| 8898 | } |
| 8899 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8900 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 8901 | for (i = 0; i < WLAN_MAX_VDEVS; i++) { |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8902 | adapter = |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 8903 | hdd_get_adapter_by_vdev(hdd_ctx, i); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8904 | if (adapter) |
| 8905 | break; |
| 8906 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8907 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8908 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 8909 | if ((adapter) && |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8910 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8911 | __hdd_indicate_mgmt_frame(adapter, |
| 8912 | frame_ind->frame_len, |
| 8913 | frame_ind->frameBuf, |
| 8914 | frame_ind->frameType, |
| 8915 | frame_ind->rxChan, |
Srinivas Dasari | ea1c133 | 2019-02-18 12:43:23 +0530 | [diff] [blame] | 8916 | frame_ind->rxRssi, |
| 8917 | frame_ind->rx_flags); |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8918 | } |
| 8919 | } |
| 8920 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8921 | } else { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 8922 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, |
| 8923 | frame_ind->sessionId); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8924 | } |
| 8925 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 8926 | if ((adapter) && |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8927 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8928 | __hdd_indicate_mgmt_frame(adapter, |
| 8929 | frame_ind->frame_len, |
| 8930 | frame_ind->frameBuf, |
| 8931 | frame_ind->frameType, |
| 8932 | frame_ind->rxChan, |
Srinivas Dasari | ea1c133 | 2019-02-18 12:43:23 +0530 | [diff] [blame] | 8933 | frame_ind->rxRssi, |
| 8934 | frame_ind->rx_flags); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8935 | } |
| 8936 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8937 | void hdd_acs_response_timeout_handler(void *context) |
| 8938 | { |
| 8939 | struct hdd_external_acs_timer_context *timer_context = |
| 8940 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8941 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8942 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8943 | uint8_t reason; |
| 8944 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8945 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8946 | if (!timer_context) { |
| 8947 | hdd_err("invlaid timer context"); |
| 8948 | return; |
| 8949 | } |
| 8950 | adapter = timer_context->adapter; |
| 8951 | reason = timer_context->reason; |
| 8952 | |
| 8953 | |
| 8954 | if ((!adapter) || |
| 8955 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 8956 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 8957 | return; |
| 8958 | } |
| 8959 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8960 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8961 | return; |
| 8962 | |
| 8963 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 8964 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8965 | else |
| 8966 | return; |
| 8967 | |
| 8968 | hdd_err("ACS timeout happened for %s reason %d", |
| 8969 | adapter->dev->name, reason); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8970 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8971 | switch (reason) { |
| 8972 | /* SAP init case */ |
| 8973 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 8974 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8975 | false); |
| 8976 | wlan_hdd_cfg80211_start_acs(adapter); |
| 8977 | break; |
| 8978 | /* DFS detected on current channel */ |
| 8979 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 8980 | wlan_sap_update_next_channel( |
| 8981 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8982 | sme_update_new_channel_event(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8983 | adapter->vdev_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8984 | break; |
| 8985 | /* LTE coex event on current channel */ |
| 8986 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 8987 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 8988 | break; |
| 8989 | default: |
| 8990 | hdd_info("invalid reason for timer invoke"); |
| 8991 | |
| 8992 | } |
| 8993 | } |
| 8994 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8995 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8996 | * hdd_override_ini_config - Override INI config |
| 8997 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8998 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8999 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9000 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9001 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9002 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9003 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9004 | { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9005 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9006 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9007 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 9008 | ucfg_scan_cfg_set_dfs_chan_scan_allowed(hdd_ctx->psoc, |
| 9009 | enable_dfs_chan_scan); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9010 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9011 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9012 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9013 | if (0 == enable_11d || 1 == enable_11d) { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9014 | status = ucfg_mlme_set_11d_enabled(hdd_ctx->psoc, enable_11d); |
| 9015 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9016 | hdd_err("Failed to set 11d_enable flag"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9017 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 9018 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9019 | if (hdd_ctx->config->action_oui_enable && !ucfg_action_oui_enabled()) { |
| 9020 | hdd_ctx->config->action_oui_enable = 0; |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9021 | hdd_err("Ignore action oui ini, since no action_oui component"); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9022 | } |
Will Huang | 14b120f | 2019-01-14 17:26:14 +0800 | [diff] [blame] | 9023 | |
| 9024 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
| 9025 | hdd_override_all_ps(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9026 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9027 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9028 | #ifdef ENABLE_MTRACE_LOG |
| 9029 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9030 | { |
| 9031 | uint8_t module_id = 0; |
| 9032 | int qdf_print_idx = -1; |
| 9033 | |
| 9034 | qdf_print_idx = qdf_get_pidx(); |
| 9035 | for (module_id = 0; module_id < QDF_MODULE_ID_MAX; module_id++) |
| 9036 | qdf_print_set_category_verbose( |
| 9037 | qdf_print_idx, |
| 9038 | module_id, QDF_TRACE_LEVEL_TRACE, |
| 9039 | hdd_ctx->config->enable_mtrace); |
| 9040 | } |
| 9041 | #else |
| 9042 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9043 | { |
| 9044 | } |
| 9045 | |
| 9046 | #endif |
| 9047 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9048 | /** |
Wu Gao | 8dd9f50 | 2019-04-26 15:04:28 +0800 | [diff] [blame] | 9049 | * hdd_log_level_to_bitmask() - user space log level to host log bitmask |
| 9050 | * @user_log_level: user space log level |
| 9051 | * |
| 9052 | * Convert log level from user space to host log level bitmask. |
| 9053 | * |
| 9054 | * Return: Bitmask of log levels to be enabled |
| 9055 | */ |
| 9056 | static uint32_t hdd_log_level_to_bitmask(enum host_log_level user_log_level) |
| 9057 | { |
| 9058 | QDF_TRACE_LEVEL host_trace_level; |
| 9059 | uint32_t bitmask; |
| 9060 | |
| 9061 | switch (user_log_level) { |
| 9062 | case HOST_LOG_LEVEL_NONE: |
| 9063 | host_trace_level = QDF_TRACE_LEVEL_NONE; |
| 9064 | break; |
| 9065 | case HOST_LOG_LEVEL_FATAL: |
| 9066 | host_trace_level = QDF_TRACE_LEVEL_FATAL; |
| 9067 | break; |
| 9068 | case HOST_LOG_LEVEL_ERROR: |
| 9069 | host_trace_level = QDF_TRACE_LEVEL_ERROR; |
| 9070 | break; |
| 9071 | case HOST_LOG_LEVEL_WARN: |
| 9072 | host_trace_level = QDF_TRACE_LEVEL_WARN; |
| 9073 | break; |
| 9074 | case HOST_LOG_LEVEL_INFO: |
| 9075 | host_trace_level = QDF_TRACE_LEVEL_INFO_LOW; |
| 9076 | break; |
| 9077 | case HOST_LOG_LEVEL_DEBUG: |
| 9078 | host_trace_level = QDF_TRACE_LEVEL_DEBUG; |
| 9079 | break; |
| 9080 | case HOST_LOG_LEVEL_TRACE: |
| 9081 | host_trace_level = QDF_TRACE_LEVEL_TRACE; |
| 9082 | break; |
| 9083 | default: |
| 9084 | host_trace_level = QDF_TRACE_LEVEL_TRACE; |
| 9085 | break; |
| 9086 | } |
| 9087 | |
| 9088 | bitmask = (1 << (host_trace_level + 1)) - 1; |
| 9089 | |
| 9090 | return bitmask; |
| 9091 | } |
| 9092 | |
| 9093 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9094 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 9095 | * @hdd_ctx - HDD context |
| 9096 | * |
| 9097 | * Set trace level for each module based on INI config. |
| 9098 | * |
| 9099 | * Return: None |
| 9100 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9101 | 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] | 9102 | { |
Wu Gao | 8dd9f50 | 2019-04-26 15:04:28 +0800 | [diff] [blame] | 9103 | uint8_t host_module_log[QDF_MODULE_ID_MAX * 2]; |
| 9104 | qdf_size_t host_module_log_num = 0; |
| 9105 | QDF_MODULE_ID module_id; |
| 9106 | uint32_t bitmask; |
| 9107 | uint32_t i; |
| 9108 | |
Wu Gao | bc6eaa1 | 2018-11-30 14:17:45 +0800 | [diff] [blame] | 9109 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, 0x7f); |
Wu Gao | 8dd9f50 | 2019-04-26 15:04:28 +0800 | [diff] [blame] | 9110 | |
| 9111 | qdf_uint8_array_parse(cfg_get(hdd_ctx->psoc, |
| 9112 | CFG_ENABLE_HOST_MODULE_LOG_LEVEL), |
| 9113 | host_module_log, |
| 9114 | QDF_MODULE_ID_MAX * 2, |
| 9115 | &host_module_log_num); |
| 9116 | |
| 9117 | for (i = 0; i + 1 < host_module_log_num; i += 2) { |
| 9118 | module_id = host_module_log[i]; |
| 9119 | bitmask = hdd_log_level_to_bitmask(host_module_log[i + 1]); |
| 9120 | if (module_id < QDF_MODULE_ID_MAX && |
| 9121 | module_id >= QDF_MODULE_ID_MIN) |
| 9122 | hdd_qdf_trace_enable(module_id, bitmask); |
| 9123 | } |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 9124 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9125 | hdd_set_mtrace_for_each(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9126 | } |
| 9127 | |
| 9128 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9129 | * hdd_context_init() - Initialize HDD context |
| 9130 | * @hdd_ctx: HDD context. |
| 9131 | * |
| 9132 | * Initialize HDD context along with all the feature specific contexts. |
| 9133 | * |
| 9134 | * return: 0 on success and errno on failure. |
| 9135 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9136 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9137 | { |
| 9138 | int ret; |
| 9139 | |
| 9140 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 9141 | hdd_ctx->max_intf_count = WLAN_MAX_VDEVS; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9142 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9143 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 9144 | init_completion(&hdd_ctx->ready_to_suspend); |
| 9145 | |
| 9146 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9147 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 9148 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 9149 | qdf_list_create(&hdd_ctx->hdd_adapters, 0); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9150 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9151 | ret = hdd_scan_context_init(hdd_ctx); |
| 9152 | if (ret) |
| 9153 | goto list_destroy; |
| 9154 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9155 | hdd_rx_wake_lock_create(hdd_ctx); |
| 9156 | |
| 9157 | ret = hdd_sap_context_init(hdd_ctx); |
| 9158 | if (ret) |
| 9159 | goto scan_destroy; |
| 9160 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9161 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 9162 | |
| 9163 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 9164 | |
| 9165 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 9166 | hdd_ctx->config); |
| 9167 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 9168 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9169 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 9170 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 9171 | "monitor_mode_wakelock"); |
| 9172 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9173 | return 0; |
| 9174 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9175 | sap_destroy: |
| 9176 | hdd_sap_context_destroy(hdd_ctx); |
| 9177 | |
| 9178 | scan_destroy: |
| 9179 | hdd_scan_context_destroy(hdd_ctx); |
| 9180 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9181 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 9182 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 9183 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9184 | return ret; |
| 9185 | } |
| 9186 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9187 | void hdd_psoc_idle_timer_start(struct hdd_context *hdd_ctx) |
| 9188 | { |
| 9189 | uint32_t timeout_ms = hdd_ctx->config->iface_change_wait_time; |
| 9190 | enum wake_lock_reason reason = |
| 9191 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER; |
| 9192 | |
Rajeev Kumar | 7b7bb3f | 2018-12-20 12:09:54 -0800 | [diff] [blame] | 9193 | if (!timeout_ms) { |
| 9194 | hdd_info("psoc idle timer is disabled"); |
| 9195 | return; |
| 9196 | } |
| 9197 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9198 | hdd_debug("Starting psoc idle timer"); |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9199 | qdf_delayed_work_start(&hdd_ctx->psoc_idle_timeout_work, timeout_ms); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9200 | hdd_prevent_suspend_timeout(timeout_ms, reason); |
| 9201 | } |
| 9202 | |
| 9203 | void hdd_psoc_idle_timer_stop(struct hdd_context *hdd_ctx) |
| 9204 | { |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9205 | qdf_delayed_work_stop_sync(&hdd_ctx->psoc_idle_timeout_work); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9206 | hdd_debug("Stopped psoc idle timer"); |
| 9207 | } |
| 9208 | |
Sourav Mohapatra | 698d6f6 | 2019-01-29 14:49:52 +0530 | [diff] [blame] | 9209 | /* |
| 9210 | * enum hdd_block_shutdown - Control if driver allows modem shutdown |
| 9211 | * @HDD_UNBLOCK_MODEM_SHUTDOWN: Unblock shutdown |
| 9212 | * @HDD_BLOCK_MODEM_SHUTDOWN: Block shutdown |
| 9213 | * |
| 9214 | * On calling pld_block_shutdown API with the given values, modem |
| 9215 | * graceful shutdown is blocked/unblocked. |
| 9216 | */ |
| 9217 | enum hdd_block_shutdown { |
| 9218 | HDD_UNBLOCK_MODEM_SHUTDOWN, |
| 9219 | HDD_BLOCK_MODEM_SHUTDOWN, |
| 9220 | }; |
| 9221 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9222 | /** |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9223 | * __hdd_psoc_idle_shutdown() - perform an idle shutdown on the given psoc |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9224 | * @hdd_ctx: the hdd context which should be shutdown |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9225 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9226 | * When no interfaces are "up" on a psoc, an idle shutdown timer is started. |
| 9227 | * If no interfaces are brought up before the timer expires, we do an |
| 9228 | * "idle shutdown," cutting power to the physical SoC to save power. This is |
| 9229 | * done completely transparently from the perspective of userspace. |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9230 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9231 | * Return: None |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9232 | */ |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9233 | static int __hdd_psoc_idle_shutdown(struct hdd_context *hdd_ctx) |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9234 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9235 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9236 | int errno; |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9237 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9238 | hdd_enter(); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9239 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9240 | errno = osif_psoc_sync_trans_start(hdd_ctx->parent_dev, &psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9241 | if (errno) { |
| 9242 | hdd_info("psoc busy, abort idle shutdown; errno:%d", errno); |
| 9243 | goto exit; |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9244 | } |
Sourav Mohapatra | 698d6f6 | 2019-01-29 14:49:52 +0530 | [diff] [blame] | 9245 | /* Block the modem graceful shutdown till stop modules is completed */ |
| 9246 | pld_block_shutdown(hdd_ctx->parent_dev, HDD_BLOCK_MODEM_SHUTDOWN); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9247 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9248 | osif_psoc_sync_wait_for_ops(psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9249 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9250 | QDF_BUG(!hdd_wlan_stop_modules(hdd_ctx, false)); |
| 9251 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9252 | osif_psoc_sync_trans_stop(psoc_sync); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9253 | |
Sourav Mohapatra | 698d6f6 | 2019-01-29 14:49:52 +0530 | [diff] [blame] | 9254 | pld_block_shutdown(hdd_ctx->parent_dev, HDD_UNBLOCK_MODEM_SHUTDOWN); |
| 9255 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9256 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9257 | hdd_exit(); |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9258 | return errno; |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9259 | } |
| 9260 | |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9261 | int hdd_psoc_idle_shutdown(struct device *dev) |
| 9262 | { |
| 9263 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9264 | |
| 9265 | return __hdd_psoc_idle_shutdown(hdd_ctx); |
| 9266 | } |
| 9267 | |
| 9268 | static int __hdd_psoc_idle_restart(struct hdd_context *hdd_ctx) |
| 9269 | { |
| 9270 | return hdd_wlan_start_modules(hdd_ctx, false); |
| 9271 | } |
| 9272 | |
| 9273 | int hdd_psoc_idle_restart(struct device *dev) |
| 9274 | { |
| 9275 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9276 | |
| 9277 | return __hdd_psoc_idle_restart(hdd_ctx); |
| 9278 | } |
| 9279 | |
| 9280 | int hdd_trigger_psoc_idle_restart(struct hdd_context *hdd_ctx) |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9281 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 9282 | QDF_BUG(rtnl_is_locked()); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9283 | |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9284 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 9285 | hdd_psoc_idle_timer_stop(hdd_ctx); |
| 9286 | hdd_info("Driver modules already Enabled"); |
| 9287 | return 0; |
| 9288 | } |
| 9289 | |
| 9290 | pld_idle_restart(hdd_ctx->parent_dev, hdd_psoc_idle_restart); |
| 9291 | |
| 9292 | return 0; |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9293 | } |
| 9294 | |
| 9295 | /** |
| 9296 | * hdd_psoc_idle_timeout_callback() - Handler for psoc idle timeout |
| 9297 | * @priv: pointer to hdd context |
| 9298 | * |
| 9299 | * Return: None |
| 9300 | */ |
| 9301 | static void hdd_psoc_idle_timeout_callback(void *priv) |
| 9302 | { |
| 9303 | struct hdd_context *hdd_ctx = priv; |
| 9304 | |
| 9305 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 9306 | return; |
| 9307 | |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9308 | hdd_info("Psoc idle timeout elapsed; starting psoc shutdown"); |
| 9309 | |
| 9310 | pld_idle_shutdown(hdd_ctx->parent_dev, hdd_psoc_idle_shutdown); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9311 | } |
| 9312 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9313 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9314 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9315 | { |
| 9316 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 9317 | wlan_logging_to_console); |
| 9318 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 9319 | } |
| 9320 | #else |
| 9321 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9322 | { } |
| 9323 | #endif |
| 9324 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9325 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9326 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9327 | struct wlan_objmgr_psoc *psoc) |
| 9328 | { |
| 9329 | config->wlan_logging_enable = cfg_get(psoc, CFG_WLAN_LOGGING_SUPPORT); |
| 9330 | |
| 9331 | config->wlan_logging_to_console = |
| 9332 | cfg_get(psoc, CFG_WLAN_LOGGING_CONSOLE_SUPPORT); |
| 9333 | } |
| 9334 | #else |
| 9335 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9336 | struct wlan_objmgr_psoc *psoc) |
| 9337 | { |
| 9338 | } |
| 9339 | #endif |
| 9340 | |
| 9341 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9342 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9343 | struct wlan_objmgr_psoc *psoc) |
| 9344 | { |
| 9345 | config->wlan_auto_shutdown = cfg_get(psoc, CFG_WLAN_AUTO_SHUTDOWN); |
| 9346 | } |
| 9347 | #else |
| 9348 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9349 | struct wlan_objmgr_psoc *psoc) |
| 9350 | { |
| 9351 | } |
| 9352 | #endif |
| 9353 | |
| 9354 | #ifndef REMOVE_PKT_LOG |
| 9355 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9356 | struct wlan_objmgr_psoc *psoc) |
| 9357 | { |
| 9358 | config->enable_packet_log = cfg_get(psoc, CFG_ENABLE_PACKET_LOG); |
| 9359 | } |
| 9360 | #else |
| 9361 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9362 | struct wlan_objmgr_psoc *psoc) |
| 9363 | { |
| 9364 | } |
| 9365 | #endif |
| 9366 | |
Sandeep Puligilla | 43b6d1a | 2018-12-03 09:16:13 -0800 | [diff] [blame] | 9367 | #ifdef ENABLE_MTRACE_LOG |
| 9368 | static void hdd_init_mtrace_log(struct hdd_config *config, |
| 9369 | struct wlan_objmgr_psoc *psoc) |
| 9370 | { |
| 9371 | config->enable_mtrace = cfg_get(psoc, CFG_ENABLE_MTRACE); |
| 9372 | } |
| 9373 | #else |
| 9374 | static void hdd_init_mtrace_log(struct hdd_config *config, |
| 9375 | struct wlan_objmgr_psoc *psoc) |
| 9376 | { |
| 9377 | } |
| 9378 | #endif |
| 9379 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9380 | #ifdef FEATURE_RUNTIME_PM |
| 9381 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9382 | struct wlan_objmgr_psoc *psoc) |
| 9383 | { |
| 9384 | config->runtime_pm = cfg_get(psoc, CFG_ENABLE_RUNTIME_PM); |
| 9385 | } |
| 9386 | #else |
| 9387 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9388 | struct wlan_objmgr_psoc *psoc) |
| 9389 | |
| 9390 | { |
| 9391 | } |
| 9392 | #endif |
| 9393 | |
| 9394 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 9395 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9396 | struct wlan_objmgr_psoc *psoc) |
| 9397 | { |
| 9398 | config->vc_mode_cfg_bitmap = cfg_get(psoc, CFG_VC_MODE_BITMAP); |
| 9399 | } |
| 9400 | #else |
| 9401 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9402 | struct wlan_objmgr_psoc *psoc) |
| 9403 | { |
| 9404 | } |
| 9405 | #endif |
| 9406 | |
gaurank kathpalia | 566c81b | 2019-02-20 14:31:45 +0530 | [diff] [blame] | 9407 | #ifdef DHCP_SERVER_OFFLOAD |
| 9408 | static void |
| 9409 | hdd_init_dhcp_server_ip(struct hdd_context *hdd_ctx) |
| 9410 | { |
| 9411 | uint8_t num_entries; |
| 9412 | |
| 9413 | hdd_ctx->config->dhcp_server_ip.is_dhcp_server_ip_valid = true; |
| 9414 | hdd_string_to_u8_array(cfg_get(hdd_ctx->psoc, CFG_DHCP_SERVER_IP_NAME), |
| 9415 | hdd_ctx->config->dhcp_server_ip.dhcp_server_ip, |
| 9416 | &num_entries, IPADDR_NUM_ENTRIES); |
| 9417 | |
| 9418 | if (num_entries != IPADDR_NUM_ENTRIES) { |
| 9419 | hdd_err("Incorrect IP address (%s) assigned for DHCP server!", |
| 9420 | cfg_get(hdd_ctx->psoc, CFG_DHCP_SERVER_IP_NAME)); |
| 9421 | hdd_config->dhcp_server_ip.is_dhcp_server_ip_valid = false; |
| 9422 | } |
| 9423 | } |
| 9424 | #else |
| 9425 | static void |
| 9426 | hdd_init_dhcp_server_ip(struct hdd_context *hdd_ctx) |
| 9427 | { |
| 9428 | } |
| 9429 | #endif |
| 9430 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9431 | /** |
| 9432 | * hdd_cfg_params_init() - Initialize hdd params in hdd_config strucuture |
| 9433 | * @hdd_ctx - Pointer to HDD context |
| 9434 | * |
| 9435 | * Return: None |
| 9436 | */ |
| 9437 | static void hdd_cfg_params_init(struct hdd_context *hdd_ctx) |
| 9438 | { |
| 9439 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
| 9440 | struct hdd_config *config = hdd_ctx->config; |
| 9441 | |
| 9442 | if (!psoc) { |
| 9443 | hdd_err("Invalid psoc"); |
| 9444 | return; |
| 9445 | } |
| 9446 | |
| 9447 | if (!config) { |
| 9448 | hdd_err("Invalid hdd config"); |
| 9449 | return; |
| 9450 | } |
| 9451 | |
gaurank kathpalia | 43c5262 | 2019-02-11 12:30:05 +0530 | [diff] [blame] | 9452 | config->dot11Mode = cfg_get(psoc, CFG_HDD_DOT11_MODE); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9453 | config->bug_on_reinit_failure = cfg_get(psoc, |
| 9454 | CFG_BUG_ON_REINIT_FAILURE); |
| 9455 | |
| 9456 | config->is_ramdump_enabled = cfg_get(psoc, |
| 9457 | CFG_ENABLE_RAMDUMP_COLLECTION); |
| 9458 | |
| 9459 | config->iface_change_wait_time = cfg_get(psoc, |
| 9460 | CFG_INTERFACE_CHANGE_WAIT); |
| 9461 | |
| 9462 | config->multicast_host_fw_msgs = cfg_get(psoc, |
| 9463 | CFG_MULTICAST_HOST_FW_MSGS); |
| 9464 | |
| 9465 | config->private_wext_control = cfg_get(psoc, CFG_PRIVATE_WEXT_CONTROL); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9466 | config->enablefwprint = cfg_get(psoc, CFG_ENABLE_FW_UART_PRINT); |
| 9467 | config->enable_fw_log = cfg_get(psoc, CFG_ENABLE_FW_LOG); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9468 | config->operating_channel = cfg_get(psoc, CFG_OPERATING_CHANNEL); |
| 9469 | config->num_vdevs = cfg_get(psoc, CFG_NUM_VDEV_ENABLE); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9470 | qdf_str_lcopy(config->enable_concurrent_sta, |
| 9471 | cfg_get(psoc, CFG_ENABLE_CONCURRENT_STA), |
| 9472 | CFG_CONCURRENT_IFACE_MAX_LEN); |
| 9473 | qdf_str_lcopy(config->dbs_scan_selection, |
| 9474 | cfg_get(psoc, CFG_DBS_SCAN_SELECTION), |
| 9475 | CFG_DBS_SCAN_PARAM_LENGTH); |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9476 | 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] | 9477 | config->mac_provision = cfg_get(psoc, CFG_ENABLE_MAC_PROVISION); |
| 9478 | config->provisioned_intf_pool = |
| 9479 | cfg_get(psoc, CFG_PROVISION_INTERFACE_POOL); |
| 9480 | config->derived_intf_pool = cfg_get(psoc, CFG_DERIVED_INTERFACE_POOL); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9481 | config->action_oui_enable = cfg_get(psoc, CFG_ENABLE_ACTION_OUI); |
Jeff Johnson | 15a88ac | 2019-03-11 14:35:25 -0700 | [diff] [blame] | 9482 | config->advertise_concurrent_operation = |
Sandeep Puligilla | dc6d68a | 2019-01-04 16:57:12 -0800 | [diff] [blame] | 9483 | cfg_get(psoc, |
| 9484 | CFG_ADVERTISE_CONCURRENT_OPERATION); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9485 | qdf_str_lcopy(config->action_oui_str[0], |
| 9486 | cfg_get(psoc, CFG_ACTION_OUI_CONNECT_1X1), |
| 9487 | ACTION_OUI_MAX_STR_LEN); |
| 9488 | qdf_str_lcopy(config->action_oui_str[1], |
| 9489 | cfg_get(psoc, CFG_ACTION_OUI_ITO_EXTENSION), |
| 9490 | ACTION_OUI_MAX_STR_LEN); |
| 9491 | qdf_str_lcopy(config->action_oui_str[2], |
| 9492 | cfg_get(psoc, CFG_ACTION_OUI_CCKM_1X1), |
| 9493 | ACTION_OUI_MAX_STR_LEN); |
| 9494 | qdf_str_lcopy(config->action_oui_str[3], |
| 9495 | cfg_get(psoc, CFG_ACTION_OUI_ITO_ALTERNATE), |
| 9496 | ACTION_OUI_MAX_STR_LEN); |
| 9497 | qdf_str_lcopy(config->action_oui_str[4], |
| 9498 | cfg_get(psoc, CFG_ACTION_OUI_SWITCH_TO_11N_MODE), |
| 9499 | ACTION_OUI_MAX_STR_LEN); |
| 9500 | qdf_str_lcopy(config->action_oui_str[5], |
| 9501 | cfg_get(psoc, |
| 9502 | CFG_ACTION_OUI_CONNECT_1X1_WITH_1_CHAIN), |
| 9503 | ACTION_OUI_MAX_STR_LEN); |
Rajeev Kumar Sirasanagandla | d7987f1 | 2018-12-08 23:24:04 +0530 | [diff] [blame] | 9504 | qdf_str_lcopy(config->action_oui_str[6], |
| 9505 | cfg_get(psoc, |
| 9506 | CFG_ACTION_OUI_DISABLE_AGGRESSIVE_TX), |
| 9507 | ACTION_OUI_MAX_STR_LEN); |
Sourav Mohapatra | 9e014cf | 2018-12-11 09:39:33 +0530 | [diff] [blame] | 9508 | config->enable_rtt_support = cfg_get(psoc, CFG_ENABLE_RTT_SUPPORT); |
Sandeep Puligilla | efeb4a9 | 2019-01-08 00:06:51 -0800 | [diff] [blame] | 9509 | config->is_unit_test_framework_enabled = |
| 9510 | cfg_get(psoc, CFG_ENABLE_UNIT_TEST_FRAMEWORK); |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 9511 | config->disable_channel = cfg_get(psoc, CFG_ENABLE_DISABLE_CHANNEL); |
Ashish Kumar Dhanotiya | 9549818 | 2019-04-29 13:59:20 +0530 | [diff] [blame] | 9512 | config->sar_version = cfg_get(psoc, CFG_SAR_VERSION); |
Rajeev Kumar | 3a7c340 | 2019-05-02 16:02:20 -0700 | [diff] [blame] | 9513 | config->is_wow_disabled = cfg_get(psoc, CFG_WOW_DISABLE); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9514 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9515 | hdd_init_vc_mode_cfg_bitmap(config, psoc); |
| 9516 | hdd_init_runtime_pm(config, psoc); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9517 | hdd_init_wlan_auto_shutdown(config, psoc); |
| 9518 | hdd_init_wlan_logging_params(config, psoc); |
| 9519 | hdd_init_packet_log(config, psoc); |
Sandeep Puligilla | 43b6d1a | 2018-12-03 09:16:13 -0800 | [diff] [blame] | 9520 | hdd_init_mtrace_log(config, psoc); |
gaurank kathpalia | 566c81b | 2019-02-20 14:31:45 +0530 | [diff] [blame] | 9521 | hdd_init_dhcp_server_ip(hdd_ctx); |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 9522 | hdd_dp_cfg_update(psoc, hdd_ctx); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9523 | } |
| 9524 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 9525 | struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9526 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9527 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9528 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9529 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9530 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9531 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9532 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 9533 | hdd_ctx = hdd_cfg80211_wiphy_alloc(); |
| 9534 | if (!hdd_ctx) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9535 | ret = -ENOMEM; |
| 9536 | goto err_out; |
| 9537 | } |
| 9538 | |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9539 | status = qdf_delayed_work_create(&hdd_ctx->psoc_idle_timeout_work, |
| 9540 | hdd_psoc_idle_timeout_callback, |
| 9541 | hdd_ctx); |
| 9542 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9543 | ret = qdf_status_to_os_return(status); |
| 9544 | goto wiphy_dealloc; |
| 9545 | } |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9546 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9547 | hdd_ctx->parent_dev = dev; |
Jeff Johnson | 995fd51 | 2019-03-06 08:45:10 -0800 | [diff] [blame] | 9548 | hdd_ctx->last_scan_reject_vdev_id = WLAN_UMAC_VDEV_ID_MAX; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9549 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9550 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9551 | if (!hdd_ctx->config) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9552 | ret = -ENOMEM; |
| 9553 | goto err_free_hdd_context; |
| 9554 | } |
| 9555 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 9556 | status = cfg_parse(WLAN_INI_FILE); |
| 9557 | if (QDF_IS_STATUS_ERROR(status)) |
| 9558 | hdd_err("Failed to parse cfg %s; status:%d\n", |
| 9559 | WLAN_INI_FILE, status); |
| 9560 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9561 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID); |
| 9562 | if (ret) { |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9563 | QDF_DEBUG_PANIC("Psoc creation fails!"); |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9564 | goto err_free_config; |
| 9565 | } |
| 9566 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9567 | hdd_cfg_params_init(hdd_ctx); |
| 9568 | |
Dustin Brown | 4bbd546 | 2019-03-22 11:18:13 -0700 | [diff] [blame] | 9569 | /* apply multiplier config, if not already set via module parameter */ |
| 9570 | if (qdf_timer_get_multiplier() == 1) |
| 9571 | qdf_timer_set_multiplier(cfg_get(hdd_ctx->psoc, |
| 9572 | CFG_TIMER_MULTIPLIER)); |
Dustin Brown | a9a8452 | 2019-02-04 12:25:40 -0800 | [diff] [blame] | 9573 | hdd_debug("set timer multiplier: %u", qdf_timer_get_multiplier()); |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 9574 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9575 | cds_set_fatal_event(cfg_get(hdd_ctx->psoc, |
| 9576 | CFG_ENABLE_FATAL_EVENT_TRIGGER)); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 9577 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9578 | hdd_override_ini_config(hdd_ctx); |
| 9579 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9580 | ret = hdd_context_init(hdd_ctx); |
| 9581 | |
| 9582 | if (ret) |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9583 | goto err_hdd_objmgr_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9584 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 9585 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE || |
| 9586 | hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9587 | goto skip_multicast_logging; |
| 9588 | |
| 9589 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 9590 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9591 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 9592 | if (ret) |
| 9593 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9594 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9595 | ret = hdd_init_netlink_services(hdd_ctx); |
| 9596 | if (ret) |
| 9597 | goto err_deinit_txrx_histogram; |
| 9598 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9599 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9600 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9601 | skip_multicast_logging: |
| 9602 | hdd_set_trace_level_for_each(hdd_ctx); |
| 9603 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 9604 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 9605 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9606 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 9607 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9608 | return hdd_ctx; |
| 9609 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9610 | err_deinit_txrx_histogram: |
| 9611 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 9612 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9613 | err_deinit_hdd_context: |
| 9614 | hdd_context_deinit(hdd_ctx); |
| 9615 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9616 | err_hdd_objmgr_destroy: |
| 9617 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 9618 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9619 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9620 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9621 | |
| 9622 | err_free_hdd_context: |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9623 | qdf_delayed_work_destroy(&hdd_ctx->psoc_idle_timeout_work); |
| 9624 | |
| 9625 | wiphy_dealloc: |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 9626 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9627 | |
| 9628 | err_out: |
| 9629 | return ERR_PTR(ret); |
| 9630 | } |
| 9631 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9632 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9633 | * hdd_start_station_adapter()- Start the Station Adapter |
| 9634 | * @adapter: HDD adapter |
| 9635 | * |
| 9636 | * This function initializes the adapter for the station mode. |
| 9637 | * |
| 9638 | * Return: 0 on success or errno on failure. |
| 9639 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9640 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9641 | { |
| 9642 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9643 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9644 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9645 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9646 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9647 | hdd_err("session is already opened, %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9648 | adapter->vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9649 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9650 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9651 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9652 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 9653 | if (ret) { |
| 9654 | hdd_err("failed to create vdev: %d", ret); |
| 9655 | return ret; |
| 9656 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9657 | status = hdd_init_station_mode(adapter); |
| 9658 | |
| 9659 | if (QDF_STATUS_SUCCESS != status) { |
| 9660 | hdd_err("Error Initializing station mode: %d", status); |
| 9661 | return qdf_status_to_os_return(status); |
| 9662 | } |
| 9663 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9664 | hdd_register_tx_flow_control(adapter, |
| 9665 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9666 | hdd_tx_resume_cb, |
| 9667 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9668 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 9669 | hdd_register_hl_netdev_fc_timer(adapter, |
| 9670 | hdd_tx_resume_timer_expired_handler); |
| 9671 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9672 | hdd_exit(); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 9673 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9674 | return 0; |
| 9675 | } |
| 9676 | |
| 9677 | /** |
| 9678 | * hdd_start_ap_adapter()- Start AP Adapter |
| 9679 | * @adapter: HDD adapter |
| 9680 | * |
| 9681 | * This function initializes the adapter for the AP mode. |
| 9682 | * |
| 9683 | * Return: 0 on success errno on failure. |
| 9684 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9685 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9686 | { |
| 9687 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9688 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9689 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9690 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9691 | uint32_t fine_time_meas_cap = 0; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9692 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9693 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9694 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9695 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9696 | hdd_err("session is already opened, %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9697 | adapter->vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9698 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9699 | } |
| 9700 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9701 | * In SSR case no need to create new sap context. |
| 9702 | * Otherwise create sap context first and then create |
| 9703 | * vdev as while creating the vdev, driver needs to |
| 9704 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9705 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9706 | if (adapter->session.ap.sap_context) { |
| 9707 | is_ssr = true; |
| 9708 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9709 | hdd_err("sap creation failed"); |
| 9710 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 9711 | } |
| 9712 | |
| 9713 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 9714 | adapter->session.ap.sap_context); |
| 9715 | if (ret) { |
| 9716 | hdd_err("failed to create vdev, status:%d", ret); |
| 9717 | hdd_sap_destroy_ctx(adapter); |
| 9718 | return ret; |
| 9719 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9720 | |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9721 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 9722 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 9723 | &fine_time_meas_cap); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9724 | sme_cli_set_command(adapter->vdev_id, |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9725 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9726 | (bool)(fine_time_meas_cap & WMI_FW_AP_RTT_RESPR), |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9727 | VDEV_CMD); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9728 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9729 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9730 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9731 | |
| 9732 | if (QDF_STATUS_SUCCESS != status) { |
| 9733 | hdd_err("Error Initializing the AP mode: %d", status); |
| 9734 | return qdf_status_to_os_return(status); |
| 9735 | } |
| 9736 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9737 | hdd_register_tx_flow_control(adapter, |
| 9738 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9739 | hdd_softap_tx_resume_cb, |
| 9740 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9741 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 9742 | hdd_register_hl_netdev_fc_timer(adapter, |
| 9743 | hdd_tx_resume_timer_expired_handler); |
| 9744 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9745 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9746 | return 0; |
| 9747 | } |
| 9748 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9749 | /** |
| 9750 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9751 | * @cds_cfg: CDS Configuration |
| 9752 | * @hdd_ctx: Pointer to hdd context |
| 9753 | * |
| 9754 | * Return: none |
| 9755 | */ |
| 9756 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9757 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9758 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9759 | { |
| 9760 | cds_cfg->tx_flow_stop_queue_th = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9761 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9762 | cds_cfg->tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9763 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 9764 | /* configuration for DP RX Threads */ |
| 9765 | cds_cfg->enable_dp_rx_threads = hdd_ctx->enable_dp_rx_threads; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9766 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9767 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9768 | /** |
| 9769 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9770 | * @hdd_ctx: HDD Context |
| 9771 | * |
| 9772 | * Return: 0 for Success, errno on failure |
| 9773 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9774 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9775 | { |
| 9776 | struct cds_config_info *cds_cfg; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9777 | int value; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9778 | uint8_t band_capability; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9779 | uint8_t ito_repeat_count; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9780 | bool crash_inject; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9781 | bool self_recovery; |
| 9782 | bool fw_timeout_crash; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9783 | QDF_STATUS status; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9784 | |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9785 | cds_cfg = qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9786 | if (!cds_cfg) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9787 | return -ENOMEM; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9788 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9789 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 9790 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 9791 | &cds_cfg->sta_maxlimod_dtim); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9792 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9793 | status = ucfg_mlme_get_crash_inject(hdd_ctx->psoc, &crash_inject); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9794 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9795 | hdd_err("Failed to get crash inject ini config"); |
| 9796 | goto exit; |
| 9797 | } |
| 9798 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9799 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 9800 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9801 | hdd_err("Failed to get self recovery ini config"); |
| 9802 | goto exit; |
| 9803 | } |
| 9804 | |
| 9805 | status = ucfg_mlme_get_fw_timeout_crash(hdd_ctx->psoc, |
| 9806 | &fw_timeout_crash); |
| 9807 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9808 | hdd_err("Failed to get fw timeout crash ini config"); |
| 9809 | goto exit; |
| 9810 | } |
| 9811 | |
| 9812 | status = ucfg_mlme_get_ito_repeat_count(hdd_ctx->psoc, |
| 9813 | &ito_repeat_count); |
| 9814 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9815 | hdd_err("Failed to get ITO repeat count ini config"); |
| 9816 | goto exit; |
| 9817 | } |
| 9818 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9819 | cds_cfg->force_target_assert_enabled = crash_inject; |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9820 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9821 | ucfg_mlme_get_sap_max_offload_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9822 | cds_cfg->ap_maxoffload_peers = value; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9823 | ucfg_mlme_get_sap_max_offload_reorder_buffs(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9824 | &value); |
| 9825 | cds_cfg->ap_maxoffload_reorderbuffs = value; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9826 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9827 | cds_cfg->reorder_offload = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9828 | cfg_get(hdd_ctx->psoc, CFG_DP_REORDER_OFFLOAD_SUPPORT); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9829 | |
| 9830 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9831 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9832 | |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9833 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9834 | ucfg_mlme_get_sap_max_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9835 | cds_cfg->max_station = value; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9836 | 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] | 9837 | cds_cfg->max_msdus_per_rxinorderind = |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 9838 | cfg_get(hdd_ctx->psoc, CFG_DP_MAX_MSDUS_PER_RXIND); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9839 | cds_cfg->self_recovery_enabled = self_recovery; |
| 9840 | cds_cfg->fw_timeout_crash = fw_timeout_crash; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9841 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9842 | cds_cfg->ito_repeat_count = ito_repeat_count; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9843 | |
| 9844 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9845 | if (QDF_IS_STATUS_ERROR(status)) |
| 9846 | goto exit; |
| 9847 | |
| 9848 | cds_cfg->bandcapability = band_capability; |
Rachit Kankane | 0106e38 | 2018-05-16 18:59:28 +0530 | [diff] [blame] | 9849 | cds_cfg->num_vdevs = hdd_ctx->config->num_vdevs; |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 9850 | cds_cfg->enable_tx_compl_tsf64 = |
| 9851 | hdd_tsf_is_tsf64_tx_set(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9852 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9853 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9854 | cds_init_ini_config(cds_cfg); |
| 9855 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9856 | |
| 9857 | exit: |
| 9858 | qdf_mem_free(cds_cfg); |
| 9859 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9860 | } |
| 9861 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9862 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9863 | * hdd_update_user_config() - API to update user configuration |
| 9864 | * parameters to obj mgr which are used by multiple components |
| 9865 | * @hdd_ctx: HDD Context |
| 9866 | * |
| 9867 | * Return: 0 for Success, errno on failure |
| 9868 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9869 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9870 | { |
| 9871 | struct wlan_objmgr_psoc_user_config *user_config; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9872 | uint8_t band_capability; |
| 9873 | QDF_STATUS status; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9874 | bool value = false; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9875 | |
| 9876 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9877 | if (QDF_IS_STATUS_ERROR(status)) |
| 9878 | return -EIO; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9879 | |
| 9880 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9881 | if (!user_config) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9882 | return -ENOMEM; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9883 | |
| 9884 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9885 | status = ucfg_mlme_is_11d_enabled(hdd_ctx->psoc, &value); |
| 9886 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9887 | hdd_err("Invalid 11d_enable flag"); |
| 9888 | user_config->is_11d_support_enabled = value; |
| 9889 | |
| 9890 | value = false; |
| 9891 | status = ucfg_mlme_is_11h_enabled(hdd_ctx->psoc, &value); |
| 9892 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9893 | hdd_err("Invalid 11h_enable flag"); |
| 9894 | user_config->is_11h_support_enabled = value; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9895 | user_config->band_capability = band_capability; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9896 | wlan_objmgr_psoc_set_user_config(hdd_ctx->psoc, user_config); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9897 | |
| 9898 | qdf_mem_free(user_config); |
| 9899 | return 0; |
| 9900 | } |
| 9901 | |
| 9902 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9903 | * hdd_init_thermal_info - Initialize thermal level |
| 9904 | * @hdd_ctx: HDD context |
| 9905 | * |
| 9906 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9907 | * which would be called when a configured thermal threshold is hit. |
| 9908 | * |
| 9909 | * Return: 0 on success and errno on failure |
| 9910 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9911 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9912 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9913 | QDF_STATUS status; |
Manikandan Mohan | 9045e2e | 2018-11-26 16:44:19 -0800 | [diff] [blame] | 9914 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9915 | |
Manikandan Mohan | 9045e2e | 2018-11-26 16:44:19 -0800 | [diff] [blame] | 9916 | status = sme_init_thermal_info(mac_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9917 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9918 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9919 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9920 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9921 | sme_add_set_thermal_level_callback(mac_handle, |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9922 | hdd_set_thermal_level_cb); |
| 9923 | |
| 9924 | return 0; |
| 9925 | |
| 9926 | } |
| 9927 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9928 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9929 | /** |
| 9930 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9931 | * |
| 9932 | * Hold RTNL lock |
| 9933 | * |
| 9934 | * Return: True if held and false otherwise |
| 9935 | */ |
| 9936 | static inline bool hdd_hold_rtnl_lock(void) |
| 9937 | { |
| 9938 | rtnl_lock(); |
| 9939 | return true; |
| 9940 | } |
| 9941 | |
| 9942 | /** |
| 9943 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9944 | * |
| 9945 | * Release RTNL lock |
| 9946 | * |
| 9947 | * Return: None |
| 9948 | */ |
| 9949 | static inline void hdd_release_rtnl_lock(void) |
| 9950 | { |
| 9951 | rtnl_unlock(); |
| 9952 | } |
| 9953 | #else |
| 9954 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9955 | static inline void hdd_release_rtnl_lock(void) { } |
| 9956 | #endif |
| 9957 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9958 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9959 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9960 | /* MAX iwpriv command support */ |
| 9961 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9962 | #define PKTLOG_CLEAR_BUFF 4 |
Venkata Sharath Chandra Manchala | 27e4490 | 2019-01-28 11:29:18 -0800 | [diff] [blame] | 9963 | /* Set Maximum pktlog file size to 64MB */ |
| 9964 | #define MAX_PKTLOG_SIZE 64 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9965 | |
| 9966 | /** |
| 9967 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9968 | * @hdd_ctx: hdd context |
| 9969 | * @set_value2: pktlog buffer size value |
| 9970 | * |
| 9971 | * |
| 9972 | * Return: 0 for success or error. |
| 9973 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9974 | 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] | 9975 | { |
| 9976 | struct sir_wifi_start_log start_log = { 0 }; |
| 9977 | QDF_STATUS status; |
| 9978 | |
| 9979 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9980 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9981 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9982 | start_log.user_triggered = 1; |
| 9983 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9984 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9985 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9986 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9987 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9988 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9989 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9990 | return -EINVAL; |
| 9991 | } |
| 9992 | |
| 9993 | return 0; |
| 9994 | } |
| 9995 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9996 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9997 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9998 | * @hdd_ctx: hdd context |
| 9999 | * |
| 10000 | * Return: 0 for success or error. |
| 10001 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10002 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10003 | { |
| 10004 | struct sir_wifi_start_log start_log; |
| 10005 | QDF_STATUS status; |
| 10006 | |
| 10007 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10008 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 10009 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10010 | start_log.user_triggered = 1; |
| 10011 | start_log.size = 0; |
| 10012 | start_log.is_pktlog_buff_clear = true; |
| 10013 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10014 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10015 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10016 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10017 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10018 | return -EINVAL; |
| 10019 | } |
| 10020 | |
| 10021 | return 0; |
| 10022 | } |
| 10023 | |
| 10024 | |
| 10025 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10026 | * hdd_process_pktlog_command() - process pktlog command |
| 10027 | * @hdd_ctx: hdd context |
| 10028 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10029 | * @set_value2: pktlog buffer size value |
| 10030 | * |
| 10031 | * This function process pktlog command. |
| 10032 | * set_value2 only matters when set_value is 3 (set buff size) |
| 10033 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10034 | * |
| 10035 | * Return: 0 for success or error. |
| 10036 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10037 | 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] | 10038 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10039 | { |
| 10040 | int ret; |
| 10041 | bool enable; |
| 10042 | uint8_t user_triggered = 0; |
| 10043 | |
| 10044 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10045 | if (0 != ret) |
| 10046 | return ret; |
| 10047 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10048 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10049 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10050 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10051 | hdd_err("invalid pktlog value %d", set_value); |
| 10052 | return -EINVAL; |
| 10053 | } |
| 10054 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10055 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 10056 | if (set_value2 <= 0) { |
| 10057 | hdd_err("invalid pktlog size %d", set_value2); |
| 10058 | return -EINVAL; |
| 10059 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
Venkata Sharath Chandra Manchala | 27e4490 | 2019-01-28 11:29:18 -0800 | [diff] [blame] | 10060 | hdd_err_rl("Pktlog size is large. max value is %uMB.", |
| 10061 | MAX_PKTLOG_SIZE); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10062 | return -EINVAL; |
| 10063 | } |
| 10064 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10065 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 10066 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10067 | } |
| 10068 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10069 | /* |
| 10070 | * set_value = 0 then disable packetlog |
| 10071 | * set_value = 1 enable packetlog forcefully |
| 10072 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 10073 | * enable packetlog with AUTO type. |
| 10074 | */ |
| 10075 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 10076 | true : false; |
| 10077 | |
| 10078 | if (1 == set_value) { |
| 10079 | enable = true; |
| 10080 | user_triggered = 1; |
| 10081 | } |
| 10082 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10083 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10084 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10085 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10086 | /** |
| 10087 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 10088 | * @hdd_ctx: HDD context |
| 10089 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10090 | * @user_triggered: triggered through iwpriv |
| 10091 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10092 | * |
| 10093 | * Return: 0 on success; error number otherwise |
| 10094 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10095 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10096 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10097 | { |
| 10098 | struct sir_wifi_start_log start_log; |
| 10099 | QDF_STATUS status; |
| 10100 | |
| 10101 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10102 | start_log.verbose_level = |
| 10103 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10104 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10105 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10106 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10107 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 10108 | /* |
| 10109 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 10110 | * commands. Host uses this flag to decide whether to send pktlog |
| 10111 | * disable command to fw without sending pktlog enable command |
| 10112 | * previously. For eg, If vendor sends pktlog disable command without |
| 10113 | * sending pktlog enable command, then host discards the packet |
| 10114 | * but for iwpriv command, host will send it to fw. |
| 10115 | */ |
| 10116 | start_log.is_iwpriv_command = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10117 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10118 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10119 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10120 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10121 | return -EINVAL; |
| 10122 | } |
| 10123 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10124 | if (enable == true) |
| 10125 | hdd_ctx->is_pktlog_enabled = 1; |
| 10126 | else |
| 10127 | hdd_ctx->is_pktlog_enabled = 0; |
| 10128 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10129 | return 0; |
| 10130 | } |
| 10131 | #endif /* REMOVE_PKT_LOG */ |
| 10132 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10133 | void hdd_free_mac_address_lists(struct hdd_context *hdd_ctx) |
| 10134 | { |
| 10135 | hdd_debug("Resetting MAC address lists"); |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 10136 | qdf_mem_zero(hdd_ctx->provisioned_mac_addr, |
| 10137 | sizeof(hdd_ctx->provisioned_mac_addr)); |
| 10138 | qdf_mem_zero(hdd_ctx->derived_mac_addr, |
| 10139 | sizeof(hdd_ctx->derived_mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10140 | hdd_ctx->num_provisioned_addr = 0; |
| 10141 | hdd_ctx->num_derived_addr = 0; |
| 10142 | hdd_ctx->provisioned_intf_addr_mask = 0; |
| 10143 | hdd_ctx->derived_intf_addr_mask = 0; |
| 10144 | } |
| 10145 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10146 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10147 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 10148 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10149 | * @dev: Device Pointer |
| 10150 | * @num: Number of Valid Mac address |
| 10151 | * |
| 10152 | * Return: Pointer to MAC address buffer |
| 10153 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10154 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 10155 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10156 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10157 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10158 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10159 | |
| 10160 | /** |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10161 | * hdd_get_platform_wlan_derived_mac_buff() - API to query platform driver |
| 10162 | * for derived MAC address |
| 10163 | * @dev: Device Pointer |
| 10164 | * @num: Number of Valid Mac address |
| 10165 | * |
| 10166 | * Return: Pointer to MAC address buffer |
| 10167 | */ |
| 10168 | static uint8_t *hdd_get_platform_wlan_derived_mac_buff(struct device *dev, |
| 10169 | uint32_t *num) |
| 10170 | { |
| 10171 | return pld_get_wlan_derived_mac_address(dev, num); |
| 10172 | } |
| 10173 | |
| 10174 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10175 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 10176 | * @hdd_ctx: HDD Context |
| 10177 | * @num: Number of random mac addresses needed |
| 10178 | * |
| 10179 | * Generate random addresses using bit manipulation on the base mac address |
| 10180 | * |
| 10181 | * Return: None |
| 10182 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10183 | 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] | 10184 | { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10185 | uint32_t idx = hdd_ctx->num_derived_addr; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10186 | uint32_t iter; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10187 | uint8_t *buf = NULL; |
| 10188 | uint8_t macaddr_b3, tmp_br3; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10189 | /* |
| 10190 | * Consider first provisioned mac address as source address to derive |
| 10191 | * remaining addresses |
| 10192 | */ |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10193 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10194 | uint8_t *src = hdd_ctx->provisioned_mac_addr[0].bytes; |
| 10195 | |
| 10196 | for (iter = 0; iter < num; ++iter, ++idx) { |
| 10197 | buf = hdd_ctx->derived_mac_addr[idx].bytes; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10198 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 10199 | macaddr_b3 = buf[3]; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10200 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + idx) & |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10201 | INTF_MACADDR_MASK; |
| 10202 | macaddr_b3 += tmp_br3; |
| 10203 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 10204 | buf[0] |= 0x02; |
| 10205 | buf[3] = macaddr_b3; |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 10206 | hdd_debug(QDF_MAC_ADDR_STR, QDF_MAC_ADDR_ARRAY(buf)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10207 | hdd_ctx->num_derived_addr++; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10208 | } |
| 10209 | } |
| 10210 | |
| 10211 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10212 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10213 | * @hdd_ctx: HDD Context |
| 10214 | * |
| 10215 | * API to get mac addresses from platform driver and update the driver |
| 10216 | * structures and configure FW with the base mac address. |
| 10217 | * Return: int |
| 10218 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10219 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10220 | { |
| 10221 | uint32_t no_of_mac_addr, iter; |
| 10222 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 10223 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 10224 | uint8_t *addr, *buf; |
| 10225 | struct device *dev = hdd_ctx->parent_dev; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10226 | tSirMacAddr mac_addr; |
| 10227 | QDF_STATUS status; |
| 10228 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10229 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10230 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10231 | if (no_of_mac_addr == 0 || !addr) { |
| 10232 | hdd_debug("No mac configured from platform driver"); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10233 | return -EINVAL; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10234 | } |
| 10235 | |
| 10236 | hdd_free_mac_address_lists(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10237 | |
| 10238 | if (no_of_mac_addr > max_mac_addr) |
| 10239 | no_of_mac_addr = max_mac_addr; |
| 10240 | |
| 10241 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 10242 | |
| 10243 | 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] | 10244 | buf = hdd_ctx->provisioned_mac_addr[iter].bytes; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10245 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 10246 | hdd_info("provisioned MAC Addr [%d]" QDF_MAC_ADDR_STR, iter, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 10247 | QDF_MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10248 | } |
| 10249 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10250 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10251 | hdd_ctx->num_provisioned_addr = no_of_mac_addr; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10252 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10253 | if (hdd_ctx->config->mac_provision) { |
| 10254 | addr = hdd_get_platform_wlan_derived_mac_buff(dev, |
| 10255 | &no_of_mac_addr); |
| 10256 | |
| 10257 | if (no_of_mac_addr == 0 || !addr) |
| 10258 | hdd_warn("No derived address from platform driver"); |
| 10259 | else if (no_of_mac_addr > |
| 10260 | (max_mac_addr - hdd_ctx->num_provisioned_addr)) |
| 10261 | no_of_mac_addr = (max_mac_addr - |
| 10262 | hdd_ctx->num_provisioned_addr); |
| 10263 | |
| 10264 | for (iter = 0; iter < no_of_mac_addr; ++iter, |
| 10265 | addr += mac_addr_size) { |
| 10266 | buf = hdd_ctx->derived_mac_addr[iter].bytes; |
| 10267 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 10268 | hdd_debug("derived MAC Addr [%d]" QDF_MAC_ADDR_STR, iter, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 10269 | QDF_MAC_ADDR_ARRAY(buf)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10270 | } |
| 10271 | hdd_ctx->num_derived_addr = no_of_mac_addr; |
| 10272 | } |
| 10273 | |
| 10274 | no_of_mac_addr = hdd_ctx->num_provisioned_addr + |
| 10275 | hdd_ctx->num_derived_addr; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10276 | if (no_of_mac_addr < max_mac_addr) |
| 10277 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 10278 | no_of_mac_addr); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10279 | |
| 10280 | status = sme_set_custom_mac_addr(mac_addr); |
| 10281 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10282 | return -EAGAIN; |
| 10283 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10284 | return 0; |
| 10285 | } |
| 10286 | |
| 10287 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10288 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 10289 | * @hdd_ctx: HDD Context |
| 10290 | * |
| 10291 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 10292 | * will generate its own MAC and update it to FW. |
| 10293 | * |
| 10294 | * Return: 0 for success |
| 10295 | * Non-zero error code for failure |
| 10296 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10297 | 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] | 10298 | { |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10299 | tSirMacAddr custom_mac_addr; |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10300 | QDF_STATUS status; |
| 10301 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10302 | if (hdd_ctx->num_provisioned_addr) |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10303 | qdf_mem_copy(&custom_mac_addr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10304 | &hdd_ctx->provisioned_mac_addr[0].bytes[0], |
| 10305 | sizeof(tSirMacAddr)); |
| 10306 | else |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10307 | qdf_mem_copy(&custom_mac_addr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10308 | &hdd_ctx->derived_mac_addr[0].bytes[0], |
| 10309 | sizeof(tSirMacAddr)); |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10310 | status = sme_set_custom_mac_addr(custom_mac_addr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10311 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10312 | return -EAGAIN; |
| 10313 | return 0; |
| 10314 | } |
| 10315 | |
| 10316 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10317 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 10318 | * @hdd_ctx: HDD Context |
| 10319 | * |
| 10320 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 10321 | * is provisioned with mac addresses, driver uses it, else it will use |
| 10322 | * wlan_mac.bin to update HW MAC addresses. |
| 10323 | * |
| 10324 | * Return: None |
| 10325 | */ |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10326 | static int hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10327 | { |
| 10328 | QDF_STATUS status; |
| 10329 | int ret; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10330 | bool update_mac_addr_to_fw = true; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10331 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10332 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10333 | if (hdd_ctx->config->mac_provision || !ret) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10334 | hdd_info("using MAC address from platform driver"); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10335 | return ret; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10336 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10337 | |
| 10338 | status = hdd_update_mac_config(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10339 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 10340 | hdd_info("using MAC address from wlan_mac.bin"); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10341 | return 0; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10342 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10343 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10344 | hdd_info("using default MAC address"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10345 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10346 | /* Use fw provided MAC */ |
| 10347 | if (!qdf_is_macaddr_zero(&hdd_ctx->hw_macaddr)) { |
| 10348 | hdd_update_macaddr(hdd_ctx, hdd_ctx->hw_macaddr, false); |
| 10349 | update_mac_addr_to_fw = false; |
| 10350 | return 0; |
| 10351 | } else if (hdd_generate_macaddr_auto(hdd_ctx) != 0) { |
| 10352 | struct qdf_mac_addr mac_addr; |
| 10353 | |
| 10354 | hdd_err("MAC failure from device serial no."); |
Jeff Johnson | 51a8052 | 2018-12-11 20:19:44 -0800 | [diff] [blame] | 10355 | qdf_get_random_bytes(&mac_addr, sizeof(mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10356 | /* |
| 10357 | * Reset multicast bit (bit-0) and set |
| 10358 | * locally-administered bit |
| 10359 | */ |
| 10360 | mac_addr.bytes[0] = 0x2; |
| 10361 | hdd_update_macaddr(hdd_ctx, mac_addr, true); |
| 10362 | } |
| 10363 | |
| 10364 | if (update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10365 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10366 | if (ret) |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 10367 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10368 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10369 | return ret; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10370 | } |
| 10371 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10372 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10373 | { |
| 10374 | int vdev_id = 0; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10375 | QDF_STATUS status; |
| 10376 | bool smart_chainmask_enabled; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10377 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10378 | int vpdev = PDEV_CMD; |
| 10379 | int ret; |
| 10380 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10381 | status = ucfg_get_smart_chainmask_enabled(hdd_ctx->psoc, |
| 10382 | &smart_chainmask_enabled); |
| 10383 | if (QDF_IS_STATUS_ERROR(status)) |
| 10384 | return -EINVAL; |
| 10385 | |
| 10386 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10387 | (int)smart_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10388 | if (ret) |
| 10389 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 10390 | |
| 10391 | return ret; |
| 10392 | } |
| 10393 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10394 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10395 | { |
| 10396 | int vdev_id = 0; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10397 | QDF_STATUS status; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10398 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10399 | bool alternative_chainmask_enabled; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10400 | int vpdev = PDEV_CMD; |
| 10401 | int ret; |
| 10402 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10403 | status = ucfg_get_alternative_chainmask_enabled( |
| 10404 | hdd_ctx->psoc, |
| 10405 | &alternative_chainmask_enabled); |
| 10406 | if (QDF_IS_STATUS_ERROR(status)) |
| 10407 | return -EINVAL; |
| 10408 | |
| 10409 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10410 | (int)alternative_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10411 | if (ret) |
| 10412 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 10413 | ret); |
| 10414 | |
| 10415 | return ret; |
| 10416 | } |
| 10417 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10418 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10419 | { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10420 | QDF_STATUS status; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10421 | int vdev_id = 0; |
| 10422 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10423 | bool value; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10424 | int vpdev = PDEV_CMD; |
| 10425 | int ret; |
| 10426 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10427 | status = ucfg_fwol_get_ani_enabled(hdd_ctx->psoc, &value); |
| 10428 | if (QDF_IS_STATUS_ERROR(status)) |
| 10429 | return -EINVAL; |
| 10430 | |
| 10431 | ret = sme_cli_set_command(vdev_id, param_id, (int)value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10432 | if (ret) |
| 10433 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 10434 | |
| 10435 | return ret; |
| 10436 | } |
| 10437 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 10438 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10439 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 10440 | * @hdd_ctx: HDD context |
| 10441 | * |
| 10442 | * Pre configurations to be done at lower layer before calling cds enable. |
| 10443 | * |
| 10444 | * Return: 0 on success and errno on failure. |
| 10445 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10446 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10447 | { |
| 10448 | int ret; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10449 | uint8_t val = 0; |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10450 | QDF_STATUS status; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10451 | uint32_t arp_ac_category; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10452 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10453 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10454 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Ajit Pal Singh | 5d26961 | 2018-04-19 16:29:12 +0530 | [diff] [blame] | 10455 | /* Register HL netdev flow control callback */ |
| 10456 | cdp_hl_fc_register(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10457 | |
| 10458 | /* |
| 10459 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 10460 | * The cfg download must occur before we update the SME config |
| 10461 | * since the SME config operation must access the cfg database |
| 10462 | */ |
| 10463 | status = hdd_set_sme_config(hdd_ctx); |
| 10464 | |
| 10465 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10466 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10467 | ret = qdf_status_to_os_return(status); |
| 10468 | goto out; |
| 10469 | } |
| 10470 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 10471 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 10472 | if (QDF_STATUS_SUCCESS != status) { |
| 10473 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 10474 | ret = qdf_status_to_os_return(status); |
| 10475 | goto out; |
| 10476 | } |
| 10477 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10478 | status = ucfg_mlme_get_tx_chainmask_1ss(hdd_ctx->psoc, &val); |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10479 | if (QDF_STATUS_SUCCESS != status) { |
| 10480 | hdd_err("Get tx_chainmask_1ss from mlme failed"); |
| 10481 | ret = qdf_status_to_os_return(status); |
| 10482 | goto out; |
| 10483 | } |
| 10484 | 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] | 10485 | PDEV_CMD); |
| 10486 | if (0 != ret) { |
| 10487 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 10488 | goto out; |
| 10489 | } |
| 10490 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10491 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 10492 | if (ret) |
| 10493 | goto out; |
| 10494 | |
| 10495 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 10496 | if (ret) |
| 10497 | goto out; |
| 10498 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10499 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 10500 | if (ret) |
| 10501 | goto out; |
| 10502 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10503 | status = ucfg_get_arp_ac_category(hdd_ctx->psoc, &arp_ac_category); |
| 10504 | |
| 10505 | if (QDF_IS_STATUS_ERROR(status)) |
| 10506 | return -EINVAL; |
| 10507 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10508 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10509 | arp_ac_category, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10510 | PDEV_CMD); |
| 10511 | if (0 != ret) { |
| 10512 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10513 | arp_ac_category, ret); |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10514 | goto out; |
| 10515 | } |
| 10516 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10517 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 10518 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10519 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10520 | ret = qdf_status_to_os_return(status); |
| 10521 | goto out; |
| 10522 | } |
| 10523 | |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 10524 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10525 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10526 | ret = -EINVAL; |
| 10527 | goto out; |
| 10528 | } |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10529 | hdd_init_channel_avoidance(hdd_ctx); |
| 10530 | |
| 10531 | out: |
| 10532 | return ret; |
| 10533 | } |
| 10534 | |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10535 | #ifdef FEATURE_P2P_LISTEN_OFFLOAD |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10536 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10537 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10538 | * @context: context registered with sme_register_p2p_lo_event(). HDD |
| 10539 | * always registers a hdd context pointer |
| 10540 | * @evt:event structure pointer |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10541 | * |
| 10542 | * This is the p2p listen offload stop event handler, it sends vendor |
| 10543 | * event back to supplicant to notify the stop reason. |
| 10544 | * |
| 10545 | * Return: None |
| 10546 | */ |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10547 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10548 | struct sir_p2p_lo_event *evt) |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10549 | { |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10550 | struct hdd_context *hdd_ctx = context; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10551 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10552 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10553 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10554 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10555 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 10556 | if (!hdd_ctx) { |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10557 | hdd_err("Invalid HDD context pointer"); |
| 10558 | return; |
| 10559 | } |
| 10560 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10561 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 10562 | if (!adapter) { |
| 10563 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 10564 | evt->vdev_id); |
| 10565 | return; |
| 10566 | } |
| 10567 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10568 | vendor_event = |
| 10569 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10570 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10571 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 10572 | GFP_KERNEL); |
| 10573 | |
| 10574 | if (!vendor_event) { |
| 10575 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 10576 | return; |
| 10577 | } |
| 10578 | |
| 10579 | if (nla_put_u32(vendor_event, |
| 10580 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 10581 | evt->reason_code)) { |
| 10582 | hdd_err("nla put failed"); |
| 10583 | kfree_skb(vendor_event); |
| 10584 | return; |
| 10585 | } |
| 10586 | |
| 10587 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10588 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 10589 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10590 | } |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10591 | #else |
| 10592 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10593 | struct sir_p2p_lo_event *evt) |
| 10594 | { |
| 10595 | } |
| 10596 | #endif |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10597 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10598 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 10599 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10600 | { |
| 10601 | return sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap); |
| 10602 | } |
| 10603 | #else |
| 10604 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10605 | { |
| 10606 | return QDF_STATUS_SUCCESS; |
| 10607 | } |
| 10608 | #endif |
| 10609 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10610 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10611 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 10612 | * @hdd_ctx: HDD context |
| 10613 | * |
| 10614 | * This function sends the adaptive dwell time config configuration to the |
| 10615 | * firmware via WMA |
| 10616 | * |
| 10617 | * Return: 0 - success, < 0 - failure |
| 10618 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10619 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10620 | { |
| 10621 | QDF_STATUS status; |
| 10622 | struct adaptive_dwelltime_params dwelltime_params; |
| 10623 | |
Harprit Chhabada | d59ae76 | 2019-01-08 16:40:43 -0800 | [diff] [blame] | 10624 | status = ucfg_fwol_get_all_adaptive_dwelltime_params(hdd_ctx->psoc, |
| 10625 | &dwelltime_params); |
| 10626 | status = ucfg_fwol_set_adaptive_dwelltime_config(&dwelltime_params); |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10627 | |
| 10628 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 10629 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10630 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 10631 | return -EAGAIN; |
| 10632 | } |
| 10633 | return 0; |
| 10634 | } |
| 10635 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10636 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10637 | { |
| 10638 | QDF_STATUS status; |
| 10639 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 10640 | uint32_t i = 0; |
| 10641 | uint8_t count = 0, numentries = 0; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10642 | uint8_t dual_mac_feature; |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10643 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10644 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 10645 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10646 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 10647 | &dual_mac_feature); |
| 10648 | |
| 10649 | if (status != QDF_STATUS_SUCCESS) { |
| 10650 | hdd_err("can't get dual mac feature flag"); |
| 10651 | return -EINVAL; |
| 10652 | } |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10653 | /* check if DBS is enabled or supported */ |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10654 | if ((dual_mac_feature == DISABLE_DBS_CXN_AND_SCAN) || |
| 10655 | (dual_mac_feature == ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10656 | return -EINVAL; |
| 10657 | |
| 10658 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 10659 | dbs_scan_config, &numentries, |
| 10660 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10661 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 10662 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10663 | if (!numentries) { |
Dustin Brown | 6a8d39b | 2018-08-14 15:27:26 -0700 | [diff] [blame] | 10664 | hdd_debug("Do not send scan_selection_config"); |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10665 | return 0; |
| 10666 | } |
| 10667 | |
| 10668 | /* hdd_set_fw_log_params */ |
| 10669 | dbs_scan_params.num_clients = 0; |
| 10670 | while (count < (numentries - 2)) { |
| 10671 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 10672 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 10673 | dbs_scan_params.num_non_dbs_scans[i] = |
| 10674 | dbs_scan_config[count + 2]; |
| 10675 | dbs_scan_params.num_clients++; |
| 10676 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 10677 | dbs_scan_params.module_id[i], |
| 10678 | dbs_scan_params.num_dbs_scans[i], |
| 10679 | dbs_scan_params.num_non_dbs_scans[i]); |
| 10680 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 10681 | i++; |
| 10682 | } |
| 10683 | |
| 10684 | dbs_scan_params.pdev_id = 0; |
| 10685 | |
| 10686 | hdd_debug("clients:%d pdev:%d", |
| 10687 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 10688 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10689 | status = sme_set_dbs_scan_selection_config(hdd_ctx->mac_handle, |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10690 | &dbs_scan_params); |
| 10691 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 10692 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10693 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 10694 | return -EAGAIN; |
| 10695 | } |
| 10696 | return 0; |
| 10697 | } |
| 10698 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10699 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10700 | /** |
| 10701 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 10702 | * @hdd_ctx: HDD context |
| 10703 | * |
| 10704 | * Set auto shutdown callback to get indications from firmware to indicate |
| 10705 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 10706 | * |
| 10707 | * Return: 0 on success and errno on failure. |
| 10708 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10709 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10710 | { |
| 10711 | QDF_STATUS status; |
| 10712 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 10713 | if (!hdd_ctx->config->wlan_auto_shutdown) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10714 | return 0; |
| 10715 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10716 | status = sme_set_auto_shutdown_cb(hdd_ctx->mac_handle, |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10717 | wlan_hdd_auto_shutdown_cb); |
| 10718 | if (status != QDF_STATUS_SUCCESS) |
| 10719 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 10720 | status); |
| 10721 | |
| 10722 | return qdf_status_to_os_return(status); |
| 10723 | } |
| 10724 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10725 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10726 | { |
| 10727 | return 0; |
| 10728 | } |
| 10729 | #endif |
| 10730 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10731 | #ifdef MWS_COEX |
| 10732 | /** |
| 10733 | * hdd_set_mws_coex() - Set MWS coex configurations |
| 10734 | * @hdd_ctx: HDD context |
| 10735 | * |
| 10736 | * This function sends MWS-COEX 4G quick FTDM and |
| 10737 | * MWS-COEX 5G-NR power limit to FW |
| 10738 | * |
| 10739 | * Return: 0 on success and errno on failure. |
| 10740 | */ |
| 10741 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10742 | { |
| 10743 | int ret = 0; |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10744 | uint32_t mws_coex_4g_quick_tdm = 0, mws_coex_5g_nr_pwr_limit = 0; |
| 10745 | |
| 10746 | ucfg_mlme_get_mws_coex_4g_quick_tdm(hdd_ctx->psoc, |
| 10747 | &mws_coex_4g_quick_tdm); |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10748 | |
| 10749 | 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] | 10750 | mws_coex_4g_quick_tdm, |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10751 | PDEV_CMD); |
| 10752 | if (ret) { |
| 10753 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10754 | return ret; |
| 10755 | } |
| 10756 | |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10757 | ucfg_mlme_get_mws_coex_5g_nr_pwr_limit(hdd_ctx->psoc, |
| 10758 | &mws_coex_5g_nr_pwr_limit); |
| 10759 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10760 | 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] | 10761 | mws_coex_5g_nr_pwr_limit, |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10762 | PDEV_CMD); |
| 10763 | if (ret) { |
| 10764 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10765 | return ret; |
| 10766 | } |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10767 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10768 | return ret; |
| 10769 | } |
| 10770 | #else |
| 10771 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10772 | { |
| 10773 | return 0; |
| 10774 | } |
| 10775 | #endif |
| 10776 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10777 | /** |
| 10778 | * hdd_features_init() - Init features |
| 10779 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10780 | * |
| 10781 | * Initialize features and their feature context after WLAN firmware is up. |
| 10782 | * |
| 10783 | * Return: 0 on success and errno on failure. |
| 10784 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10785 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10786 | { |
Jeff Johnson | 19ce8d0 | 2019-02-08 22:56:23 -0800 | [diff] [blame] | 10787 | struct tx_power_limit hddtxlimit; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10788 | QDF_STATUS status; |
| 10789 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10790 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10791 | struct hdd_config *cfg; |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 10792 | bool b_cts2self, is_imps_enabled; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10793 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10794 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10795 | |
Dustin Brown | ad698ae | 2018-09-05 17:19:30 -0700 | [diff] [blame] | 10796 | ret = hdd_update_country_code(hdd_ctx); |
| 10797 | if (ret) { |
| 10798 | hdd_err("Failed to update country code; errno:%d", ret); |
| 10799 | return -EINVAL; |
| 10800 | } |
| 10801 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10802 | ret = hdd_init_mws_coex(hdd_ctx); |
| 10803 | if (ret) |
| 10804 | hdd_warn("Error initializing mws-coex"); |
| 10805 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10806 | cfg = hdd_ctx->config; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10807 | /* FW capabilities received, Set the Dot11 mode */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10808 | mac_handle = hdd_ctx->mac_handle; |
| 10809 | sme_setdef_dot11mode(mac_handle); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10810 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 10811 | ucfg_mlme_is_imps_enabled(hdd_ctx->psoc, &is_imps_enabled); |
| 10812 | hdd_set_idle_ps_config(hdd_ctx, is_imps_enabled); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10813 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10814 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10815 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 10816 | cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 10817 | cfg_dp_enable_data_stall), PDEV_CMD); |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10818 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10819 | ucfg_mlme_get_go_cts2self_for_sta(hdd_ctx->psoc, &b_cts2self); |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 10820 | if (b_cts2self) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10821 | sme_set_cts2self_for_p2p_go(mac_handle); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10822 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10823 | if (hdd_set_vc_mode_config(hdd_ctx)) |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10824 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10825 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10826 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10827 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10828 | |
| 10829 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10830 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10831 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10832 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10833 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10834 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10835 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10836 | if (ret) { |
| 10837 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10838 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10839 | } |
| 10840 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10841 | /** |
| 10842 | * In case of SSR/PDR, if pktlog was enabled manually before |
Rakshith Suresh Patkar | 6d95526 | 2019-03-13 16:51:50 +0530 | [diff] [blame] | 10843 | * SSR/PDR, then enable it again automatically after Wlan |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10844 | * device up. |
Rakshith Suresh Patkar | 6d95526 | 2019-03-13 16:51:50 +0530 | [diff] [blame] | 10845 | * During SSR/PDR, pktlog will be disabled as part of |
| 10846 | * hdd_features_deinit if pktlog is enabled in ini. |
| 10847 | * Re-enable pktlog in SSR case, if pktlog is enabled in ini. |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10848 | */ |
Rakshith Suresh Patkar | 6d95526 | 2019-03-13 16:51:50 +0530 | [diff] [blame] | 10849 | if (cds_is_packet_log_enabled() || |
| 10850 | (cds_is_driver_recovering() && hdd_ctx->is_pktlog_enabled)) |
Alok Kumar | 5a75b9d | 2018-08-31 10:55:43 +0530 | [diff] [blame] | 10851 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10852 | |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 10853 | hddtxlimit.txPower2g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_2G); |
| 10854 | hddtxlimit.txPower5g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_5G); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10855 | status = sme_txpower_limit(mac_handle, &hddtxlimit); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10856 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10857 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10858 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10859 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10860 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 10861 | status = sme_enable_disable_chanavoidind_event(mac_handle, 0); |
| 10862 | if (QDF_IS_STATUS_ERROR(status) && (status != QDF_STATUS_E_NOSUPPORT)) { |
| 10863 | hdd_err("Failed to disable Chan Avoidance Indication"); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10864 | return -EINVAL; |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10865 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10866 | |
| 10867 | /* register P2P Listen Offload event callback */ |
| 10868 | if (wma_is_p2p_lo_capable()) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10869 | sme_register_p2p_lo_event(mac_handle, hdd_ctx, |
| 10870 | wlan_hdd_p2p_lo_event_callback); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10871 | |
| 10872 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10873 | |
| 10874 | if (ret) |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10875 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10876 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10877 | wlan_hdd_init_chan_info(hdd_ctx); |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10878 | wlan_hdd_twt_init(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10879 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10880 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10881 | return 0; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10882 | } |
| 10883 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10884 | /** |
| 10885 | * hdd_features_deinit() - Deinit features |
| 10886 | * @hdd_ctx: HDD context |
| 10887 | * |
| 10888 | * De-Initialize features and their feature context. |
| 10889 | * |
| 10890 | * Return: none. |
| 10891 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10892 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10893 | { |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10894 | wlan_hdd_twt_deinit(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10895 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10896 | wlan_hdd_tsf_deinit(hdd_ctx); |
jitiphil | 4e3bef4 | 2018-11-14 14:31:13 +0530 | [diff] [blame] | 10897 | if (cds_is_packet_log_enabled()) |
| 10898 | hdd_pktlog_enable_disable(hdd_ctx, false, 0, 0); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10899 | } |
| 10900 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10901 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10902 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10903 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10904 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10905 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10906 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10907 | 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] | 10908 | { |
| 10909 | QDF_STATUS status; |
| 10910 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10911 | status = ucfg_scan_register_bcn_cb(hdd_ctx->psoc, |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10912 | wlan_cfg80211_inform_bss_frame, |
| 10913 | SCAN_CB_TYPE_INFORM_BCN); |
| 10914 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Abhishek Singh | 5ffe9de | 2019-03-05 15:42:43 +0530 | [diff] [blame] | 10915 | hdd_err("failed to register SCAN_CB_TYPE_INFORM_BCN with status code %08d [x%08x]", |
| 10916 | status, status); |
| 10917 | return status; |
| 10918 | } |
| 10919 | |
| 10920 | status = ucfg_scan_register_bcn_cb(hdd_ctx->psoc, |
| 10921 | wlan_cfg80211_unlink_bss_list, |
| 10922 | SCAN_CB_TYPE_UNLINK_BSS); |
| 10923 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10924 | 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] | 10925 | status, status); |
| 10926 | return status; |
| 10927 | } |
| 10928 | |
| 10929 | return QDF_STATUS_SUCCESS; |
| 10930 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10931 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10932 | /** |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 10933 | * hdd_v2_flow_pool_map() - Flow pool create callback when vdev is active |
| 10934 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10935 | * |
| 10936 | * Return: none. |
| 10937 | */ |
| 10938 | static void hdd_v2_flow_pool_map(int vdev_id) |
| 10939 | { |
| 10940 | QDF_STATUS status; |
| 10941 | |
| 10942 | status = cdp_flow_pool_map(cds_get_context(QDF_MODULE_ID_SOC), |
| 10943 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 10944 | vdev_id); |
| 10945 | /* |
| 10946 | * For Adrastea flow control v2 is based on FW MAP events, |
| 10947 | * so this above callback is not implemented. |
| 10948 | * Hence this is not actual failure. Dont return failure |
| 10949 | */ |
| 10950 | if ((status != QDF_STATUS_SUCCESS) && |
| 10951 | (status != QDF_STATUS_E_INVAL)) { |
| 10952 | hdd_err("vdev_id: %d, failed to create flow pool status %d", |
| 10953 | vdev_id, status); |
| 10954 | } |
| 10955 | } |
| 10956 | |
| 10957 | /** |
| 10958 | * hdd_v2_flow_pool_unmap() - Flow pool create callback when vdev is not active |
| 10959 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10960 | * |
| 10961 | * Return: none. |
| 10962 | */ |
| 10963 | static void hdd_v2_flow_pool_unmap(int vdev_id) |
| 10964 | { |
| 10965 | cdp_flow_pool_unmap(cds_get_context(QDF_MODULE_ID_SOC), |
| 10966 | cds_get_context(QDF_MODULE_ID_TXRX), vdev_id); |
| 10967 | } |
| 10968 | |
| 10969 | /** |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10970 | * hdd_action_oui_config() - Configure action_oui strings |
| 10971 | * @hdd_ctx: pointer to hdd context |
| 10972 | * |
| 10973 | * This is a HDD wrapper function which invokes ucfg api |
| 10974 | * of action_oui component to parse action oui strings. |
| 10975 | * |
| 10976 | * Return: None |
| 10977 | */ |
| 10978 | static void hdd_action_oui_config(struct hdd_context *hdd_ctx) |
| 10979 | { |
| 10980 | QDF_STATUS status; |
| 10981 | uint32_t id; |
| 10982 | uint8_t *str; |
| 10983 | |
| 10984 | if (!hdd_ctx->config->action_oui_enable) |
| 10985 | return; |
| 10986 | |
| 10987 | for (id = 0; id < ACTION_OUI_MAXIMUM_ID; id++) { |
| 10988 | str = hdd_ctx->config->action_oui_str[id]; |
| 10989 | if (!qdf_str_len(str)) |
| 10990 | continue; |
| 10991 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10992 | status = ucfg_action_oui_parse(hdd_ctx->psoc, str, id); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10993 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10994 | hdd_err("Failed to parse action_oui str: %u", id); |
| 10995 | } |
| 10996 | } |
| 10997 | |
| 10998 | /** |
| 10999 | * hdd_action_oui_send() - Send action_oui extensions to firmware |
| 11000 | * @hdd_ctx: pointer to hdd context |
| 11001 | * |
| 11002 | * This is a HDD wrapper function which invokes ucfg api |
| 11003 | * of action_oui component to send action oui extensions to firmware. |
| 11004 | * |
| 11005 | * Return: None |
| 11006 | */ |
| 11007 | static void hdd_action_oui_send(struct hdd_context *hdd_ctx) |
| 11008 | { |
| 11009 | QDF_STATUS status; |
| 11010 | |
| 11011 | if (!hdd_ctx->config->action_oui_enable) |
| 11012 | return; |
| 11013 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11014 | status = ucfg_action_oui_send(hdd_ctx->psoc); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11015 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11016 | hdd_err("Failed to send one or all action_ouis"); |
| 11017 | } |
| 11018 | |
Jeff Johnson | 0187c62 | 2019-01-04 06:39:44 -0800 | [diff] [blame] | 11019 | static void hdd_hastings_bt_war_initialize(struct hdd_context *hdd_ctx) |
| 11020 | { |
| 11021 | if (hdd_ctx->config->iface_change_wait_time) |
| 11022 | hdd_hastings_bt_war_disable_fw(hdd_ctx); |
| 11023 | else |
| 11024 | hdd_hastings_bt_war_enable_fw(hdd_ctx); |
| 11025 | } |
| 11026 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11027 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11028 | * hdd_configure_cds() - Configure cds modules |
| 11029 | * @hdd_ctx: HDD context |
| 11030 | * @adapter: Primary adapter context |
| 11031 | * |
| 11032 | * Enable Cds modules after WLAN firmware is up. |
| 11033 | * |
| 11034 | * Return: 0 on success and errno on failure. |
| 11035 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11036 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11037 | { |
| 11038 | int ret; |
| 11039 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11040 | int set_value; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11041 | mac_handle_t mac_handle; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11042 | bool enable_rts_sifsbursting; |
| 11043 | uint8_t enable_phy_reg_retention; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11044 | uint8_t max_mpdus_inampdu, is_force_1x1 = 0; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11045 | uint32_t num_abg_tx_chains = 0; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11046 | uint16_t num_11b_tx_chains = 0; |
| 11047 | uint16_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 11048 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11049 | bool value; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11050 | enum pmo_auto_pwr_detect_failure_mode auto_power_fail_mode; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11051 | bool bval = false; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11052 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11053 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11054 | |
| 11055 | hdd_action_oui_send(hdd_ctx); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11056 | status = ucfg_policy_mgr_get_force_1x1(hdd_ctx->psoc, &is_force_1x1); |
| 11057 | if (status != QDF_STATUS_SUCCESS) { |
| 11058 | hdd_err("Failed to get force 1x1 value"); |
| 11059 | goto out; |
| 11060 | } |
| 11061 | if (is_force_1x1) |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11062 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 11063 | 1, PDEV_CMD); |
| 11064 | /* set chip power save failure detected callback */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11065 | sme_set_chip_pwr_save_fail_cb(mac_handle, |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11066 | hdd_chip_pwr_save_fail_detected_cb); |
| 11067 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11068 | status = ucfg_get_max_mpdus_inampdu(hdd_ctx->psoc, |
| 11069 | &max_mpdus_inampdu); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11070 | if (status) { |
| 11071 | hdd_err("Failed to get max mpdus in ampdu value"); |
| 11072 | goto out; |
| 11073 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11074 | |
| 11075 | if (max_mpdus_inampdu) { |
| 11076 | set_value = max_mpdus_inampdu; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11077 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 11078 | set_value, PDEV_CMD); |
| 11079 | } |
| 11080 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11081 | status = ucfg_get_enable_rts_sifsbursting(hdd_ctx->psoc, |
| 11082 | &enable_rts_sifsbursting); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11083 | if (status) { |
| 11084 | hdd_err("Failed to get rts sifs bursting value"); |
| 11085 | goto out; |
| 11086 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11087 | |
| 11088 | if (enable_rts_sifsbursting) { |
| 11089 | set_value = enable_rts_sifsbursting; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11090 | sme_cli_set_command(0, |
| 11091 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 11092 | set_value, PDEV_CMD); |
| 11093 | } |
| 11094 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 11095 | ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11096 | if (value) { |
| 11097 | set_value = value; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11098 | sme_cli_set_command(0, |
| 11099 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 11100 | set_value, PDEV_CMD); |
| 11101 | } |
| 11102 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11103 | status = ucfg_mlme_get_num_11b_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11104 | &num_11b_tx_chains); |
| 11105 | if (status != QDF_STATUS_SUCCESS) { |
| 11106 | hdd_err("Failed to get num_11b_tx_chains"); |
| 11107 | goto out; |
| 11108 | } |
| 11109 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11110 | status = ucfg_mlme_get_num_11ag_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11111 | &num_11ag_tx_chains); |
| 11112 | if (status != QDF_STATUS_SUCCESS) { |
| 11113 | hdd_err("Failed to get num_11ag_tx_chains"); |
| 11114 | goto out; |
| 11115 | } |
| 11116 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11117 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 11118 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11119 | hdd_err("unable to get vht_enable2x2"); |
| 11120 | |
| 11121 | if (!bval) { |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11122 | if (num_11b_tx_chains > 1) |
| 11123 | num_11b_tx_chains = 1; |
| 11124 | if (num_11ag_tx_chains > 1) |
| 11125 | num_11ag_tx_chains = 1; |
| 11126 | } |
| 11127 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11128 | num_11b_tx_chains); |
| 11129 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11130 | num_11ag_tx_chains); |
| 11131 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 11132 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11133 | |
Paul Zhang | 02526cd | 2018-09-20 17:47:46 +0800 | [diff] [blame] | 11134 | if (!ucfg_reg_is_regdb_offloaded(hdd_ctx->psoc)) |
| 11135 | ucfg_reg_program_default_cc(hdd_ctx->pdev, |
| 11136 | hdd_ctx->reg.reg_domain); |
| 11137 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11138 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 11139 | if (ret) { |
| 11140 | hdd_err("Failed to pre-configure cds"); |
| 11141 | goto out; |
| 11142 | } |
| 11143 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11144 | /* Always get latest IPA resources allocated from cds_open and configure |
| 11145 | * IPA module before configuring them to FW. Sequence required as crash |
| 11146 | * observed otherwise. |
| 11147 | */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11148 | if (ucfg_ipa_uc_ol_init(hdd_ctx->pdev, |
| 11149 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 11150 | hdd_err("Failed to setup pipes"); |
| 11151 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11152 | } |
| 11153 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11154 | /* |
| 11155 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 11156 | * else |
| 11157 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11158 | status = cds_enable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11159 | |
| 11160 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11161 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11162 | goto out; |
| 11163 | } |
| 11164 | |
| 11165 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 11166 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11167 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11168 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11169 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11170 | status = hdd_register_bcn_cb(hdd_ctx); |
| 11171 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 11172 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11173 | goto cds_disable; |
| 11174 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11175 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11176 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11177 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11178 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11179 | |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 11180 | /* Donot disable rx offload on concurrency for lithium based targets */ |
| 11181 | if (!(hdd_ctx->target_type == TARGET_TYPE_QCA6290 || |
| 11182 | hdd_ctx->target_type == TARGET_TYPE_QCA6390)) |
| 11183 | if (hdd_ctx->ol_enable) |
| 11184 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 11185 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11186 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 11187 | 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] | 11188 | dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; |
| 11189 | dp_cbs.hdd_v2_flow_pool_unmap = hdd_v2_flow_pool_unmap; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11190 | status = policy_mgr_register_dp_cb(hdd_ctx->psoc, &dp_cbs); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11191 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11192 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11193 | goto cds_disable; |
| 11194 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11195 | status = policy_mgr_register_mode_change_cb(hdd_ctx->psoc, |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11196 | wlan_hdd_send_mode_change_event); |
| 11197 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 11198 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 11199 | goto cds_disable; |
| 11200 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11201 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 11202 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 11203 | hdd_debug("enhance green ap is not enabled"); |
| 11204 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 11205 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 11206 | hdd_debug("Failed to set wow pulse"); |
| 11207 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 11208 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
Manikandan Mohan | 66df7fc | 2019-01-08 17:57:05 -0800 | [diff] [blame] | 11209 | ucfg_fwol_get_gcmp_enable(hdd_ctx->psoc), PDEV_CMD); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11210 | |
| 11211 | auto_power_fail_mode = |
| 11212 | ucfg_pmo_get_auto_power_fail_mode(hdd_ctx->psoc); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11213 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11214 | auto_power_fail_mode, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11215 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11216 | status = ucfg_get_enable_phy_reg_retention(hdd_ctx->psoc, |
| 11217 | &enable_phy_reg_retention); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11218 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11219 | if (QDF_IS_STATUS_ERROR(status)) |
| 11220 | return -EINVAL; |
| 11221 | |
| 11222 | if (enable_phy_reg_retention) |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11223 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11224 | enable_phy_reg_retention, PDEV_CMD); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11225 | |
Jeff Johnson | 0187c62 | 2019-01-04 06:39:44 -0800 | [diff] [blame] | 11226 | hdd_hastings_bt_war_initialize(hdd_ctx); |
| 11227 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11228 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11229 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11230 | cds_disable: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11231 | cds_disable(hdd_ctx->psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11232 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11233 | out: |
| 11234 | return -EINVAL; |
| 11235 | } |
| 11236 | |
| 11237 | /** |
| 11238 | * hdd_deconfigure_cds() -De-Configure cds |
| 11239 | * @hdd_ctx: HDD context |
| 11240 | * |
| 11241 | * Deconfigure Cds modules before WLAN firmware is down. |
| 11242 | * |
| 11243 | * Return: 0 on success and errno on failure. |
| 11244 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11245 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11246 | { |
| 11247 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11248 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11249 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11250 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 11251 | |
| 11252 | /* De-init features */ |
| 11253 | hdd_features_deinit(hdd_ctx); |
| 11254 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11255 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->psoc); |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 11256 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11257 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11258 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11259 | qdf_status = cds_disable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11260 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11261 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 11262 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11263 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11264 | } |
| 11265 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11266 | 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] | 11267 | hdd_err("Failed to disconnect pipes"); |
| 11268 | ret = -EINVAL; |
| 11269 | } |
| 11270 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11271 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11272 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11273 | } |
| 11274 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11275 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 11276 | static void hdd_deregister_policy_manager_callback( |
| 11277 | struct wlan_objmgr_psoc *psoc) |
| 11278 | { |
| 11279 | if (QDF_STATUS_SUCCESS != |
| 11280 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 11281 | hdd_err("HDD callback deregister with policy manager failed"); |
| 11282 | } |
| 11283 | } |
| 11284 | #else |
| 11285 | static void hdd_deregister_policy_manager_callback( |
| 11286 | struct wlan_objmgr_psoc *psoc) |
| 11287 | { |
| 11288 | } |
| 11289 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11290 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11291 | 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] | 11292 | { |
| 11293 | void *hif_ctx; |
| 11294 | qdf_device_t qdf_ctx; |
| 11295 | QDF_STATUS qdf_status; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11296 | bool is_recovery_stop = cds_is_driver_recovering(); |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11297 | int ret = 0; |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11298 | int debugfs_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11299 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11300 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11301 | hdd_enter(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11302 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11303 | if (!qdf_ctx) { |
| 11304 | hdd_err("QDF device context NULL"); |
| 11305 | return -EINVAL; |
| 11306 | } |
| 11307 | |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11308 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11309 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11310 | debugfs_threads = hdd_return_debugfs_threads_count(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11311 | |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 11312 | if (debugfs_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
| 11313 | hdd_warn("Debugfs threads %d, wiphy suspend %d", |
| 11314 | debugfs_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11315 | |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11316 | if (IS_IDLE_STOP && !ftm_mode) { |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 11317 | hdd_psoc_idle_timer_start(hdd_ctx); |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11318 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11319 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11320 | return 0; |
| 11321 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 11322 | } |
| 11323 | |
Liangwei Dong | 857cb84 | 2019-04-28 04:55:17 -0400 | [diff] [blame] | 11324 | hdd_deregister_policy_manager_callback(hdd_ctx->psoc); |
| 11325 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 11326 | /* free user wowl patterns */ |
| 11327 | hdd_free_user_wowl_ptrns(); |
| 11328 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11329 | switch (hdd_ctx->driver_status) { |
| 11330 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11331 | hdd_debug("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11332 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11333 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11334 | hdd_debug("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11335 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11336 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 11337 | hdd_info("Wlan transitioning (CLOSED <- ENABLED)"); |
| 11338 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11339 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE || |
| 11340 | hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 11341 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11342 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 11343 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11344 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11345 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11346 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11347 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11348 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11349 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11350 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11351 | break; |
| 11352 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11353 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11354 | hdd_ctx->driver_status); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11355 | ret = -EINVAL; |
| 11356 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11357 | } |
| 11358 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11359 | hdd_sysfs_destroy_powerstats_interface(); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11360 | hdd_sysfs_destroy_version_interface(); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11361 | hdd_sysfs_destroy_driver_root_obj(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11362 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11363 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11364 | if (hdd_get_conparam() != QDF_GLOBAL_EPPING_MODE) { |
| 11365 | qdf_status = cds_post_disable(); |
| 11366 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11367 | hdd_err("Failed to process post CDS disable! :%d", |
| 11368 | qdf_status); |
| 11369 | ret = -EINVAL; |
| 11370 | QDF_ASSERT(0); |
| 11371 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11372 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11373 | /* De-register the SME callbacks */ |
| 11374 | hdd_deregister_cb(hdd_ctx); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 11375 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11376 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 11377 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11378 | qdf_status = cds_dp_close(hdd_ctx->psoc); |
| 11379 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11380 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 11381 | ret = -EINVAL; |
| 11382 | QDF_ASSERT(0); |
| 11383 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11384 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11385 | qdf_status = cds_close(hdd_ctx->psoc); |
| 11386 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11387 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
| 11388 | ret = -EINVAL; |
| 11389 | QDF_ASSERT(0); |
| 11390 | } |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11391 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11392 | qdf_status = wbuff_module_deinit(); |
| 11393 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 11394 | hdd_err("WBUFF de-init unsuccessful; status: %d", |
| 11395 | qdf_status); |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11396 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11397 | hdd_component_pdev_close(hdd_ctx->pdev); |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11398 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11399 | hdd_component_psoc_close(hdd_ctx->psoc); |
| 11400 | dispatcher_pdev_close(hdd_ctx->pdev); |
| 11401 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 11402 | if (ret) { |
| 11403 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 11404 | QDF_ASSERT(0); |
| 11405 | } |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11406 | } |
| 11407 | |
| 11408 | /* |
| 11409 | * Reset total mac phy during module stop such that during |
| 11410 | * next module start same psoc is used to populate new service |
| 11411 | * ready data |
| 11412 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11413 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11414 | if (tgt_hdl) |
| 11415 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 11416 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11417 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11418 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 11419 | if (!hif_ctx) { |
| 11420 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11421 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11422 | } |
| 11423 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 11424 | if (hdd_ctx->target_hw_name) { |
| 11425 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 11426 | hdd_ctx->target_hw_name = NULL; |
| 11427 | } |
| 11428 | |
Lin Bai | 7bae103 | 2019-04-30 12:29:36 +0800 | [diff] [blame] | 11429 | if (hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) { |
Visweswara Tanuku | c949ad2 | 2019-03-20 13:00:30 +0530 | [diff] [blame] | 11430 | epping_disable(); |
| 11431 | epping_close(); |
| 11432 | } |
| 11433 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 11434 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11435 | |
| 11436 | ol_cds_free(); |
| 11437 | |
Dustin Brown | c2a156e | 2018-10-25 16:56:27 -0700 | [diff] [blame] | 11438 | if (IS_IDLE_STOP) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11439 | ret = pld_power_off(qdf_ctx->dev); |
| 11440 | if (ret) |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11441 | hdd_err("Failed to power down device; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11442 | } |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11443 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11444 | /* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */ |
| 11445 | wlan_hdd_free_cache_channels(hdd_ctx); |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11446 | |
Sourav Mohapatra | 9036f65 | 2019-04-02 15:02:59 +0530 | [diff] [blame] | 11447 | /* Free the resources allocated while storing SAR config. These needs |
| 11448 | * to be freed only in the case when it is not SSR. As in the case of |
| 11449 | * SSR, the values needs to be intact so that it can be restored during |
| 11450 | * reinit path. |
| 11451 | */ |
| 11452 | if (!is_recovery_stop) |
| 11453 | wlan_hdd_free_sar_config(hdd_ctx); |
| 11454 | |
Jingxiang Ge | 3de0275 | 2019-01-29 15:47:03 +0800 | [diff] [blame] | 11455 | hdd_sap_destroy_ctx_all(hdd_ctx, is_recovery_stop); |
| 11456 | |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 11457 | hdd_check_for_leaks(hdd_ctx, is_recovery_stop); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 11458 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11459 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11460 | /* Once the firmware sequence is completed reset this flag */ |
| 11461 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11462 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11463 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11464 | |
Kai Liu | eabb1df | 2018-11-08 14:58:54 +0800 | [diff] [blame] | 11465 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, PLD_BUS_WIDTH_NONE); |
| 11466 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11467 | done: |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11468 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11469 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11470 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11471 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11472 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11473 | } |
| 11474 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11475 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11476 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11477 | * hdd_state_info_dump() - prints state information of hdd layer |
| 11478 | * @buf: buffer pointer |
| 11479 | * @size: size of buffer to be filled |
| 11480 | * |
| 11481 | * This function is used to dump state information of hdd layer |
| 11482 | * |
| 11483 | * Return: None |
| 11484 | */ |
| 11485 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 11486 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11487 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 11488 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11489 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11490 | uint16_t len = 0; |
| 11491 | char *buf = *buf_ptr; |
| 11492 | |
| 11493 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11494 | if (!hdd_ctx) { |
| 11495 | hdd_err("Failed to get hdd context "); |
| 11496 | return; |
| 11497 | } |
| 11498 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11499 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11500 | |
| 11501 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 11502 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11503 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 11504 | "\n is_scheduler_suspended %d", |
| 11505 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11506 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11507 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11508 | if (adapter->dev) |
| 11509 | len += scnprintf(buf + len, *size - len, |
| 11510 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 11511 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11512 | "\n device_mode: %d", adapter->device_mode); |
| 11513 | switch (adapter->device_mode) { |
| 11514 | case QDF_STA_MODE: |
| 11515 | case QDF_P2P_CLIENT_MODE: |
| 11516 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11517 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 11518 | "\n conn_state: %d", |
| 11519 | hdd_sta_ctx->conn_info.conn_state); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11520 | break; |
| 11521 | |
| 11522 | default: |
| 11523 | break; |
| 11524 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11525 | } |
| 11526 | |
| 11527 | *size -= len; |
| 11528 | *buf_ptr += len; |
| 11529 | } |
| 11530 | |
| 11531 | /** |
| 11532 | * hdd_register_debug_callback() - registration function for hdd layer |
| 11533 | * to print hdd state information |
| 11534 | * |
| 11535 | * Return: None |
| 11536 | */ |
| 11537 | static void hdd_register_debug_callback(void) |
| 11538 | { |
| 11539 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 11540 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11541 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 11542 | static void hdd_register_debug_callback(void) |
| 11543 | { |
| 11544 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11545 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11546 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11547 | /* |
| 11548 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 11549 | * |
| 11550 | * This function is used to create bug report lock |
| 11551 | * |
| 11552 | * Return: None |
| 11553 | */ |
| 11554 | static void wlan_init_bug_report_lock(void) |
| 11555 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 11556 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11557 | |
| 11558 | p_cds_context = cds_get_global_context(); |
| 11559 | if (!p_cds_context) { |
| 11560 | hdd_err("cds context is NULL"); |
| 11561 | return; |
| 11562 | } |
| 11563 | |
| 11564 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 11565 | } |
| 11566 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11567 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11568 | void hdd_dp_trace_init(struct hdd_config *config) |
| 11569 | { |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11570 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 11571 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 11572 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 11573 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 11574 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 11575 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 11576 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11577 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11578 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11579 | if (!config->enable_dp_trace) { |
| 11580 | hdd_err("dp trace is disabled from ini"); |
| 11581 | return; |
| 11582 | } |
| 11583 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11584 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 11585 | &num_entries, sizeof(config_params)); |
| 11586 | |
| 11587 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11588 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11589 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11590 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11591 | else if (bw_compute_interval > 1000) { |
| 11592 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 11593 | thresh_time_limit = 1; |
| 11594 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11595 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 11596 | |
| 11597 | switch (num_entries) { |
| 11598 | case 4: |
| 11599 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11600 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11601 | case 3: |
| 11602 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11603 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11604 | case 2: |
| 11605 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11606 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11607 | case 1: |
| 11608 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11609 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11610 | default: |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 11611 | hdd_debug("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 11612 | live_mode, thresh, thresh_time_limit, |
| 11613 | verbosity, proto_bitmap); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11614 | }; |
| 11615 | |
| 11616 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 11617 | verbosity, proto_bitmap); |
| 11618 | |
| 11619 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11620 | #endif |
| 11621 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11622 | #ifdef DISABLE_CHANNEL_LIST |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11623 | 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] | 11624 | { |
| 11625 | return qdf_mutex_create(&hdd_ctx->cache_channel_lock); |
| 11626 | } |
| 11627 | #else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11628 | 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] | 11629 | { |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11630 | return QDF_STATUS_SUCCESS; |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11631 | } |
| 11632 | #endif |
| 11633 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11634 | static QDF_STATUS hdd_open_adapter_no_trans(struct hdd_context *hdd_ctx, |
| 11635 | enum QDF_OPMODE op_mode, |
| 11636 | const char *iface_name, |
| 11637 | uint8_t *mac_addr_bytes) |
| 11638 | { |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11639 | struct osif_vdev_sync *vdev_sync; |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11640 | struct hdd_adapter *adapter; |
| 11641 | QDF_STATUS status; |
| 11642 | int errno; |
| 11643 | |
| 11644 | QDF_BUG(rtnl_is_locked()); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11645 | |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11646 | errno = osif_vdev_sync_create(hdd_ctx->parent_dev, &vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11647 | if (errno) |
| 11648 | return qdf_status_from_os_return(errno); |
| 11649 | |
| 11650 | adapter = hdd_open_adapter(hdd_ctx, op_mode, iface_name, |
| 11651 | mac_addr_bytes, NET_NAME_UNKNOWN, true); |
| 11652 | if (!adapter) { |
| 11653 | status = QDF_STATUS_E_INVAL; |
| 11654 | goto destroy_sync; |
| 11655 | } |
| 11656 | |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11657 | osif_vdev_sync_register(adapter->dev, vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11658 | |
| 11659 | return QDF_STATUS_SUCCESS; |
| 11660 | |
| 11661 | destroy_sync: |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11662 | osif_vdev_sync_destroy(vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11663 | |
| 11664 | return status; |
| 11665 | } |
| 11666 | |
| 11667 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 11668 | /** |
| 11669 | * hdd_open_p2p_interface - Open P2P interface |
| 11670 | * @hdd_ctx: HDD context |
| 11671 | * |
| 11672 | * Return: QDF_STATUS |
| 11673 | */ |
| 11674 | static QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
| 11675 | { |
| 11676 | QDF_STATUS status; |
| 11677 | bool p2p_dev_addr_admin; |
| 11678 | bool is_p2p_locally_administered = false; |
| 11679 | |
| 11680 | cfg_p2p_get_device_addr_admin(hdd_ctx->psoc, &p2p_dev_addr_admin); |
| 11681 | |
| 11682 | if (p2p_dev_addr_admin) { |
| 11683 | if (hdd_ctx->num_provisioned_addr && |
| 11684 | !(hdd_ctx->provisioned_mac_addr[0].bytes[0] & 0x02)) { |
| 11685 | hdd_ctx->p2p_device_address = |
| 11686 | hdd_ctx->provisioned_mac_addr[0]; |
| 11687 | |
| 11688 | /* |
| 11689 | * Generate the P2P Device Address. This consists of |
| 11690 | * the device's primary MAC address with the locally |
| 11691 | * administered bit set. |
| 11692 | */ |
| 11693 | |
| 11694 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
| 11695 | is_p2p_locally_administered = true; |
| 11696 | } else if (!(hdd_ctx->derived_mac_addr[0].bytes[0] & 0x02)) { |
| 11697 | hdd_ctx->p2p_device_address = |
| 11698 | hdd_ctx->derived_mac_addr[0]; |
| 11699 | /* |
| 11700 | * Generate the P2P Device Address. This consists of |
| 11701 | * the device's primary MAC address with the locally |
| 11702 | * administered bit set. |
| 11703 | */ |
| 11704 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
| 11705 | is_p2p_locally_administered = true; |
| 11706 | } |
| 11707 | } |
| 11708 | if (!is_p2p_locally_administered) { |
| 11709 | uint8_t *p2p_dev_addr; |
| 11710 | |
| 11711 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx, |
| 11712 | QDF_P2P_DEVICE_MODE); |
| 11713 | if (!p2p_dev_addr) { |
| 11714 | hdd_err("Failed to get MAC address for new p2p device"); |
| 11715 | return QDF_STATUS_E_INVAL; |
| 11716 | } |
| 11717 | |
| 11718 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
| 11719 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
| 11720 | } |
| 11721 | |
| 11722 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_P2P_DEVICE_MODE, |
| 11723 | "p2p%d", |
| 11724 | hdd_ctx->p2p_device_address.bytes); |
| 11725 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11726 | hdd_err("Failed to open p2p interface"); |
| 11727 | return QDF_STATUS_E_INVAL; |
| 11728 | } |
| 11729 | |
| 11730 | return QDF_STATUS_SUCCESS; |
| 11731 | } |
| 11732 | #else |
| 11733 | static inline QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
| 11734 | { |
| 11735 | return QDF_STATUS_SUCCESS; |
| 11736 | } |
| 11737 | #endif |
| 11738 | |
| 11739 | static QDF_STATUS hdd_open_ocb_interface(struct hdd_context *hdd_ctx) |
| 11740 | { |
| 11741 | QDF_STATUS status; |
| 11742 | uint8_t *mac_addr; |
| 11743 | |
| 11744 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_OCB_MODE); |
| 11745 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_OCB_MODE, |
| 11746 | "wlanocb%d", mac_addr); |
| 11747 | if (QDF_IS_STATUS_ERROR(status)) |
| 11748 | hdd_err("Failed to open 802.11p interface"); |
| 11749 | |
| 11750 | return status; |
| 11751 | } |
| 11752 | |
| 11753 | static QDF_STATUS hdd_open_concurrent_interface(struct hdd_context *hdd_ctx) |
| 11754 | { |
| 11755 | QDF_STATUS status; |
| 11756 | const char *iface_name; |
| 11757 | uint8_t *mac_addr; |
| 11758 | |
| 11759 | if (qdf_str_eq(hdd_ctx->config->enable_concurrent_sta, "")) |
| 11760 | return QDF_STATUS_SUCCESS; |
| 11761 | |
| 11762 | iface_name = hdd_ctx->config->enable_concurrent_sta; |
| 11763 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_STA_MODE); |
| 11764 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_STA_MODE, |
| 11765 | iface_name, mac_addr); |
| 11766 | if (QDF_IS_STATUS_ERROR(status)) |
| 11767 | hdd_err("Failed to open concurrent station interface"); |
| 11768 | |
| 11769 | return status; |
| 11770 | } |
| 11771 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11772 | static QDF_STATUS |
| 11773 | hdd_open_adapters_for_mission_mode(struct hdd_context *hdd_ctx) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11774 | { |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11775 | enum dot11p_mode dot11p_mode; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11776 | QDF_STATUS status; |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11777 | uint8_t *mac_addr; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11778 | |
| 11779 | ucfg_mlme_get_dot11p_mode(hdd_ctx->psoc, &dot11p_mode); |
| 11780 | |
| 11781 | /* Create only 802.11p interface? */ |
| 11782 | if (dot11p_mode == CFG_11P_STANDALONE) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11783 | return hdd_open_ocb_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11784 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11785 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_STA_MODE); |
| 11786 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_STA_MODE, |
| 11787 | "wlan%d", mac_addr); |
| 11788 | if (QDF_IS_STATUS_ERROR(status)) |
| 11789 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11790 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11791 | /* opening concurrent STA is best effort, continue on error */ |
| 11792 | hdd_open_concurrent_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11793 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11794 | status = hdd_open_p2p_interface(hdd_ctx); |
| 11795 | if (status) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11796 | goto err_close_adapters; |
| 11797 | |
| 11798 | /* Open 802.11p Interface */ |
| 11799 | if (dot11p_mode == CFG_11P_CONCURRENT) { |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11800 | status = hdd_open_ocb_interface(hdd_ctx); |
| 11801 | if (QDF_IS_STATUS_ERROR(status)) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11802 | goto err_close_adapters; |
| 11803 | } |
| 11804 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11805 | return QDF_STATUS_SUCCESS; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11806 | |
| 11807 | err_close_adapters: |
| 11808 | hdd_close_all_adapters(hdd_ctx, true); |
| 11809 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11810 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11811 | } |
| 11812 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11813 | 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] | 11814 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11815 | 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] | 11816 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11817 | return hdd_open_adapter_no_trans(hdd_ctx, QDF_FTM_MODE, |
| 11818 | "wlan%d", mac_addr); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11819 | } |
| 11820 | |
| 11821 | static QDF_STATUS |
| 11822 | hdd_open_adapters_for_monitor_mode(struct hdd_context *hdd_ctx) |
| 11823 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11824 | 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] | 11825 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11826 | return hdd_open_adapter_no_trans(hdd_ctx, QDF_MONITOR_MODE, |
| 11827 | "wlan%d", mac_addr); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11828 | } |
| 11829 | |
| 11830 | static QDF_STATUS hdd_open_adapters_for_epping_mode(struct hdd_context *hdd_ctx) |
| 11831 | { |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11832 | epping_enable_adapter(); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11833 | return QDF_STATUS_SUCCESS; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11834 | } |
| 11835 | |
| 11836 | typedef QDF_STATUS (*hdd_open_mode_handler)(struct hdd_context *hdd_ctx); |
| 11837 | |
| 11838 | static const hdd_open_mode_handler |
| 11839 | hdd_open_mode_handlers[QDF_GLOBAL_MAX_MODE] = { |
| 11840 | [QDF_GLOBAL_MISSION_MODE] = hdd_open_adapters_for_mission_mode, |
| 11841 | [QDF_GLOBAL_FTM_MODE] = hdd_open_adapters_for_ftm_mode, |
| 11842 | [QDF_GLOBAL_MONITOR_MODE] = hdd_open_adapters_for_monitor_mode, |
| 11843 | [QDF_GLOBAL_EPPING_MODE] = hdd_open_adapters_for_epping_mode, |
| 11844 | }; |
| 11845 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11846 | static QDF_STATUS hdd_open_adapters_for_mode(struct hdd_context *hdd_ctx, |
| 11847 | enum QDF_GLOBAL_MODE driver_mode) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11848 | { |
| 11849 | QDF_STATUS status; |
| 11850 | |
| 11851 | if (driver_mode < 0 || |
| 11852 | driver_mode >= QDF_GLOBAL_MAX_MODE || |
| 11853 | !hdd_open_mode_handlers[driver_mode]) { |
| 11854 | hdd_err("Driver mode %d not supported", driver_mode); |
| 11855 | return -ENOTSUPP; |
| 11856 | } |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11857 | |
| 11858 | hdd_hold_rtnl_lock(); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11859 | status = hdd_open_mode_handlers[driver_mode](hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11860 | hdd_release_rtnl_lock(); |
| 11861 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11862 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11863 | } |
| 11864 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11865 | int hdd_wlan_startup(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11866 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11867 | QDF_STATUS status; |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11868 | int errno; |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 11869 | bool is_imps_enabled; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11870 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11871 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11872 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11873 | hdd_action_oui_config(hdd_ctx); |
| 11874 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11875 | qdf_nbuf_init_replenish_timer(); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11876 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11877 | status = wlan_hdd_cache_chann_mutex_create(hdd_ctx); |
| 11878 | if (QDF_IS_STATUS_ERROR(status)) |
| 11879 | return qdf_status_to_os_return(status); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11880 | |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 11881 | #ifdef FEATURE_WLAN_CH_AVOID |
| 11882 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 11883 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11884 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11885 | osif_request_manager_init(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11886 | hdd_driver_memdump_init(); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11887 | hdd_bus_bandwidth_init(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11888 | |
Arunk Khandavalli | 5ff037547 | 2019-01-11 17:26:47 +0530 | [diff] [blame] | 11889 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 11890 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
| 11891 | QDF_TIMER_TYPE_SW, |
| 11892 | hdd_skip_acs_scan_timer_handler, |
| 11893 | hdd_ctx); |
| 11894 | if (QDF_IS_STATUS_ERROR(status)) |
| 11895 | hdd_err("Failed to init ACS Skip timer"); |
| 11896 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
| 11897 | #endif |
| 11898 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11899 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 11900 | if (errno) { |
| 11901 | hdd_err("Failed to start modules; errno:%d", errno); |
| 11902 | goto memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11903 | } |
| 11904 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11905 | if (hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) |
| 11906 | return 0; |
| 11907 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 11908 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11909 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11910 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 11911 | if (!hdd_ctx->mac_handle) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11912 | hdd_err("Mac Handle is null"); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11913 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11914 | } |
| 11915 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11916 | errno = hdd_wiphy_init(hdd_ctx); |
| 11917 | if (errno) { |
| 11918 | hdd_err("Failed to initialize wiphy; errno:%d", errno); |
| 11919 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11920 | } |
| 11921 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11922 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 11923 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 11924 | errno = hdd_initialize_mac_address(hdd_ctx); |
| 11925 | if (errno) { |
| 11926 | hdd_err("MAC initializtion failed: %d", errno); |
| 11927 | goto unregister_wiphy; |
| 11928 | } |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 11929 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11930 | errno = register_netdevice_notifier(&hdd_netdev_notifier); |
| 11931 | if (errno) { |
| 11932 | hdd_err("register_netdevice_notifier failed; errno:%d", errno); |
| 11933 | goto unregister_wiphy; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11934 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 11935 | |
Sandeep Puligilla | 3461878 | 2019-01-04 17:42:42 -0800 | [diff] [blame] | 11936 | wlan_hdd_update_11n_mode(hdd_ctx); |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 11937 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 11938 | hdd_lpass_notify_wlan_version(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11939 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11940 | errno = hdd_register_notifiers(hdd_ctx); |
| 11941 | if (errno) |
Arun Kumar Khandavalli | 4b6e218 | 2019-04-29 18:32:09 +0530 | [diff] [blame] | 11942 | goto unregister_netdev; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 11943 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11944 | status = wlansap_global_init(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11945 | if (QDF_IS_STATUS_ERROR(status)) |
| 11946 | goto unregister_notifiers; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11947 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 11948 | ucfg_mlme_is_imps_enabled(hdd_ctx->psoc, &is_imps_enabled); |
| 11949 | hdd_set_idle_ps_config(hdd_ctx, is_imps_enabled); |
Arun Kumar Khandavalli | deda5a8 | 2019-03-11 15:32:19 +0530 | [diff] [blame] | 11950 | hdd_debugfs_mws_coex_info_init(hdd_ctx); |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame^] | 11951 | wlan_cfg80211_init_interop_issues_ap(hdd_ctx->pdev); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11952 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11953 | hdd_exit(); |
| 11954 | |
| 11955 | return 0; |
| 11956 | |
| 11957 | unregister_notifiers: |
| 11958 | hdd_unregister_notifiers(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 | unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11961 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 11962 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11963 | unregister_wiphy: |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 11964 | qdf_dp_trace_deinit(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11965 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11966 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11967 | stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11968 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11969 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11970 | memdump_deinit: |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11971 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11972 | hdd_driver_memdump_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11973 | osif_request_manager_deinit(); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11974 | qdf_nbuf_deinit_replenish_timer(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 11975 | |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 11976 | if (cds_is_fw_down()) |
| 11977 | hdd_err("Not setting the complete event as fw is down"); |
| 11978 | else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11979 | hdd_start_complete(errno); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11980 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11981 | hdd_exit(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11982 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11983 | return errno; |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11984 | } |
| 11985 | |
| 11986 | QDF_STATUS hdd_psoc_create_vdevs(struct hdd_context *hdd_ctx) |
| 11987 | { |
| 11988 | enum QDF_GLOBAL_MODE driver_mode = hdd_get_conparam(); |
| 11989 | QDF_STATUS status; |
| 11990 | |
| 11991 | status = hdd_open_adapters_for_mode(hdd_ctx, driver_mode); |
| 11992 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11993 | hdd_err("Failed to create vdevs; status:%d", status); |
| 11994 | return status; |
| 11995 | } |
| 11996 | |
| 11997 | if (hdd_ctx->rps) |
| 11998 | hdd_set_rps_cpu_mask(hdd_ctx); |
| 11999 | |
| 12000 | if (driver_mode != QDF_GLOBAL_FTM_MODE) |
| 12001 | hdd_psoc_idle_timer_start(hdd_ctx); |
| 12002 | |
| 12003 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12004 | } |
| 12005 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12006 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12007 | * hdd_wlan_update_target_info() - update target type info |
| 12008 | * @hdd_ctx: HDD context |
| 12009 | * @context: hif context |
| 12010 | * |
| 12011 | * Update target info received from firmware in hdd context |
| 12012 | * Return:None |
| 12013 | */ |
| 12014 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12015 | 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] | 12016 | { |
| 12017 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 12018 | |
| 12019 | if (!tgt_info) { |
| 12020 | hdd_err("Target info is Null"); |
| 12021 | return; |
| 12022 | } |
| 12023 | |
| 12024 | hdd_ctx->target_type = tgt_info->target_type; |
| 12025 | } |
| 12026 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12027 | 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] | 12028 | { |
| 12029 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12030 | int status; |
| 12031 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12032 | struct osif_request *request = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12033 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12034 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12035 | |
| 12036 | if (!rsp) { |
| 12037 | hdd_err("data is null"); |
| 12038 | return; |
| 12039 | } |
| 12040 | |
| 12041 | status = wlan_hdd_validate_context(hdd_ctx); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12042 | if (status != 0) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12043 | return; |
| 12044 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12045 | request = osif_request_get(context); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12046 | if (!request) { |
| 12047 | hdd_err("obselete request"); |
| 12048 | return; |
| 12049 | } |
| 12050 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12051 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12052 | if ((!adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12053 | hdd_err("Invalid adapter or adapter has invalid magic"); |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12054 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12055 | return; |
| 12056 | } |
| 12057 | |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 12058 | hdd_debug("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 12059 | hdd_debug("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 12060 | hdd_debug("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 12061 | hdd_debug("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 12062 | hdd_debug("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 12063 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 12064 | hdd_debug("rsp->dad_detected :%x", rsp->dad_detected); |
| 12065 | hdd_debug("rsp->connect_status :%x", rsp->connect_status); |
| 12066 | hdd_debug("rsp->ba_session_establishment_status :%x", |
| 12067 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12068 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12069 | 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] | 12070 | adapter->dad |= rsp->dad_detected; |
| 12071 | adapter->con_status = rsp->connect_status; |
| 12072 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12073 | /* Flag true indicates connectivity check stats present. */ |
| 12074 | if (rsp->connect_stats_present) { |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 12075 | hdd_debug("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 12076 | hdd_debug("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12077 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 12078 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 12079 | rsp->icmpv4_rsp_recvd; |
| 12080 | } |
| 12081 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12082 | osif_request_complete(request); |
| 12083 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12084 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12085 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12086 | } |
| 12087 | |
Visweswara Tanuku | 633976b | 2019-01-07 16:13:12 +0530 | [diff] [blame] | 12088 | #ifdef WLAN_FEATURE_MOTION_DETECTION |
| 12089 | /** |
| 12090 | * hdd_md_host_evt_cb - Callback for Motion Detection Event |
| 12091 | * @ctx: HDD context |
| 12092 | * @event: motion detect event |
| 12093 | * |
| 12094 | * Callback for Motion Detection Event. Re-enables Motion |
| 12095 | * Detection again upon event |
| 12096 | * |
| 12097 | * Return: QDF_STATUS QDF_STATUS_SUCCESS on Success and |
| 12098 | * QDF_STATUS_E_FAILURE on failure |
| 12099 | */ |
| 12100 | QDF_STATUS hdd_md_host_evt_cb(void *ctx, struct sir_md_evt *event) |
| 12101 | { |
| 12102 | struct hdd_adapter *adapter = NULL; |
| 12103 | struct hdd_context *hdd_ctx; |
| 12104 | QDF_STATUS status; |
| 12105 | struct sme_motion_det_en motion_det; |
| 12106 | |
| 12107 | if (!ctx || !event) |
| 12108 | return QDF_STATUS_E_INVAL; |
| 12109 | |
| 12110 | hdd_ctx = (struct hdd_context *)ctx; |
| 12111 | status = wlan_hdd_validate_context(hdd_ctx); |
| 12112 | if (0 != status) |
| 12113 | return QDF_STATUS_E_INVAL; |
| 12114 | |
| 12115 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, event->vdev_id); |
| 12116 | if (!adapter || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 12117 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 12118 | return QDF_STATUS_E_INVAL; |
| 12119 | } |
| 12120 | |
| 12121 | hdd_debug("Motion Detection CB vdev_id=%u, status=%u", |
| 12122 | event->vdev_id, event->status); |
| 12123 | |
| 12124 | if (adapter->motion_detection_mode) { |
| 12125 | motion_det.vdev_id = event->vdev_id; |
| 12126 | motion_det.enable = 1; |
| 12127 | hdd_debug("Motion Detect CB -> Enable Motion Detection again"); |
| 12128 | sme_motion_det_enable(hdd_ctx->mac_handle, &motion_det); |
| 12129 | } |
| 12130 | |
| 12131 | return QDF_STATUS_SUCCESS; |
| 12132 | } |
| 12133 | #endif /* WLAN_FEATURE_MOTION_DETECTION */ |
| 12134 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12135 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12136 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12137 | * @hdd_ctx: HDD context |
| 12138 | * |
| 12139 | * Register the HDD callbacks to CDS/SME. |
| 12140 | * |
| 12141 | * Return: 0 for success or Error code for failure |
| 12142 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12143 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12144 | { |
| 12145 | QDF_STATUS status; |
| 12146 | int ret = 0; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12147 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12148 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12149 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12150 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12151 | hdd_err("in ftm mode, no need to register callbacks"); |
| 12152 | return ret; |
| 12153 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12154 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12155 | mac_handle = hdd_ctx->mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12156 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12157 | sme_register_oem_data_rsp_callback(mac_handle, |
| 12158 | hdd_send_oem_data_rsp_msg); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12159 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12160 | sme_register_mgmt_frame_ind_callback(mac_handle, |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 12161 | hdd_indicate_mgmt_frame); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12162 | sme_set_tsfcb(mac_handle, hdd_get_tsf_cb, hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12163 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12164 | wlan_hdd_cfg80211_stats_ext_callback); |
| 12165 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12166 | sme_ext_scan_register_callback(mac_handle, |
| 12167 | wlan_hdd_cfg80211_extscan_callback); |
| 12168 | sme_stats_ext2_register_callback(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 12169 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12170 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12171 | sme_set_rssi_threshold_breached_cb(mac_handle, |
| 12172 | hdd_rssi_threshold_breached); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12173 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12174 | sme_set_link_layer_stats_ind_cb(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12175 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 12176 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12177 | 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] | 12178 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12179 | sme_set_link_layer_ext_cb(mac_handle, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 12180 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
Abhinav Kumar | 338e57d | 2019-02-04 17:30:10 +0530 | [diff] [blame] | 12181 | sme_update_hidden_ssid_status_cb(mac_handle, |
| 12182 | hdd_hidden_ssid_enable_roaming); |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 12183 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12184 | status = sme_set_lost_link_info_cb(mac_handle, |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 12185 | hdd_lost_link_info_cb); |
| 12186 | /* print error and not block the startup process */ |
| 12187 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12188 | hdd_err("set lost link info callback failed"); |
| 12189 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12190 | ret = hdd_register_data_stall_detect_cb(); |
| 12191 | if (ret) { |
| 12192 | hdd_err("Register data stall detect detect callback failed."); |
| 12193 | return ret; |
| 12194 | } |
| 12195 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12196 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 12197 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12198 | sme_register_set_connection_info_cb(mac_handle, |
| 12199 | hdd_set_connection_in_progress, |
| 12200 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12201 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12202 | status = sme_congestion_register_callback(mac_handle, |
| 12203 | hdd_update_cca_info_cb); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12204 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12205 | hdd_err("set congestion callback failed"); |
| 12206 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12207 | status = sme_set_bt_activity_info_cb(mac_handle, |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 12208 | hdd_bt_activity_cb); |
| 12209 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12210 | hdd_err("set bt activity info callback failed"); |
| 12211 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12212 | status = sme_register_tx_queue_cb(mac_handle, |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 12213 | hdd_tx_queue_cb); |
| 12214 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12215 | hdd_err("Register tx queue callback failed"); |
| 12216 | |
Visweswara Tanuku | 633976b | 2019-01-07 16:13:12 +0530 | [diff] [blame] | 12217 | #ifdef WLAN_FEATURE_MOTION_DETECTION |
| 12218 | sme_set_md_host_evt_cb(mac_handle, hdd_md_host_evt_cb, (void *)hdd_ctx); |
| 12219 | #endif /* WLAN_FEATURE_MOTION_DETECTION */ |
| 12220 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12221 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12222 | |
| 12223 | return ret; |
| 12224 | } |
| 12225 | |
| 12226 | /** |
| 12227 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 12228 | * @hdd_ctx: HDD context |
| 12229 | * |
| 12230 | * De-Register the HDD callbacks to CDS/SME. |
| 12231 | * |
| 12232 | * Return: void |
| 12233 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12234 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12235 | { |
| 12236 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12237 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12238 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12239 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12240 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12241 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12242 | hdd_err("in ftm mode, no need to deregister callbacks"); |
| 12243 | return; |
| 12244 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12245 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12246 | mac_handle = hdd_ctx->mac_handle; |
| 12247 | sme_deregister_tx_queue_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12248 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12249 | sme_reset_link_layer_stats_ind_cb(mac_handle); |
| 12250 | sme_reset_rssi_threshold_breached_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12251 | |
Min Liu | d35ae31 | 2019-05-08 15:43:13 +0800 | [diff] [blame] | 12252 | sme_stats_ext_deregister_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12253 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12254 | status = sme_reset_tsfcb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12255 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12256 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 12257 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12258 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12259 | ret = hdd_deregister_data_stall_detect_cb(); |
| 12260 | if (ret) |
| 12261 | hdd_err("Failed to de-register data stall detect event callback"); |
| 12262 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12263 | sme_deregister_oem_data_rsp_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12264 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12265 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12266 | } |
| 12267 | |
| 12268 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12269 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12270 | * @adapter: Pointer to the HDD adapter |
| 12271 | * @param: Params to the operation |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12272 | * |
| 12273 | * This to take counter measure to handle deauth req from HDD |
| 12274 | * |
| 12275 | * Return: None |
| 12276 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12277 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12278 | struct csr_del_sta_params *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12279 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12280 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12281 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12282 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12283 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12284 | /* Ignore request to deauth bcmc station */ |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12285 | if (param->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12286 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12287 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12288 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12289 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12290 | param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12291 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12292 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12293 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12294 | } |
| 12295 | |
| 12296 | /** |
| 12297 | * 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] | 12298 | * @adapter: Pointer to the HDD |
| 12299 | * @param: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12300 | * |
| 12301 | * This to take counter measure to handle deauth req from HDD |
| 12302 | * |
| 12303 | * Return: None |
| 12304 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12305 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12306 | struct csr_del_sta_params *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12307 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12308 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12309 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12310 | /* Ignore request to disassoc bcmc station */ |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12311 | if (param->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12312 | return; |
| 12313 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12314 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12315 | param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12316 | } |
| 12317 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12318 | void wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12319 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12320 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12321 | struct hdd_adapter *adapter = NULL; |
| 12322 | struct csr_roam_profile *roam_profile; |
| 12323 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12324 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12325 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12326 | hdd_debug("No active sta session"); |
| 12327 | return; |
| 12328 | } |
| 12329 | |
| 12330 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12331 | roam_profile = hdd_roam_profile(adapter); |
| 12332 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12333 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12334 | if (cur_adapter->vdev_id != adapter->vdev_id && |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12335 | adapter->device_mode == QDF_STA_MODE && |
| 12336 | hdd_conn_is_connected(sta_ctx)) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12337 | hdd_debug("%d Disable roaming", adapter->vdev_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12338 | sme_stop_roaming(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12339 | adapter->vdev_id, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12340 | ecsr_driver_disabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12341 | } |
| 12342 | } |
| 12343 | } |
| 12344 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12345 | void wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12346 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12347 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12348 | struct hdd_adapter *adapter = NULL; |
| 12349 | struct csr_roam_profile *roam_profile; |
| 12350 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12351 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12352 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12353 | hdd_debug("No active sta session"); |
| 12354 | return; |
| 12355 | } |
| 12356 | |
| 12357 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12358 | roam_profile = hdd_roam_profile(adapter); |
| 12359 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12360 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12361 | if (cur_adapter->vdev_id != adapter->vdev_id && |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12362 | adapter->device_mode == QDF_STA_MODE && |
| 12363 | hdd_conn_is_connected(sta_ctx)) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12364 | hdd_debug("%d Enable roaming", adapter->vdev_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12365 | sme_start_roaming(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12366 | adapter->vdev_id, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12367 | REASON_DRIVER_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12368 | } |
| 12369 | } |
| 12370 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12371 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12372 | /** |
| 12373 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 12374 | * @skb: sk buffer pointer |
| 12375 | * |
| 12376 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 12377 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 12378 | * |
| 12379 | * Return: None |
| 12380 | */ |
| 12381 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 12382 | { |
| 12383 | #ifdef CNSS_GENL |
| 12384 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 12385 | #else |
| 12386 | nl_srv_bcast(skb); |
| 12387 | #endif |
| 12388 | } |
| 12389 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12390 | 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] | 12391 | { |
| 12392 | struct sk_buff *skb; |
| 12393 | struct nlmsghdr *nlh; |
| 12394 | tAniMsgHdr *ani_hdr; |
| 12395 | void *nl_data = NULL; |
| 12396 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12397 | struct radio_index_tlv *radio_info; |
| 12398 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12399 | |
| 12400 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 12401 | flags = GFP_ATOMIC; |
| 12402 | |
| 12403 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 12404 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12405 | if (!skb) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12406 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12407 | |
| 12408 | nlh = (struct nlmsghdr *)skb->data; |
| 12409 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 12410 | nlh->nlmsg_flags = 0; |
| 12411 | nlh->nlmsg_seq = 0; |
| 12412 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 12413 | |
| 12414 | ani_hdr = NLMSG_DATA(nlh); |
| 12415 | ani_hdr->type = type; |
| 12416 | |
| 12417 | switch (type) { |
| 12418 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 12419 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12420 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12421 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12422 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12423 | ani_hdr->length = 0; |
| 12424 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12425 | break; |
| 12426 | case WLAN_SVC_WLAN_STATUS_IND: |
| 12427 | case WLAN_SVC_WLAN_VERSION_IND: |
| 12428 | case WLAN_SVC_DFS_CAC_START_IND: |
| 12429 | case WLAN_SVC_DFS_CAC_END_IND: |
| 12430 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 12431 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 12432 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 12433 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 12434 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 12435 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12436 | ani_hdr->length = len; |
| 12437 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 12438 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 12439 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12440 | break; |
| 12441 | |
| 12442 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 12443 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12444 | type); |
| 12445 | kfree_skb(skb); |
| 12446 | return; |
| 12447 | } |
| 12448 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12449 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 12450 | * Add radio index at the end of the svc event in TLV format |
| 12451 | * to maintain the backward compatibility with userspace |
| 12452 | * applications. |
| 12453 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12454 | |
| 12455 | tlv_len = 0; |
| 12456 | |
| 12457 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 12458 | < WLAN_NL_MAX_PAYLOAD) { |
| 12459 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 12460 | sizeof(*ani_hdr) + len); |
| 12461 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 12462 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 12463 | radio_info->radio = radio; |
| 12464 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12465 | hdd_debug("Added radio index tlv - radio index %d", |
| 12466 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12467 | } |
| 12468 | |
| 12469 | nlh->nlmsg_len += tlv_len; |
| 12470 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 12471 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12472 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12473 | } |
| 12474 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12475 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 12476 | void wlan_hdd_auto_shutdown_cb(void) |
| 12477 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12478 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12479 | |
| 12480 | if (!hdd_ctx) |
| 12481 | return; |
| 12482 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12483 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12484 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 12485 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12486 | } |
| 12487 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12488 | 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] | 12489 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12490 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12491 | bool ap_connected = false, sta_connected = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12492 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12493 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12494 | mac_handle = hdd_ctx->mac_handle; |
| 12495 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12496 | return; |
| 12497 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12498 | if (hdd_ctx->config->wlan_auto_shutdown == 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12499 | return; |
| 12500 | |
| 12501 | if (enable == false) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12502 | if (sme_set_auto_shutdown_timer(mac_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12503 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12504 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12505 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12506 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12507 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12508 | return; |
| 12509 | } |
| 12510 | |
| 12511 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12512 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->psoc)) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12513 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12514 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12515 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 12516 | conn_info.conn_state == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12517 | eConnectionState_Associated) { |
| 12518 | sta_connected = true; |
| 12519 | break; |
| 12520 | } |
| 12521 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12522 | |
| 12523 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12524 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12525 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12526 | ap_connected = true; |
| 12527 | break; |
| 12528 | } |
| 12529 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12530 | } |
| 12531 | } |
| 12532 | |
| 12533 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12534 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12535 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12536 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12537 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12538 | if (sme_set_auto_shutdown_timer(mac_handle, |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12539 | hdd_ctx->config->wlan_auto_shutdown) |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12540 | != QDF_STATUS_SUCCESS) |
| 12541 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 12542 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 12543 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12544 | hdd_ctx->config->wlan_auto_shutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12545 | } |
| 12546 | #endif |
| 12547 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12548 | struct hdd_adapter * |
| 12549 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 12550 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12551 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12552 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12553 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12554 | |
| 12555 | con_sap_adapter = NULL; |
| 12556 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12557 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12558 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 12559 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12560 | adapter != this_sap_adapter) { |
| 12561 | if (check_start_bss) { |
| 12562 | if (test_bit(SOFTAP_BSS_STARTED, |
| 12563 | &adapter->event_flags)) { |
| 12564 | con_sap_adapter = adapter; |
| 12565 | break; |
| 12566 | } |
| 12567 | } else { |
| 12568 | con_sap_adapter = adapter; |
| 12569 | break; |
| 12570 | } |
| 12571 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12572 | } |
| 12573 | |
| 12574 | return con_sap_adapter; |
| 12575 | } |
| 12576 | |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 12577 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12578 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12579 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12580 | return adapter->device_mode == QDF_STA_MODE || |
| 12581 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12582 | } |
| 12583 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12584 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12585 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12586 | return adapter->device_mode == QDF_SAP_MODE || |
| 12587 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 12588 | } |
| 12589 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12590 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12591 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12592 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12593 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12594 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12595 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12596 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 12597 | conn_info.conn_state == eConnectionState_Associated) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12598 | return true; |
| 12599 | } |
| 12600 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12601 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12602 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12603 | return true; |
| 12604 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12605 | } |
| 12606 | |
| 12607 | return false; |
| 12608 | } |
| 12609 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12610 | 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] | 12611 | { |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 12612 | qdf_periodic_work_start(&hdd_ctx->bus_bw_work, |
| 12613 | hdd_ctx->config->bus_bw_compute_interval); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12614 | } |
| 12615 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12616 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12617 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12618 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12619 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12620 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12621 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12622 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12623 | } |
| 12624 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12625 | 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] | 12626 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12627 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12628 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12629 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12630 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12631 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12632 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12633 | } |
| 12634 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12635 | 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] | 12636 | { |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 12637 | if (!qdf_periodic_work_stop_sync(&hdd_ctx->bus_bw_work)) |
| 12638 | return; |
| 12639 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12640 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12641 | hdd_reset_tcp_delack(hdd_ctx); |
| 12642 | } |
| 12643 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12644 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12645 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12646 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12647 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12648 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12649 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12650 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12651 | } |
| 12652 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12653 | 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] | 12654 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12655 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12656 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12657 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12658 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12659 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12660 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12661 | } |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 12662 | #endif /*WLAN_FEATURE_DP_BUS_BANDWIDTH*/ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12663 | |
| 12664 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12665 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 12666 | * @ap_adapter: SAP adapter |
| 12667 | * |
| 12668 | * This function will process the stopping of sap adapter. |
| 12669 | * |
| 12670 | * Return: None |
| 12671 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12672 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12673 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12674 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12675 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12676 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12677 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12678 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12679 | if (!ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12680 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12681 | return; |
| 12682 | } |
| 12683 | |
| 12684 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12685 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12686 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12687 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12688 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12689 | mutex_lock(&hdd_ctx->sap_lock); |
| 12690 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 12691 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12692 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12693 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12694 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12695 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12696 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12697 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 12698 | qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 12699 | SME_CMD_STOP_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12700 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12701 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12702 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12703 | return; |
| 12704 | } |
| 12705 | } |
| 12706 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12707 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12708 | ap_adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12709 | ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12710 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12711 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12712 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12713 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12714 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12715 | } |
| 12716 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12717 | } |
| 12718 | |
| 12719 | /** |
| 12720 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 12721 | * @ap_adapter: SAP adapter |
| 12722 | * |
| 12723 | * This function will process the starting of sap adapter. |
| 12724 | * |
| 12725 | * Return: None |
| 12726 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12727 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12728 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12729 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12730 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12731 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12732 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 8f8ceb9 | 2019-03-24 08:16:55 -0700 | [diff] [blame] | 12733 | struct sap_config *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12734 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12735 | if (!ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12736 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12737 | return; |
| 12738 | } |
| 12739 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12740 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 12741 | hdd_err("SoftAp role has not been enabled"); |
| 12742 | return; |
| 12743 | } |
| 12744 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12745 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 12746 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12747 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 12748 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12749 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12750 | mutex_lock(&hdd_ctx->sap_lock); |
| 12751 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 12752 | goto end; |
| 12753 | |
| 12754 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12755 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12756 | goto end; |
| 12757 | } |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12758 | wlan_reg_set_channel_params(hdd_ctx->pdev, |
Abhinav Kumar | 6f69448 | 2018-09-04 16:07:39 +0530 | [diff] [blame] | 12759 | hdd_ap_ctx->sap_config.channel, 0, |
| 12760 | &hdd_ap_ctx->sap_config.ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12761 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 12762 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12763 | 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] | 12764 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12765 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12766 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12767 | goto end; |
| 12768 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12769 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12770 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 12771 | SME_CMD_START_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12772 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12773 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12774 | goto end; |
| 12775 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12776 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12777 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12778 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12779 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12780 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12781 | ap_adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12782 | ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12783 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12784 | true); |
| 12785 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 12786 | mutex_unlock(&hdd_ctx->sap_lock); |
| 12787 | |
| 12788 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12789 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12790 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12791 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 12792 | /* SAP context and beacon cleanup will happen during driver unload |
| 12793 | * in hdd_stop_adapter |
| 12794 | */ |
| 12795 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 12796 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12797 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12798 | |
| 12799 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12800 | * hdd_get_fw_version() - Get FW version |
| 12801 | * @hdd_ctx: pointer to HDD context. |
| 12802 | * @major_spid: FW version - major spid. |
| 12803 | * @minor_spid: FW version - minor spid |
| 12804 | * @ssid: FW version - ssid |
| 12805 | * @crmid: FW version - crmid |
| 12806 | * |
| 12807 | * This function is called to get the firmware build version stored |
| 12808 | * as part of the HDD context |
| 12809 | * |
| 12810 | * Return: None |
| 12811 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12812 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12813 | uint32_t *major_spid, uint32_t *minor_spid, |
| 12814 | uint32_t *siid, uint32_t *crmid) |
| 12815 | { |
| 12816 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 12817 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 12818 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 12819 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 12820 | } |
| 12821 | |
| 12822 | #ifdef QCA_CONFIG_SMP |
| 12823 | /** |
| 12824 | * wlan_hdd_get_cpu() - get cpu_index |
| 12825 | * |
| 12826 | * Return: cpu_index |
| 12827 | */ |
| 12828 | int wlan_hdd_get_cpu(void) |
| 12829 | { |
| 12830 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12831 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12832 | put_cpu(); |
| 12833 | return cpu_index; |
| 12834 | } |
| 12835 | #endif |
| 12836 | |
| 12837 | /** |
| 12838 | * hdd_get_fwpath() - get framework path |
| 12839 | * |
| 12840 | * This function is used to get the string written by |
| 12841 | * userspace to start the wlan driver |
| 12842 | * |
| 12843 | * Return: string |
| 12844 | */ |
| 12845 | const char *hdd_get_fwpath(void) |
| 12846 | { |
| 12847 | return fwpath.string; |
| 12848 | } |
| 12849 | |
Dustin Brown | 94ce20f | 2018-09-04 13:11:38 -0700 | [diff] [blame] | 12850 | static inline int hdd_state_query_cb(void) |
| 12851 | { |
| 12852 | return !!wlan_hdd_validate_context(cds_get_context(QDF_MODULE_ID_HDD)); |
| 12853 | } |
| 12854 | |
Dustin Brown | 265e82b | 2019-03-18 11:07:32 -0700 | [diff] [blame] | 12855 | static int __hdd_op_protect_cb(void **out_sync, const char *func) |
| 12856 | { |
| 12857 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12858 | |
| 12859 | if (!hdd_ctx) |
| 12860 | return -EAGAIN; |
| 12861 | |
| 12862 | return __osif_psoc_sync_op_start(hdd_ctx->parent_dev, |
| 12863 | (struct osif_psoc_sync **)out_sync, |
| 12864 | func); |
| 12865 | } |
| 12866 | |
| 12867 | static void __hdd_op_unprotect_cb(void *sync, const char *func) |
| 12868 | { |
| 12869 | __osif_psoc_sync_op_stop(sync, func); |
| 12870 | } |
| 12871 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12872 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12873 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12874 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12875 | * This function initilizes CDS global context with the help of cds_init. This |
| 12876 | * has to be the first function called after probe to get a valid global |
| 12877 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12878 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12879 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12880 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12881 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12882 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12883 | QDF_STATUS status; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12884 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12885 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12886 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12887 | hdd_err("Failed to allocate CDS context"); |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 12888 | return -ENOMEM; |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12889 | } |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 12890 | |
Dustin Brown | 265e82b | 2019-03-18 11:07:32 -0700 | [diff] [blame] | 12891 | 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] | 12892 | |
| 12893 | wlan_init_bug_report_lock(); |
| 12894 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12895 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12896 | wlan_logging_sock_init_svc(); |
| 12897 | #endif |
| 12898 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12899 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 12900 | hdd_register_debug_callback(); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12901 | wlan_roam_debug_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12902 | |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 12903 | return 0; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12904 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12905 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12906 | /** |
| 12907 | * hdd_deinit() - Deinitialize Driver |
| 12908 | * |
| 12909 | * This function frees CDS global context with the help of cds_deinit. This |
| 12910 | * has to be the last function call in remove callback to free the global |
| 12911 | * context. |
| 12912 | */ |
| 12913 | void hdd_deinit(void) |
| 12914 | { |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12915 | wlan_roam_debug_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12916 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12917 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12918 | wlan_logging_sock_deinit_svc(); |
| 12919 | #endif |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12920 | |
| 12921 | wlan_destroy_bug_report_lock(); |
Dustin Brown | 265e82b | 2019-03-18 11:07:32 -0700 | [diff] [blame] | 12922 | qdf_op_callbacks_register(NULL, NULL); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12923 | cds_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12924 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12925 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12926 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 12927 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 12928 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12929 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12930 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12931 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12932 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 12933 | struct file *file) |
| 12934 | { |
| 12935 | return 0; |
| 12936 | } |
| 12937 | |
| 12938 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 12939 | const char __user *user_buf, |
| 12940 | size_t count, |
| 12941 | loff_t *f_pos) |
| 12942 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12943 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12944 | static const char wlan_off_str[] = "OFF"; |
| 12945 | static const char wlan_on_str[] = "ON"; |
| 12946 | int ret; |
| 12947 | unsigned long rc; |
| 12948 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12949 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12950 | pr_err("Failed to read buffer\n"); |
| 12951 | return -EINVAL; |
| 12952 | } |
| 12953 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12954 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12955 | pr_debug("Wifi turning off from UI\n"); |
| 12956 | goto exit; |
| 12957 | } |
| 12958 | |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 12959 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12960 | pr_info("Wifi Turning On from UI\n"); |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12961 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12962 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12963 | pr_err("Invalid value received from framework"); |
| 12964 | goto exit; |
| 12965 | } |
| 12966 | |
| 12967 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 12968 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12969 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 12970 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 12971 | if (!rc) { |
Srinivas Girigowda | 09625b0 | 2018-09-10 15:28:09 -0700 | [diff] [blame] | 12972 | hdd_alert("Timed-out!!"); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12973 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12974 | return ret; |
| 12975 | } |
| 12976 | |
| 12977 | hdd_start_complete(0); |
| 12978 | } |
| 12979 | |
| 12980 | exit: |
| 12981 | return count; |
| 12982 | } |
| 12983 | |
| 12984 | |
| 12985 | const struct file_operations wlan_hdd_state_fops = { |
| 12986 | .owner = THIS_MODULE, |
| 12987 | .open = wlan_hdd_state_ctrl_param_open, |
| 12988 | .write = wlan_hdd_state_ctrl_param_write, |
| 12989 | }; |
| 12990 | |
| 12991 | static int wlan_hdd_state_ctrl_param_create(void) |
| 12992 | { |
| 12993 | unsigned int wlan_hdd_state_major = 0; |
| 12994 | int ret; |
| 12995 | struct device *dev; |
| 12996 | |
| 12997 | device = MKDEV(wlan_hdd_state_major, 0); |
| 12998 | |
| 12999 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 13000 | if (ret) { |
| 13001 | pr_err("Failed to register qcwlanstate"); |
| 13002 | goto dev_alloc_err; |
| 13003 | } |
| 13004 | wlan_hdd_state_major = MAJOR(device); |
| 13005 | |
| 13006 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 13007 | if (IS_ERR(class)) { |
| 13008 | pr_err("wlan_hdd_state class_create error"); |
| 13009 | goto class_err; |
| 13010 | } |
| 13011 | |
| 13012 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 13013 | if (IS_ERR(dev)) { |
| 13014 | pr_err("wlan_hdd_statedevice_create error"); |
| 13015 | goto err_class_destroy; |
| 13016 | } |
| 13017 | |
| 13018 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 13019 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 13020 | if (ret) { |
| 13021 | pr_err("Failed to add cdev error"); |
| 13022 | goto cdev_add_err; |
| 13023 | } |
| 13024 | |
| 13025 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 13026 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 13027 | |
| 13028 | return 0; |
| 13029 | |
| 13030 | cdev_add_err: |
| 13031 | device_destroy(class, device); |
| 13032 | err_class_destroy: |
| 13033 | class_destroy(class); |
| 13034 | class_err: |
| 13035 | unregister_chrdev_region(device, dev_num); |
| 13036 | dev_alloc_err: |
| 13037 | return -ENODEV; |
| 13038 | } |
| 13039 | |
| 13040 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 13041 | { |
| 13042 | cdev_del(&wlan_hdd_state_cdev); |
| 13043 | device_destroy(class, device); |
| 13044 | class_destroy(class); |
| 13045 | unregister_chrdev_region(device, dev_num); |
| 13046 | |
| 13047 | pr_info("Device node unregistered"); |
| 13048 | } |
| 13049 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13050 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13051 | * hdd_component_init() - Initialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13052 | * |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13053 | * Return: QDF_STATUS |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13054 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13055 | static QDF_STATUS hdd_component_init(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13056 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13057 | QDF_STATUS status; |
| 13058 | |
| 13059 | /* initialize converged components */ |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13060 | status = target_if_init(wma_get_psoc_from_scn_handle); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13061 | if (QDF_IS_STATUS_ERROR(status)) |
| 13062 | return status; |
| 13063 | |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13064 | status = ucfg_mlme_global_init(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13065 | if (QDF_IS_STATUS_ERROR(status)) |
| 13066 | goto target_if_deinit; |
| 13067 | |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13068 | status = dispatcher_init(); |
| 13069 | if (QDF_IS_STATUS_ERROR(status)) |
| 13070 | goto mlme_global_deinit; |
| 13071 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13072 | /* initialize non-converged components */ |
| 13073 | status = ucfg_mlme_init(); |
| 13074 | if (QDF_IS_STATUS_ERROR(status)) |
| 13075 | goto dispatcher_deinit; |
| 13076 | |
| 13077 | status = ucfg_fwol_init(); |
| 13078 | if (QDF_IS_STATUS_ERROR(status)) |
| 13079 | goto mlme_deinit; |
| 13080 | |
| 13081 | status = disa_init(); |
| 13082 | if (QDF_IS_STATUS_ERROR(status)) |
| 13083 | goto fwol_deinit; |
| 13084 | |
| 13085 | status = pmo_init(); |
| 13086 | if (QDF_IS_STATUS_ERROR(status)) |
| 13087 | goto disa_deinit; |
| 13088 | |
| 13089 | status = ucfg_ocb_init(); |
| 13090 | if (QDF_IS_STATUS_ERROR(status)) |
| 13091 | goto pmo_deinit; |
| 13092 | |
| 13093 | status = ipa_init(); |
| 13094 | if (QDF_IS_STATUS_ERROR(status)) |
| 13095 | goto ocb_deinit; |
| 13096 | |
| 13097 | status = ucfg_action_oui_init(); |
| 13098 | if (QDF_IS_STATUS_ERROR(status)) |
| 13099 | goto ipa_deinit; |
| 13100 | |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13101 | status = nan_init(); |
| 13102 | if (QDF_IS_STATUS_ERROR(status)) |
| 13103 | goto action_oui_deinit; |
| 13104 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13105 | status = ucfg_p2p_init(); |
| 13106 | if (QDF_IS_STATUS_ERROR(status)) |
| 13107 | goto nan_deinit; |
| 13108 | |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame^] | 13109 | status = ucfg_interop_issues_ap_init(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13110 | if (QDF_IS_STATUS_ERROR(status)) |
| 13111 | goto p2p_deinit; |
| 13112 | |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame^] | 13113 | status = policy_mgr_init(); |
| 13114 | if (QDF_IS_STATUS_ERROR(status)) |
| 13115 | goto interop_issues_ap_deinit; |
| 13116 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13117 | status = ucfg_tdls_init(); |
| 13118 | if (QDF_IS_STATUS_ERROR(status)) |
| 13119 | goto policy_deinit; |
| 13120 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13121 | return QDF_STATUS_SUCCESS; |
| 13122 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13123 | policy_deinit: |
| 13124 | policy_mgr_deinit(); |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame^] | 13125 | interop_issues_ap_deinit: |
| 13126 | ucfg_interop_issues_ap_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13127 | p2p_deinit: |
| 13128 | ucfg_p2p_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13129 | nan_deinit: |
| 13130 | nan_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13131 | action_oui_deinit: |
| 13132 | ucfg_action_oui_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13133 | ipa_deinit: |
| 13134 | ipa_deinit(); |
| 13135 | ocb_deinit: |
| 13136 | ucfg_ocb_deinit(); |
| 13137 | pmo_deinit: |
| 13138 | pmo_deinit(); |
| 13139 | disa_deinit: |
| 13140 | disa_deinit(); |
| 13141 | fwol_deinit: |
| 13142 | ucfg_fwol_deinit(); |
| 13143 | mlme_deinit: |
| 13144 | ucfg_mlme_deinit(); |
| 13145 | dispatcher_deinit: |
| 13146 | dispatcher_deinit(); |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13147 | mlme_global_deinit: |
| 13148 | ucfg_mlme_global_deinit(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13149 | target_if_deinit: |
| 13150 | target_if_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13151 | |
| 13152 | return status; |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13153 | } |
| 13154 | |
| 13155 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13156 | * hdd_component_deinit() - Deinitialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13157 | * |
| 13158 | * Return: None |
| 13159 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13160 | static void hdd_component_deinit(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13161 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13162 | /* deinitialize non-converged components */ |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13163 | ucfg_tdls_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13164 | policy_mgr_deinit(); |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame^] | 13165 | ucfg_interop_issues_ap_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13166 | ucfg_p2p_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13167 | nan_deinit(); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 13168 | ucfg_action_oui_deinit(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 13169 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13170 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13171 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13172 | disa_deinit(); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13173 | ucfg_fwol_deinit(); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13174 | ucfg_mlme_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13175 | |
| 13176 | /* deinitialize converged components */ |
| 13177 | dispatcher_deinit(); |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13178 | ucfg_mlme_global_deinit(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13179 | target_if_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13180 | } |
| 13181 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13182 | QDF_STATUS hdd_component_psoc_open(struct wlan_objmgr_psoc *psoc) |
| 13183 | { |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13184 | QDF_STATUS status; |
| 13185 | |
| 13186 | status = ucfg_mlme_psoc_open(psoc); |
| 13187 | if (QDF_IS_STATUS_ERROR(status)) |
| 13188 | return status; |
| 13189 | |
| 13190 | status = ucfg_fwol_psoc_open(psoc); |
| 13191 | if (QDF_IS_STATUS_ERROR(status)) |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13192 | goto err_fwol; |
| 13193 | |
| 13194 | status = ucfg_pmo_psoc_open(psoc); |
| 13195 | if (QDF_IS_STATUS_ERROR(status)) |
| 13196 | goto err_pmo; |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13197 | |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13198 | status = ucfg_policy_mgr_psoc_open(psoc); |
| 13199 | if (QDF_IS_STATUS_ERROR(status)) |
| 13200 | goto err_plcy_mgr; |
| 13201 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13202 | status = ucfg_p2p_psoc_open(psoc); |
| 13203 | if (QDF_IS_STATUS_ERROR(status)) |
| 13204 | goto err_p2p; |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13205 | |
| 13206 | status = ucfg_tdls_psoc_open(psoc); |
| 13207 | if (QDF_IS_STATUS_ERROR(status)) |
| 13208 | goto err_tdls; |
| 13209 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13210 | return status; |
| 13211 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13212 | err_tdls: |
| 13213 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13214 | err_p2p: |
| 13215 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13216 | err_plcy_mgr: |
| 13217 | ucfg_pmo_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13218 | err_pmo: |
| 13219 | ucfg_fwol_psoc_close(psoc); |
| 13220 | err_fwol: |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13221 | ucfg_mlme_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13222 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13223 | return status; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13224 | } |
| 13225 | |
| 13226 | void hdd_component_psoc_close(struct wlan_objmgr_psoc *psoc) |
| 13227 | { |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13228 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13229 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13230 | ucfg_policy_mgr_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13231 | ucfg_pmo_psoc_close(psoc); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13232 | ucfg_fwol_psoc_close(psoc); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13233 | ucfg_mlme_psoc_close(psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13234 | } |
| 13235 | |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13236 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 13237 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13238 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13239 | disa_psoc_enable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13240 | nan_psoc_enable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13241 | p2p_psoc_enable(psoc); |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame^] | 13242 | ucfg_interop_issues_ap_psoc_enable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13243 | policy_mgr_psoc_enable(psoc); |
Wu Gao | a67c380 | 2018-12-27 12:07:52 +0800 | [diff] [blame] | 13244 | ucfg_tdls_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13245 | } |
| 13246 | |
| 13247 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 13248 | { |
Wu Gao | a67c380 | 2018-12-27 12:07:52 +0800 | [diff] [blame] | 13249 | ucfg_tdls_psoc_disable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13250 | policy_mgr_psoc_disable(psoc); |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame^] | 13251 | ucfg_interop_issues_ap_psoc_disable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13252 | p2p_psoc_disable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13253 | nan_psoc_disable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13254 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13255 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13256 | } |
| 13257 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 13258 | QDF_STATUS hdd_component_pdev_open(struct wlan_objmgr_pdev *pdev) |
| 13259 | { |
| 13260 | return ucfg_mlme_pdev_open(pdev); |
| 13261 | } |
| 13262 | |
| 13263 | void hdd_component_pdev_close(struct wlan_objmgr_pdev *pdev) |
| 13264 | { |
| 13265 | ucfg_mlme_pdev_close(pdev); |
| 13266 | } |
| 13267 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13268 | static QDF_STATUS hdd_qdf_print_init(void) |
| 13269 | { |
| 13270 | QDF_STATUS status; |
| 13271 | int qdf_print_idx; |
| 13272 | |
| 13273 | status = qdf_print_setup(); |
| 13274 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13275 | pr_err("Failed qdf_print_setup; status:%u\n", status); |
| 13276 | return status; |
| 13277 | } |
| 13278 | |
| 13279 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 13280 | if (qdf_print_idx < 0) { |
| 13281 | pr_err("Failed to register for qdf_print_ctrl\n"); |
| 13282 | return QDF_STATUS_E_FAILURE; |
| 13283 | } |
| 13284 | |
| 13285 | qdf_set_pidx(qdf_print_idx); |
| 13286 | |
| 13287 | return QDF_STATUS_SUCCESS; |
| 13288 | } |
| 13289 | |
| 13290 | static void hdd_qdf_print_deinit(void) |
| 13291 | { |
| 13292 | int qdf_pidx = qdf_get_pidx(); |
| 13293 | |
| 13294 | qdf_set_pidx(-1); |
| 13295 | qdf_print_ctrl_cleanup(qdf_pidx); |
| 13296 | |
| 13297 | /* currently, no qdf print 'un-setup'*/ |
| 13298 | } |
| 13299 | |
| 13300 | static QDF_STATUS hdd_qdf_init(void) |
| 13301 | { |
| 13302 | QDF_STATUS status; |
| 13303 | |
| 13304 | status = hdd_qdf_print_init(); |
| 13305 | if (QDF_IS_STATUS_ERROR(status)) |
| 13306 | goto exit; |
| 13307 | |
| 13308 | status = qdf_debugfs_init(); |
| 13309 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13310 | hdd_err("Failed to init debugfs; status:%u", status); |
| 13311 | goto print_deinit; |
| 13312 | } |
| 13313 | |
| 13314 | qdf_lock_stats_init(); |
| 13315 | qdf_mem_init(); |
Dustin Brown | c279631 | 2019-03-13 16:43:36 -0700 | [diff] [blame] | 13316 | qdf_delayed_work_feature_init(); |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 13317 | qdf_periodic_work_feature_init(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13318 | qdf_mc_timer_manager_init(); |
| 13319 | qdf_event_list_init(); |
| 13320 | |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13321 | status = qdf_talloc_feature_init(); |
| 13322 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13323 | hdd_err("Failed to init talloc; status:%u", status); |
| 13324 | goto event_deinit; |
| 13325 | } |
| 13326 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13327 | status = qdf_cpuhp_init(); |
| 13328 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13329 | hdd_err("Failed to init cpuhp; status:%u", status); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13330 | goto talloc_deinit; |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13331 | } |
| 13332 | |
| 13333 | status = qdf_trace_spin_lock_init(); |
| 13334 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13335 | hdd_err("Failed to init spinlock; status:%u", status); |
| 13336 | goto cpuhp_deinit; |
| 13337 | } |
| 13338 | |
| 13339 | qdf_trace_init(); |
| 13340 | qdf_register_debugcb_init(); |
| 13341 | |
| 13342 | return QDF_STATUS_SUCCESS; |
| 13343 | |
| 13344 | cpuhp_deinit: |
| 13345 | qdf_cpuhp_deinit(); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13346 | talloc_deinit: |
| 13347 | qdf_talloc_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13348 | event_deinit: |
| 13349 | qdf_event_list_destroy(); |
| 13350 | qdf_mc_timer_manager_exit(); |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 13351 | qdf_periodic_work_feature_deinit(); |
Dustin Brown | c279631 | 2019-03-13 16:43:36 -0700 | [diff] [blame] | 13352 | qdf_delayed_work_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13353 | qdf_mem_exit(); |
| 13354 | qdf_lock_stats_deinit(); |
| 13355 | qdf_debugfs_exit(); |
| 13356 | print_deinit: |
| 13357 | hdd_qdf_print_deinit(); |
| 13358 | |
| 13359 | exit: |
| 13360 | return status; |
| 13361 | } |
| 13362 | |
| 13363 | static void hdd_qdf_deinit(void) |
| 13364 | { |
| 13365 | /* currently, no debugcb deinit */ |
| 13366 | |
| 13367 | qdf_trace_deinit(); |
| 13368 | |
| 13369 | /* currently, no trace spinlock deinit */ |
| 13370 | |
| 13371 | qdf_cpuhp_deinit(); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13372 | qdf_talloc_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13373 | qdf_event_list_destroy(); |
| 13374 | qdf_mc_timer_manager_exit(); |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 13375 | qdf_periodic_work_feature_deinit(); |
Dustin Brown | c279631 | 2019-03-13 16:43:36 -0700 | [diff] [blame] | 13376 | qdf_delayed_work_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13377 | qdf_mem_exit(); |
| 13378 | qdf_lock_stats_deinit(); |
| 13379 | qdf_debugfs_exit(); |
| 13380 | hdd_qdf_print_deinit(); |
| 13381 | } |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13382 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13383 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
| 13384 | static bool is_monitor_mode_supported(void) |
| 13385 | { |
| 13386 | return true; |
| 13387 | } |
| 13388 | #else |
| 13389 | static bool is_monitor_mode_supported(void) |
| 13390 | { |
| 13391 | pr_err("Monitor mode not supported!"); |
| 13392 | return false; |
| 13393 | } |
| 13394 | #endif |
| 13395 | |
| 13396 | #ifdef WLAN_FEATURE_EPPING |
| 13397 | static bool is_epping_mode_supported(void) |
| 13398 | { |
| 13399 | return true; |
| 13400 | } |
| 13401 | #else |
| 13402 | static bool is_epping_mode_supported(void) |
| 13403 | { |
| 13404 | pr_err("Epping mode not supported!"); |
| 13405 | return false; |
| 13406 | } |
| 13407 | #endif |
| 13408 | |
| 13409 | #ifdef QCA_WIFI_FTM |
| 13410 | static bool is_ftm_mode_supported(void) |
| 13411 | { |
| 13412 | return true; |
| 13413 | } |
| 13414 | #else |
| 13415 | static bool is_ftm_mode_supported(void) |
| 13416 | { |
| 13417 | pr_err("FTM mode not supported!"); |
| 13418 | return false; |
| 13419 | } |
| 13420 | #endif |
| 13421 | |
| 13422 | /** |
| 13423 | * is_con_mode_valid() check con mode is valid or not |
| 13424 | * @mode: global con mode |
| 13425 | * |
| 13426 | * Return: TRUE on success FALSE on failure |
| 13427 | */ |
| 13428 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
| 13429 | { |
| 13430 | switch (mode) { |
| 13431 | case QDF_GLOBAL_MONITOR_MODE: |
| 13432 | return is_monitor_mode_supported(); |
| 13433 | case QDF_GLOBAL_EPPING_MODE: |
| 13434 | return is_epping_mode_supported(); |
| 13435 | case QDF_GLOBAL_FTM_MODE: |
| 13436 | return is_ftm_mode_supported(); |
| 13437 | case QDF_GLOBAL_MISSION_MODE: |
| 13438 | return true; |
| 13439 | default: |
| 13440 | return false; |
| 13441 | } |
| 13442 | } |
| 13443 | |
| 13444 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
| 13445 | enum QDF_GLOBAL_MODE curr_mode) |
| 13446 | { |
| 13447 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 13448 | return; |
| 13449 | |
| 13450 | switch (curr_mode) { |
| 13451 | case QDF_GLOBAL_MONITOR_MODE: |
| 13452 | hdd_info("Release wakelock for monitor mode!"); |
| 13453 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 13454 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 13455 | /* fallthrough */ |
| 13456 | case QDF_GLOBAL_MISSION_MODE: |
| 13457 | case QDF_GLOBAL_FTM_MODE: |
| 13458 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 13459 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
| 13460 | hdd_stop_all_adapters(hdd_ctx); |
| 13461 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 13462 | |
| 13463 | break; |
| 13464 | default: |
| 13465 | break; |
| 13466 | } |
| 13467 | } |
| 13468 | |
| 13469 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
| 13470 | enum QDF_GLOBAL_MODE curr_mode) |
| 13471 | { |
| 13472 | int driver_status; |
| 13473 | |
| 13474 | driver_status = hdd_ctx->driver_status; |
| 13475 | |
| 13476 | switch (curr_mode) { |
| 13477 | case QDF_GLOBAL_MISSION_MODE: |
| 13478 | case QDF_GLOBAL_MONITOR_MODE: |
| 13479 | case QDF_GLOBAL_FTM_MODE: |
| 13480 | hdd_close_all_adapters(hdd_ctx, false); |
| 13481 | break; |
| 13482 | case QDF_GLOBAL_EPPING_MODE: |
| 13483 | epping_disable(); |
| 13484 | epping_close(); |
| 13485 | break; |
| 13486 | default: |
| 13487 | return; |
| 13488 | } |
| 13489 | } |
| 13490 | |
| 13491 | static int |
| 13492 | hdd_parse_driver_mode(const char *mode_str, enum QDF_GLOBAL_MODE *out_mode) |
| 13493 | { |
| 13494 | QDF_STATUS status; |
| 13495 | uint32_t mode; |
| 13496 | |
| 13497 | *out_mode = QDF_GLOBAL_MAX_MODE; |
| 13498 | |
| 13499 | status = qdf_uint32_parse(mode_str, &mode); |
| 13500 | if (QDF_IS_STATUS_ERROR(status)) |
| 13501 | return qdf_status_to_os_return(status); |
| 13502 | |
| 13503 | if (mode >= QDF_GLOBAL_MAX_MODE) |
| 13504 | return -ERANGE; |
| 13505 | |
| 13506 | *out_mode = (enum QDF_GLOBAL_MODE)mode; |
| 13507 | |
| 13508 | return 0; |
| 13509 | } |
| 13510 | |
| 13511 | /** |
| 13512 | * __hdd_driver_mode_change() - Handles a driver mode change |
| 13513 | * @hdd_ctx: Pointer to the global HDD context |
| 13514 | * @next_mode: the driver mode to transition to |
| 13515 | * |
| 13516 | * This function is invoked when user updates con_mode using sys entry, |
| 13517 | * to initialize and bring-up driver in that specific mode. |
| 13518 | * |
| 13519 | * Return: Errno |
| 13520 | */ |
| 13521 | static int __hdd_driver_mode_change(struct hdd_context *hdd_ctx, |
| 13522 | enum QDF_GLOBAL_MODE next_mode) |
| 13523 | { |
| 13524 | enum QDF_GLOBAL_MODE curr_mode; |
| 13525 | int errno; |
| 13526 | |
| 13527 | hdd_info("Driver mode changing to %d", next_mode); |
| 13528 | |
| 13529 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13530 | if (errno) |
| 13531 | return errno; |
| 13532 | |
| 13533 | if (!is_con_mode_valid(next_mode)) { |
| 13534 | hdd_err_rl("Requested driver mode is invalid"); |
| 13535 | return -EINVAL; |
| 13536 | } |
| 13537 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13538 | curr_mode = hdd_get_conparam(); |
| 13539 | if (curr_mode == next_mode) { |
| 13540 | hdd_err_rl("Driver is already in the requested mode"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13541 | return 0; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13542 | } |
| 13543 | |
| 13544 | /* ensure adapters are stopped */ |
| 13545 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 13546 | |
| 13547 | errno = hdd_wlan_stop_modules(hdd_ctx, true); |
| 13548 | if (errno) { |
| 13549 | hdd_err("Stop wlan modules failed"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13550 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13551 | } |
| 13552 | |
| 13553 | /* Cleanup present mode before switching to new mode */ |
| 13554 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 13555 | |
| 13556 | hdd_set_conparam(next_mode); |
| 13557 | |
| 13558 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 13559 | if (errno) { |
| 13560 | hdd_err("Start wlan modules failed: %d", errno); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13561 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13562 | } |
| 13563 | |
| 13564 | errno = hdd_open_adapters_for_mode(hdd_ctx, next_mode); |
| 13565 | if (errno) { |
| 13566 | hdd_err("Failed to open adapters"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13567 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13568 | } |
| 13569 | |
| 13570 | if (next_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 13571 | struct hdd_adapter *adapter = |
| 13572 | hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE); |
| 13573 | |
| 13574 | QDF_BUG(adapter); |
| 13575 | if (!adapter) { |
| 13576 | hdd_err("Failed to get monitor adapter"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13577 | return -EINVAL; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13578 | } |
| 13579 | |
| 13580 | errno = hdd_start_adapter(adapter); |
| 13581 | if (errno) { |
| 13582 | hdd_err("Failed to start monitor adapter"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13583 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13584 | } |
| 13585 | |
| 13586 | hdd_info("Acquire wakelock for monitor mode"); |
| 13587 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 13588 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 13589 | } |
| 13590 | |
| 13591 | /* con_mode is a global module parameter */ |
| 13592 | con_mode = next_mode; |
| 13593 | hdd_info("Driver mode successfully changed to %d", next_mode); |
| 13594 | |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13595 | return 0; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13596 | } |
| 13597 | |
| 13598 | static int hdd_driver_mode_change(enum QDF_GLOBAL_MODE mode) |
| 13599 | { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13600 | struct osif_driver_sync *driver_sync; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13601 | struct hdd_context *hdd_ctx; |
| 13602 | QDF_STATUS status; |
| 13603 | int errno; |
| 13604 | |
| 13605 | hdd_enter(); |
| 13606 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13607 | status = osif_driver_sync_trans_start_wait(&driver_sync); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13608 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13609 | hdd_err("Failed to start 'mode change'; status:%u", status); |
| 13610 | errno = qdf_status_to_os_return(status); |
| 13611 | goto exit; |
| 13612 | } |
| 13613 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13614 | osif_driver_sync_wait_for_ops(driver_sync); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13615 | |
| 13616 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13617 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13618 | if (errno) |
| 13619 | goto trans_stop; |
| 13620 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13621 | errno = __hdd_driver_mode_change(hdd_ctx, mode); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13622 | |
| 13623 | trans_stop: |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13624 | osif_driver_sync_trans_stop(driver_sync); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13625 | |
| 13626 | exit: |
| 13627 | hdd_exit(); |
| 13628 | |
| 13629 | return errno; |
| 13630 | } |
| 13631 | |
| 13632 | static int hdd_set_con_mode(enum QDF_GLOBAL_MODE mode) |
| 13633 | { |
| 13634 | con_mode = mode; |
| 13635 | |
| 13636 | return 0; |
| 13637 | } |
| 13638 | |
| 13639 | static int (*hdd_set_con_mode_cb)(enum QDF_GLOBAL_MODE mode) = hdd_set_con_mode; |
| 13640 | |
| 13641 | static void hdd_driver_mode_change_register(void) |
| 13642 | { |
| 13643 | hdd_set_con_mode_cb = hdd_driver_mode_change; |
| 13644 | } |
| 13645 | |
| 13646 | static void hdd_driver_mode_change_unregister(void) |
| 13647 | { |
| 13648 | hdd_set_con_mode_cb = hdd_set_con_mode; |
| 13649 | } |
| 13650 | |
| 13651 | static int con_mode_handler(const char *kmessage, const struct kernel_param *kp) |
| 13652 | { |
| 13653 | enum QDF_GLOBAL_MODE mode; |
| 13654 | int errno; |
| 13655 | |
| 13656 | errno = hdd_parse_driver_mode(kmessage, &mode); |
| 13657 | if (errno) { |
| 13658 | hdd_err_rl("Failed to parse driver mode '%s'", kmessage); |
| 13659 | return errno; |
| 13660 | } |
| 13661 | |
| 13662 | return hdd_set_con_mode_cb(mode); |
| 13663 | } |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13664 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13665 | /** |
| 13666 | * hdd_driver_load() - Perform the driver-level load operation |
| 13667 | * |
| 13668 | * Note: this is used in both static and DLKM driver builds |
| 13669 | * |
| 13670 | * Return: Errno |
| 13671 | */ |
| 13672 | static int hdd_driver_load(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13673 | { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13674 | struct osif_driver_sync *driver_sync; |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13675 | QDF_STATUS status; |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13676 | int errno; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13677 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13678 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 13679 | g_wlan_driver_version); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13680 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13681 | status = hdd_qdf_init(); |
| 13682 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13683 | errno = qdf_status_to_os_return(status); |
| 13684 | goto exit; |
| 13685 | } |
| 13686 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13687 | osif_sync_init(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13688 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13689 | status = osif_driver_sync_create_and_trans(&driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13690 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13691 | hdd_err("Failed to init driver sync; status:%u", status); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13692 | errno = qdf_status_to_os_return(status); |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13693 | goto sync_deinit; |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13694 | } |
| 13695 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13696 | errno = hdd_init(); |
| 13697 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13698 | hdd_err("Failed to init HDD; errno:%d", errno); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13699 | goto trans_stop; |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13700 | } |
| 13701 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13702 | status = hdd_component_init(); |
| 13703 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13704 | hdd_err("Failed to init components; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13705 | errno = qdf_status_to_os_return(status); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13706 | goto hdd_deinit; |
| 13707 | } |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13708 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13709 | status = qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
| 13710 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13711 | hdd_err("Failed to create wake lock; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13712 | errno = qdf_status_to_os_return(status); |
| 13713 | goto comp_deinit; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13714 | } |
| 13715 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13716 | hdd_set_conparam(con_mode); |
| 13717 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13718 | errno = wlan_hdd_state_ctrl_param_create(); |
| 13719 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13720 | hdd_err("Failed to create ctrl param; errno:%d", errno); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13721 | goto wakelock_destroy; |
| 13722 | } |
| 13723 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13724 | errno = pld_init(); |
| 13725 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13726 | hdd_err("Failed to init PLD; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13727 | goto param_destroy; |
| 13728 | } |
| 13729 | |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13730 | hdd_driver_mode_change_register(); |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13731 | |
| 13732 | osif_driver_sync_register(driver_sync); |
| 13733 | osif_driver_sync_trans_stop(driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13734 | |
| 13735 | /* psoc probe can happen in registration; do after 'load' transition */ |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13736 | errno = wlan_hdd_register_driver(); |
| 13737 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13738 | hdd_err("Failed to register driver; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13739 | goto pld_deinit; |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13740 | } |
| 13741 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13742 | hdd_debug("%s: driver loaded", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13743 | |
| 13744 | return 0; |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13745 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13746 | pld_deinit: |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13747 | status = osif_driver_sync_trans_start(&driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13748 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13749 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13750 | osif_driver_sync_unregister(); |
| 13751 | osif_driver_sync_wait_for_ops(driver_sync); |
| 13752 | |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13753 | hdd_driver_mode_change_unregister(); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13754 | pld_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13755 | |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13756 | param_destroy: |
| 13757 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13758 | wakelock_destroy: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13759 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13760 | comp_deinit: |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13761 | hdd_component_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13762 | hdd_deinit: |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13763 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13764 | trans_stop: |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13765 | osif_driver_sync_trans_stop(driver_sync); |
| 13766 | osif_driver_sync_destroy(driver_sync); |
| 13767 | sync_deinit: |
| 13768 | osif_sync_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13769 | hdd_qdf_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13770 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13771 | exit: |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13772 | return errno; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13773 | } |
| 13774 | |
| 13775 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13776 | * hdd_driver_unload() - Performs the driver-level unload operation |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13777 | * |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13778 | * Note: this is used in both static and DLKM driver builds |
| 13779 | * |
| 13780 | * Return: None |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13781 | */ |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13782 | static void hdd_driver_unload(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13783 | { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13784 | struct osif_driver_sync *driver_sync; |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 13785 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13786 | QDF_STATUS status; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 13787 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13788 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 13789 | QWLAN_VERSIONSTR); |
| 13790 | |
Dustin Brown | 8c0b5e3 | 2019-01-18 13:56:02 -0800 | [diff] [blame] | 13791 | if (hdd_ctx) |
| 13792 | hdd_psoc_idle_timer_stop(hdd_ctx); |
| 13793 | |
| 13794 | /* trigger SoC remove */ |
| 13795 | wlan_hdd_unregister_driver(); |
| 13796 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13797 | status = osif_driver_sync_trans_start_wait(&driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13798 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13799 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13800 | hdd_err("Unable to unload wlan; status:%u", status); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 13801 | return; |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13802 | } |
| 13803 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13804 | osif_driver_sync_unregister(); |
| 13805 | osif_driver_sync_wait_for_ops(driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13806 | |
Will Huang | ba035ec | 2018-07-05 11:13:30 +0800 | [diff] [blame] | 13807 | cds_set_driver_loaded(false); |
| 13808 | cds_set_unload_in_progress(true); |
| 13809 | |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13810 | hdd_driver_mode_change_unregister(); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13811 | pld_deinit(); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13812 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13813 | hdd_set_conparam(0); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13814 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13815 | hdd_component_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13816 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13817 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13818 | osif_driver_sync_trans_stop(driver_sync); |
| 13819 | osif_driver_sync_destroy(driver_sync); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 13820 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13821 | osif_sync_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13822 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13823 | hdd_qdf_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13824 | } |
| 13825 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13826 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13827 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13828 | * wlan_boot_cb() - Wlan boot callback |
| 13829 | * @kobj: object whose directory we're creating the link in. |
| 13830 | * @attr: attribute the user is interacting with |
| 13831 | * @buff: the buffer containing the user data |
| 13832 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13833 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13834 | * This callback is invoked when the fs is ready to start the |
| 13835 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13836 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13837 | * 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] | 13838 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13839 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13840 | struct kobj_attribute *attr, |
| 13841 | const char *buf, |
| 13842 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13843 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13844 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13845 | if (wlan_loader->loaded_state) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13846 | hdd_err("wlan driver already initialized"); |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13847 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13848 | } |
| 13849 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13850 | if (hdd_driver_load()) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13851 | return -EIO; |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13852 | |
| 13853 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13854 | |
| 13855 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13856 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13857 | |
| 13858 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13859 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 13860 | * |
| 13861 | * Return: None |
| 13862 | * |
| 13863 | */ |
| 13864 | static void hdd_sysfs_cleanup(void) |
| 13865 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13866 | /* remove from group */ |
| 13867 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 13868 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 13869 | wlan_loader->attr_group); |
| 13870 | |
| 13871 | /* unlink the object from parent */ |
| 13872 | kobject_del(wlan_loader->boot_wlan_obj); |
| 13873 | |
| 13874 | /* free the object */ |
| 13875 | kobject_put(wlan_loader->boot_wlan_obj); |
| 13876 | |
| 13877 | kfree(wlan_loader->attr_group); |
| 13878 | kfree(wlan_loader); |
| 13879 | |
| 13880 | wlan_loader = NULL; |
| 13881 | } |
| 13882 | |
| 13883 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13884 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 13885 | * ready |
| 13886 | * |
| 13887 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 13888 | * when the filesystem is ready. |
| 13889 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13890 | * QDF API cannot be used here since this function is called even before |
| 13891 | * initializing WLAN driver. |
| 13892 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13893 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13894 | */ |
| 13895 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13896 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13897 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13898 | |
| 13899 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13900 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13901 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13902 | |
| 13903 | wlan_loader->boot_wlan_obj = NULL; |
| 13904 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 13905 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13906 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13907 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13908 | |
| 13909 | wlan_loader->loaded_state = 0; |
| 13910 | wlan_loader->attr_group->attrs = attrs; |
| 13911 | |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 13912 | wlan_loader->boot_wlan_obj = kobject_create_and_add(WLAN_LOADER_NAME, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13913 | kernel_kobj); |
| 13914 | if (!wlan_loader->boot_wlan_obj) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13915 | hdd_err("sysfs create and add failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13916 | goto error_return; |
| 13917 | } |
| 13918 | |
| 13919 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 13920 | wlan_loader->attr_group); |
| 13921 | if (ret) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13922 | hdd_err("sysfs create group failed; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13923 | goto error_return; |
| 13924 | } |
| 13925 | |
| 13926 | return 0; |
| 13927 | |
| 13928 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13929 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13930 | |
| 13931 | return ret; |
| 13932 | } |
| 13933 | |
| 13934 | /** |
| 13935 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 13936 | * |
| 13937 | * Return: 0 on success or errno on failure |
| 13938 | */ |
| 13939 | static int wlan_deinit_sysfs(void) |
| 13940 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13941 | if (!wlan_loader) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13942 | hdd_err("wlan_loader is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13943 | return -EINVAL; |
| 13944 | } |
| 13945 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13946 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13947 | return 0; |
| 13948 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13949 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13950 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13951 | |
| 13952 | #ifdef MODULE |
| 13953 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13954 | * hdd_module_init() - Module init helper |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13955 | * |
| 13956 | * Module init helper function used by both module and static driver. |
| 13957 | * |
| 13958 | * Return: 0 for success, errno on failure |
| 13959 | */ |
| 13960 | static int hdd_module_init(void) |
| 13961 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13962 | if (hdd_driver_load()) |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13963 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13964 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13965 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13966 | } |
| 13967 | #else |
| 13968 | static int __init hdd_module_init(void) |
| 13969 | { |
| 13970 | int ret = -EINVAL; |
| 13971 | |
| 13972 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13973 | if (ret) |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13974 | hdd_err("Failed to create sysfs entry"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13975 | |
| 13976 | return ret; |
| 13977 | } |
| 13978 | #endif |
| 13979 | |
| 13980 | |
| 13981 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13982 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13983 | * hdd_module_exit() - Exit function |
| 13984 | * |
| 13985 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 13986 | * |
| 13987 | * Return: None |
| 13988 | */ |
| 13989 | static void __exit hdd_module_exit(void) |
| 13990 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13991 | hdd_driver_unload(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13992 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13993 | #else |
| 13994 | static void __exit hdd_module_exit(void) |
| 13995 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13996 | hdd_driver_unload(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13997 | wlan_deinit_sysfs(); |
| 13998 | } |
| 13999 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14000 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14001 | static int fwpath_changed_handler(const char *kmessage, |
| 14002 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14003 | { |
| 14004 | return param_set_copystring(kmessage, kp); |
| 14005 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 14006 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14007 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14008 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14009 | { |
| 14010 | int ret; |
| 14011 | |
| 14012 | ret = param_set_int(kmessage, kp); |
| 14013 | |
| 14014 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 14015 | pr_err("Only FTM mode supported!"); |
| 14016 | return -ENOTSUPP; |
| 14017 | } |
| 14018 | |
| 14019 | hdd_set_conparam(con_mode_ftm); |
| 14020 | con_mode = con_mode_ftm; |
| 14021 | |
| 14022 | return ret; |
| 14023 | } |
| 14024 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 14025 | #ifdef WLAN_FEATURE_EPPING |
| 14026 | static int con_mode_handler_epping(const char *kmessage, |
| 14027 | const struct kernel_param *kp) |
| 14028 | { |
| 14029 | int ret; |
| 14030 | |
| 14031 | ret = param_set_int(kmessage, kp); |
| 14032 | |
| 14033 | if (con_mode_epping != QDF_GLOBAL_EPPING_MODE) { |
| 14034 | pr_err("Only EPPING mode supported!"); |
| 14035 | return -ENOTSUPP; |
| 14036 | } |
| 14037 | |
| 14038 | hdd_set_conparam(con_mode_epping); |
| 14039 | con_mode = con_mode_epping; |
| 14040 | |
| 14041 | return ret; |
| 14042 | } |
| 14043 | #endif |
| 14044 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14045 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14046 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14047 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14048 | { |
| 14049 | int ret; |
| 14050 | |
| 14051 | ret = param_set_int(kmessage, kp); |
| 14052 | |
| 14053 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 14054 | pr_err("Only Monitor mode supported!"); |
| 14055 | return -ENOTSUPP; |
| 14056 | } |
| 14057 | |
| 14058 | hdd_set_conparam(con_mode_monitor); |
| 14059 | con_mode = con_mode_monitor; |
| 14060 | |
| 14061 | return ret; |
| 14062 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14063 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14064 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14065 | /** |
| 14066 | * hdd_get_conparam() - driver exit point |
| 14067 | * |
| 14068 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 14069 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14070 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14071 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14072 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14073 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14074 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14075 | } |
| 14076 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14077 | void hdd_set_conparam(int32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14078 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 14079 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14080 | } |
| 14081 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14082 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14083 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 14084 | * @hdd_ctx: HDD context |
| 14085 | * |
| 14086 | * Cleans up the pre cac interface, if it exists |
| 14087 | * |
| 14088 | * Return: None |
| 14089 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14090 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14091 | { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 14092 | uint8_t vdev_id; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14093 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 14094 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14095 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 14096 | 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] | 14097 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14098 | hdd_err("failed to get pre cac vdev id"); |
| 14099 | return; |
| 14100 | } |
| 14101 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 14102 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14103 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 14104 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14105 | return; |
| 14106 | } |
| 14107 | |
| 14108 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 14109 | wlan_hdd_sap_pre_cac_failure, |
| 14110 | (void *)precac_adapter); |
| 14111 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 14112 | |
| 14113 | } |
| 14114 | |
| 14115 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14116 | * hdd_update_ol_config - API to update ol configuration parameters |
| 14117 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14118 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14119 | * Return: void |
| 14120 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14121 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14122 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14123 | struct ol_config_info cfg = {0}; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14124 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14125 | bool self_recovery = false; |
| 14126 | QDF_STATUS status; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14127 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14128 | if (!ol_ctx) |
| 14129 | return; |
| 14130 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14131 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14132 | if (QDF_IS_STATUS_ERROR(status)) |
| 14133 | hdd_err("Failed to get self recovery ini config"); |
| 14134 | |
| 14135 | cfg.enable_self_recovery = self_recovery; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14136 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 14137 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 14138 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 14139 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14140 | |
| 14141 | ol_init_ini_config(ol_ctx, &cfg); |
| 14142 | } |
| 14143 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14144 | #ifdef FEATURE_RUNTIME_PM |
| 14145 | /** |
| 14146 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 14147 | * @hdd_ctx: hdd context |
| 14148 | * @cfg: pointer to the configuration memory being populated |
| 14149 | * |
| 14150 | * Return: void |
| 14151 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14152 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14153 | struct hif_config_info *cfg) |
| 14154 | { |
| 14155 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14156 | cfg->runtime_pm_delay = |
| 14157 | ucfg_pmo_get_runtime_pm_delay(hdd_ctx->psoc); |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14158 | } |
| 14159 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14160 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14161 | struct hif_config_info *cfg) |
| 14162 | { |
| 14163 | } |
| 14164 | #endif |
| 14165 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14166 | /** |
| 14167 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 14168 | * @hdd_ctx: HDD Context |
| 14169 | * |
| 14170 | * Return: void |
| 14171 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14172 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14173 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14174 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14175 | struct hif_config_info cfg = {0}; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14176 | bool prevent_link_down = false; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14177 | bool self_recovery = false; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14178 | QDF_STATUS status; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14179 | |
| 14180 | if (!scn) |
| 14181 | return; |
| 14182 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14183 | status = ucfg_mlme_get_prevent_link_down(hdd_ctx->psoc, |
| 14184 | &prevent_link_down); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14185 | if (QDF_IS_STATUS_ERROR(status)) |
| 14186 | hdd_err("Failed to get prevent_link_down config"); |
| 14187 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14188 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14189 | if (QDF_IS_STATUS_ERROR(status)) |
| 14190 | hdd_err("Failed to get self recovery ini config"); |
| 14191 | |
| 14192 | cfg.enable_self_recovery = self_recovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14193 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Mohit Khanna | a8c9f56 | 2019-03-25 22:17:02 -0700 | [diff] [blame] | 14194 | cfg.rx_softirq_max_yield_duration_ns = |
| 14195 | cfg_get(hdd_ctx->psoc, |
| 14196 | CFG_DP_RX_SOFTIRQ_MAX_YIELD_TIME_NS); |
| 14197 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14198 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14199 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14200 | if (prevent_link_down) |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14201 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14202 | } |
| 14203 | |
Mohit Khanna | a8c9f56 | 2019-03-25 22:17:02 -0700 | [diff] [blame] | 14204 | #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT |
| 14205 | /** |
| 14206 | * hdd_update_dp_config_rx_softirq_limits() - Update DP rx softirq limit config |
| 14207 | * datapath |
| 14208 | * @hdd_ctx: HDD Context |
| 14209 | * @params: pointer to cdp_config_params to be updated |
| 14210 | * |
| 14211 | * Void |
| 14212 | */ |
| 14213 | static |
| 14214 | void hdd_update_dp_config_rx_softirq_limits(struct hdd_context *hdd_ctx, |
| 14215 | struct cdp_config_params *params) |
| 14216 | { |
| 14217 | params->tx_comp_loop_pkt_limit = cfg_get(hdd_ctx->psoc, |
| 14218 | CFG_DP_TX_COMP_LOOP_PKT_LIMIT); |
| 14219 | params->rx_reap_loop_pkt_limit = cfg_get(hdd_ctx->psoc, |
| 14220 | CFG_DP_RX_REAP_LOOP_PKT_LIMIT); |
| 14221 | params->rx_hp_oos_update_limit = cfg_get(hdd_ctx->psoc, |
| 14222 | CFG_DP_RX_HP_OOS_UPDATE_LIMIT); |
| 14223 | } |
| 14224 | #else |
| 14225 | static |
| 14226 | void hdd_update_dp_config_rx_softirq_limits(struct hdd_context *hdd_ctx, |
| 14227 | struct cdp_config_params *params) |
| 14228 | { |
| 14229 | } |
| 14230 | #endif /* WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT */ |
| 14231 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14232 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14233 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 14234 | * datapath |
| 14235 | * @hdd_ctx: HDD Context |
| 14236 | * |
| 14237 | * Return: 0 for success/errno for failure |
| 14238 | */ |
| 14239 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 14240 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14241 | struct cdp_config_params params = {0}; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14242 | QDF_STATUS status; |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14243 | void *soc; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14244 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14245 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 14246 | params.tso_enable = cfg_get(hdd_ctx->psoc, CFG_DP_TSO); |
| 14247 | 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] | 14248 | params.tx_flow_stop_queue_threshold = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 14249 | 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] | 14250 | params.tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 14251 | cfg_get(hdd_ctx->psoc, |
| 14252 | CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14253 | params.flow_steering_enable = |
| 14254 | cfg_get(hdd_ctx->psoc, CFG_DP_FLOW_STEERING_ENABLED); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14255 | params.napi_enable = hdd_ctx->napi_enable; |
| 14256 | params.tcp_udp_checksumoffload = |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14257 | cfg_get(hdd_ctx->psoc, |
| 14258 | CFG_DP_TCP_UDP_CKSUM_OFFLOAD); |
Sravan Kumar Kairam | 0af1ee5 | 2018-12-12 20:37:51 +0530 | [diff] [blame] | 14259 | params.ipa_enable = ucfg_ipa_is_enabled(); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 14260 | params.gro_enable = cfg_get(hdd_ctx->psoc, CFG_DP_GRO); |
Mohit Khanna | a8c9f56 | 2019-03-25 22:17:02 -0700 | [diff] [blame] | 14261 | params.tx_comp_loop_pkt_limit = cfg_get(hdd_ctx->psoc, |
| 14262 | CFG_DP_TX_COMP_LOOP_PKT_LIMIT); |
| 14263 | params.rx_reap_loop_pkt_limit = cfg_get(hdd_ctx->psoc, |
| 14264 | CFG_DP_RX_REAP_LOOP_PKT_LIMIT); |
| 14265 | params.rx_hp_oos_update_limit = cfg_get(hdd_ctx->psoc, |
| 14266 | CFG_DP_RX_HP_OOS_UPDATE_LIMIT); |
| 14267 | hdd_update_dp_config_rx_softirq_limits(hdd_ctx, ¶ms); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14268 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14269 | status = cdp_update_config_parameters(soc, ¶ms); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14270 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 14271 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14272 | return status; |
| 14273 | } |
| 14274 | |
| 14275 | return 0; |
| 14276 | } |
| 14277 | |
| 14278 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14279 | * hdd_update_config() - Initialize driver per module ini parameters |
| 14280 | * @hdd_ctx: HDD Context |
| 14281 | * |
| 14282 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14283 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14284 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14285 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14286 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14287 | int ret; |
| 14288 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14289 | if (ucfg_pmo_is_ns_offloaded(hdd_ctx->psoc)) |
| 14290 | hdd_ctx->ns_offload_enable = true; |
| 14291 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14292 | hdd_update_ol_config(hdd_ctx); |
| 14293 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14294 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 14295 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 14296 | else |
| 14297 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 14298 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14299 | |
| 14300 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14301 | } |
| 14302 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14303 | /** |
| 14304 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 14305 | * @hdd_ctx: HDD context |
| 14306 | * |
| 14307 | * Return: void |
| 14308 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14309 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14310 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14311 | struct pmo_psoc_cfg psoc_cfg = {0}; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14312 | QDF_STATUS status; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14313 | enum pmo_wow_enable_type wow_enable; |
| 14314 | |
| 14315 | ucfg_pmo_get_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14316 | |
| 14317 | /* |
| 14318 | * Value of hdd_ctx->wowEnable can be, |
| 14319 | * 0 - Disable both magic pattern match and pattern byte match. |
| 14320 | * 1 - Enable magic pattern match on all interfaces. |
| 14321 | * 2 - Enable pattern byte match on all interfaces. |
| 14322 | * 3 - Enable both magic patter and pattern byte match on |
| 14323 | * all interfaces. |
| 14324 | */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14325 | wow_enable = ucfg_pmo_get_wow_enable(hdd_ctx->psoc); |
| 14326 | psoc_cfg.magic_ptrn_enable = (wow_enable & 0x01) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14327 | psoc_cfg.ptrn_match_enable_all_vdev = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14328 | (wow_enable & 0x02) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14329 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 14330 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 14331 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 14332 | &psoc_cfg.sta_max_li_mod_dtim); |
| 14333 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14334 | |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 14335 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14336 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14337 | status = ucfg_pmo_update_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 14338 | if (QDF_IS_STATUS_ERROR(status)) |
| 14339 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 14340 | |
| 14341 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14342 | } |
| 14343 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14344 | 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] | 14345 | struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14346 | { |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14347 | struct wlan_fwol_ie_whitelist whitelist = {0}; |
| 14348 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14349 | QDF_STATUS status; |
| 14350 | bool is_ie_whitelist_enable = false; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14351 | uint8_t i = 0; |
| 14352 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14353 | status = ucfg_fwol_get_ie_whitelist(psoc, &is_ie_whitelist_enable); |
| 14354 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14355 | hdd_err("Unable to get IE whitelist param"); |
| 14356 | return; |
| 14357 | } |
| 14358 | |
| 14359 | ie_whitelist->white_list = is_ie_whitelist_enable; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14360 | if (!ie_whitelist->white_list) |
| 14361 | return; |
| 14362 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14363 | status = ucfg_fwol_get_all_whitelist_params(psoc, &whitelist); |
| 14364 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14365 | hdd_err("Unable to get all whitelist params"); |
| 14366 | return; |
| 14367 | } |
| 14368 | |
| 14369 | ie_whitelist->ie_bitmap[0] = whitelist.ie_bitmap_0; |
| 14370 | ie_whitelist->ie_bitmap[1] = whitelist.ie_bitmap_1; |
| 14371 | ie_whitelist->ie_bitmap[2] = whitelist.ie_bitmap_2; |
| 14372 | ie_whitelist->ie_bitmap[3] = whitelist.ie_bitmap_3; |
| 14373 | ie_whitelist->ie_bitmap[4] = whitelist.ie_bitmap_4; |
| 14374 | ie_whitelist->ie_bitmap[5] = whitelist.ie_bitmap_5; |
| 14375 | ie_whitelist->ie_bitmap[6] = whitelist.ie_bitmap_6; |
| 14376 | ie_whitelist->ie_bitmap[7] = whitelist.ie_bitmap_7; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14377 | |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14378 | ie_whitelist->num_vendor_oui = whitelist.no_of_probe_req_ouis; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14379 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14380 | ie_whitelist->voui[i] = whitelist.probe_req_voui[i]; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14381 | } |
| 14382 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14383 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 14384 | { |
| 14385 | uint8_t i, score; |
| 14386 | |
| 14387 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 14388 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 14389 | if (score > MAX_INDEX_SCORE) |
| 14390 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 14391 | MAX_INDEX_SCORE, i); |
| 14392 | } |
| 14393 | |
| 14394 | return per_index_score; |
| 14395 | } |
| 14396 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14397 | QDF_STATUS hdd_update_score_config( |
| 14398 | struct scoring_config *score_config, struct hdd_context *hdd_ctx) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14399 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14400 | struct hdd_config *cfg = hdd_ctx->config; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14401 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14402 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14403 | bool bval = false; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 14404 | uint32_t channel_bonding_mode; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14405 | |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14406 | qdf_mem_zero(&vdev_ini_cfg, sizeof(struct wlan_mlme_nss_chains)); |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14407 | /* Populate the nss chain params from ini for this vdev type */ |
| 14408 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 14409 | QDF_STA_MODE, |
| 14410 | hdd_ctx->num_rf_chains); |
| 14411 | |
| 14412 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]; |
| 14413 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]; |
| 14414 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14415 | sme_update_score_config(hdd_ctx->mac_handle, score_config); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14416 | |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 14417 | ucfg_mlme_get_channel_bonding_24ghz(hdd_ctx->psoc, |
| 14418 | &channel_bonding_mode); |
| 14419 | score_config->cb_mode_24G = channel_bonding_mode; |
| 14420 | ucfg_mlme_get_channel_bonding_5ghz(hdd_ctx->psoc, |
| 14421 | &channel_bonding_mode); |
| 14422 | score_config->cb_mode_5G = channel_bonding_mode; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14423 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14424 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 14425 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 14426 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 14427 | score_config->he_cap = 1; |
| 14428 | |
| 14429 | if (score_config->he_cap || |
| 14430 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 14431 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 14432 | score_config->vht_cap = 1; |
| 14433 | |
| 14434 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 14435 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 14436 | score_config->ht_cap = 1; |
| 14437 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14438 | status = ucfg_mlme_get_vht_for_24ghz(hdd_ctx->psoc, &bval); |
| 14439 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14440 | hdd_err("Failed to get vht_for_24ghz"); |
| 14441 | if (score_config->vht_cap && bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14442 | score_config->vht_24G_cap = 1; |
| 14443 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14444 | status = ucfg_mlme_get_vht_enable_tx_bf(hdd_ctx->psoc, |
| 14445 | &bval); |
| 14446 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14447 | hdd_err("unable to get vht_enable_tx_bf"); |
| 14448 | |
| 14449 | if (bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14450 | score_config->beamformee_cap = 1; |
| 14451 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14452 | return QDF_STATUS_SUCCESS; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14453 | } |
| 14454 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14455 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14456 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 14457 | * @hdd_ctx: HDD context |
| 14458 | * |
| 14459 | * Return: 0 if success else err |
| 14460 | */ |
| 14461 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 14462 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14463 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14464 | struct dfs_user_config dfs_cfg = {0}; |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14465 | QDF_STATUS status; |
| 14466 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 14467 | ucfg_mlme_get_dfs_filter_offload(hdd_ctx->psoc, |
| 14468 | &dfs_cfg.dfs_is_phyerr_filter_offload); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14469 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 14470 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14471 | hdd_err("failed dfs psoc configuration"); |
| 14472 | return -EINVAL; |
| 14473 | } |
| 14474 | |
| 14475 | return 0; |
| 14476 | } |
| 14477 | |
| 14478 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14479 | * hdd_update_scan_config - API to update scan configuration parameters |
| 14480 | * @hdd_ctx: HDD context |
| 14481 | * |
| 14482 | * Return: 0 if success else err |
| 14483 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14484 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14485 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14486 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Sandeep Puligilla | d788702 | 2019-02-26 00:48:52 -0800 | [diff] [blame] | 14487 | struct scan_user_cfg scan_cfg; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14488 | QDF_STATUS status; |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14489 | uint32_t mcast_mcc_rest_time = 0; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14490 | |
Sandeep Puligilla | d788702 | 2019-02-26 00:48:52 -0800 | [diff] [blame] | 14491 | qdf_mem_zero(&scan_cfg, sizeof(scan_cfg)); |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14492 | status = ucfg_mlme_get_sta_miracast_mcc_rest_time(hdd_ctx->psoc, |
| 14493 | &mcast_mcc_rest_time); |
| 14494 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14495 | hdd_err("ucfg_mlme_get_sta_miracast_mcc_rest_time, use def"); |
| 14496 | return -EIO; |
| 14497 | } |
| 14498 | scan_cfg.sta_miracast_mcc_rest_time = mcast_mcc_rest_time; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14499 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14500 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14501 | status = hdd_update_score_config(&scan_cfg.score_config, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14502 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14503 | hdd_err("Failed to update scoring config"); |
| 14504 | return -EINVAL; |
| 14505 | } |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14506 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14507 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 14508 | if (status != QDF_STATUS_SUCCESS) { |
| 14509 | hdd_err("failed pmo psoc configuration"); |
| 14510 | return -EINVAL; |
| 14511 | } |
| 14512 | |
| 14513 | return 0; |
| 14514 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14515 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14516 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14517 | { |
| 14518 | int ret; |
| 14519 | |
| 14520 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14521 | if (ret) |
| 14522 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14523 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14524 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14525 | if (ret) |
| 14526 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14527 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14528 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14529 | if (ret) |
| 14530 | return ret; |
| 14531 | |
| 14532 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14533 | if (ret) |
| 14534 | return ret; |
| 14535 | |
| 14536 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14537 | |
| 14538 | return ret; |
| 14539 | } |
| 14540 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14541 | /** |
| 14542 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 14543 | * @mode : cfg80211 DFS mode |
| 14544 | * |
| 14545 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 14546 | */ |
| 14547 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 14548 | { |
| 14549 | switch (mode) { |
| 14550 | case DFS_MODE_ENABLE: |
| 14551 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14552 | case DFS_MODE_DISABLE: |
| 14553 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14554 | case DFS_MODE_DEPRIORITIZE: |
| 14555 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14556 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14557 | hdd_debug("ACS dfs mode is NONE"); |
| 14558 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14559 | } |
| 14560 | } |
| 14561 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14562 | /** |
| 14563 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 14564 | * @hddctx: pointer to hdd context |
| 14565 | * @set_value: enable/disable |
| 14566 | * |
| 14567 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 14568 | * Host(even though it is duplicate). When Host send vendor command |
| 14569 | * disable,FW doesn't perform any action. Whenever any change in |
| 14570 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 14571 | * |
| 14572 | * return - 0 on success, appropriate error values on failure. |
| 14573 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14574 | 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] | 14575 | { |
| 14576 | QDF_STATUS status; |
| 14577 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14578 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14579 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14580 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14581 | status = sme_enable_disable_chanavoidind_event(hdd_ctx->mac_handle, |
| 14582 | set_value); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14583 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14584 | hdd_err("Failed to send chan avoid command to SME"); |
| 14585 | return -EINVAL; |
| 14586 | } |
| 14587 | return 0; |
| 14588 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14589 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14590 | /** |
| 14591 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 14592 | * @value: value to set |
| 14593 | * |
| 14594 | * This function will set the passed value to roaming in progress flag. |
| 14595 | * |
| 14596 | * Return: None |
| 14597 | */ |
| 14598 | void hdd_set_roaming_in_progress(bool value) |
| 14599 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14600 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14601 | |
| 14602 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14603 | if (!hdd_ctx) { |
| 14604 | hdd_err("HDD context is NULL"); |
| 14605 | return; |
| 14606 | } |
| 14607 | |
| 14608 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14609 | hdd_debug("Roaming in Progress set to %d", value); |
Abhinav Kumar | 2b431b6 | 2019-03-18 20:23:58 +0530 | [diff] [blame] | 14610 | if (!hdd_ctx->roaming_in_progress) { |
| 14611 | /* Reset scan reject params on successful roam complete */ |
| 14612 | hdd_debug("Reset scan reject params"); |
| 14613 | hdd_init_scan_reject_params(hdd_ctx); |
| 14614 | } |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14615 | } |
| 14616 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14617 | bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14618 | { |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14619 | if (!hdd_ctx) { |
| 14620 | hdd_err("HDD context is NULL"); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14621 | return false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14622 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 14623 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14624 | hdd_debug("roaming_in_progress = %d", hdd_ctx->roaming_in_progress); |
| 14625 | |
| 14626 | return hdd_ctx->roaming_in_progress; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14627 | } |
| 14628 | |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14629 | bool hdd_is_connection_in_progress(uint8_t *out_vdev_id, |
| 14630 | enum scan_reject_states *out_reason) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14631 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 14632 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14633 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14634 | uint8_t sta_id = 0; |
| 14635 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14636 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14637 | mac_handle_t mac_handle; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14638 | |
| 14639 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14640 | if (!hdd_ctx) { |
| 14641 | hdd_err("HDD context is NULL"); |
| 14642 | return false; |
| 14643 | } |
| 14644 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14645 | mac_handle = hdd_ctx->mac_handle; |
| 14646 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14647 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 929afa4 | 2018-06-01 15:04:44 -0700 | [diff] [blame] | 14648 | hdd_debug("Adapter with device mode %s(%d) exists", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 14649 | qdf_opmode_str(adapter->device_mode), |
| 14650 | adapter->device_mode); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14651 | if (((QDF_STA_MODE == adapter->device_mode) |
| 14652 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 14653 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 14654 | && (eConnectionState_Connecting == |
| 14655 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 14656 | conn_info.conn_state)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14657 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14658 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14659 | adapter->vdev_id); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14660 | if (out_vdev_id && out_reason) { |
| 14661 | *out_vdev_id = adapter->vdev_id; |
| 14662 | *out_reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14663 | } |
| 14664 | return true; |
| 14665 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 14666 | /* |
| 14667 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 14668 | * hdd_is_roaming_in_progress is for LFR3 |
| 14669 | */ |
| 14670 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 14671 | sme_neighbor_middle_of_roaming( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14672 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14673 | adapter->vdev_id)) || |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14674 | hdd_is_roaming_in_progress(hdd_ctx)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14675 | hdd_debug("%pK(%d) Reassociation 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 = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14681 | } |
| 14682 | return true; |
| 14683 | } |
| 14684 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 14685 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 14686 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 14687 | hdd_sta_ctx = |
| 14688 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 14689 | if ((eConnectionState_Associated == |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 14690 | hdd_sta_ctx->conn_info.conn_state) |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 14691 | && sme_is_sta_key_exchange_in_progress( |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14692 | mac_handle, adapter->vdev_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14693 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 14694 | &(adapter->mac_addr.bytes[0]); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 14695 | hdd_debug("client " QDF_MAC_ADDR_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14696 | " is in middle of WPS/EAPOL exchange.", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 14697 | QDF_MAC_ADDR_ARRAY(sta_mac)); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14698 | if (out_vdev_id && out_reason) { |
| 14699 | *out_vdev_id = adapter->vdev_id; |
| 14700 | *out_reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14701 | } |
| 14702 | return true; |
| 14703 | } |
| 14704 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 14705 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 14706 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 14707 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14708 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14709 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14710 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14711 | continue; |
| 14712 | |
| 14713 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14714 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 14715 | sta_mac.bytes[0]); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 14716 | hdd_debug("client " QDF_MAC_ADDR_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14717 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 14718 | QDF_MAC_ADDR_ARRAY(sta_mac)); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14719 | if (out_vdev_id && out_reason) { |
| 14720 | *out_vdev_id = adapter->vdev_id; |
| 14721 | *out_reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14722 | } |
| 14723 | return true; |
| 14724 | } |
| 14725 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14726 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14727 | return true; |
| 14728 | } |
| 14729 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14730 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14731 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14732 | return false; |
| 14733 | } |
| 14734 | |
| 14735 | /** |
| 14736 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14737 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14738 | * |
| 14739 | * Return: None |
| 14740 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14741 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14742 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 14743 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 14744 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14745 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14746 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | 8f8ceb9 | 2019-03-24 08:16:55 -0700 | [diff] [blame] | 14747 | struct sap_config *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14748 | void *sap_ctx; |
| 14749 | |
| 14750 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 14751 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 14752 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14753 | |
| 14754 | mutex_lock(&hdd_ctx->sap_lock); |
| 14755 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 14756 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14757 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 14758 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 14759 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 14760 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14761 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14762 | qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 14763 | SME_CMD_STOP_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14764 | |
| 14765 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14766 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14767 | goto end; |
| 14768 | } |
| 14769 | } |
| 14770 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14771 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14772 | ap_adapter->device_mode, ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14773 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14774 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14775 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14776 | |
| 14777 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14778 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14779 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14780 | eUPDATE_IE_ALL); |
| 14781 | goto end; |
| 14782 | } |
| 14783 | |
| 14784 | qdf_event_reset(&hostapd_state->qdf_event); |
| 14785 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 14786 | sap_config, |
| 14787 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14788 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14789 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14790 | eUPDATE_IE_ALL); |
| 14791 | goto end; |
| 14792 | } |
| 14793 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14794 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14795 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14796 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 14797 | SME_CMD_START_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14798 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14799 | eUPDATE_IE_ALL); |
| 14800 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14801 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14802 | goto end; |
| 14803 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14804 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14805 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14806 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14807 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14808 | ap_adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14809 | ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14810 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14811 | ap_adapter->device_mode, |
| 14812 | true); |
| 14813 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14814 | } |
| 14815 | end: |
| 14816 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14817 | } |
| 14818 | |
| 14819 | /** |
| 14820 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 14821 | * with non dfs acs |
| 14822 | * |
| 14823 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 14824 | * |
| 14825 | * Return: None |
| 14826 | */ |
| 14827 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 14828 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14829 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14830 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 14831 | struct cds_context *cds_ctx; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14832 | uint8_t restart_chan; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14833 | |
| 14834 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14835 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14836 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14837 | return; |
| 14838 | } |
| 14839 | |
| 14840 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 14841 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14842 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14843 | return; |
| 14844 | } |
| 14845 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14846 | if (policy_mgr_get_concurrency_mode(hdd_ctx->psoc) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14847 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 14848 | hdd_debug("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14849 | return; |
| 14850 | } |
| 14851 | |
| 14852 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14853 | if (ap_adapter && |
| 14854 | test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags) && |
| 14855 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, |
| 14856 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14857 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14858 | 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] | 14859 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14860 | restart_chan = |
bings | 6c4672b | 2019-03-19 16:00:19 +0800 | [diff] [blame] | 14861 | wlansap_get_safe_channel_from_pcl_and_acs_range( |
| 14862 | WLAN_HDD_GET_SAP_CTX_PTR(ap_adapter)); |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14863 | if (!restart_chan || |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14864 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, restart_chan)) |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14865 | restart_chan = SAP_DEFAULT_5GHZ_CHANNEL; |
| 14866 | |
| 14867 | hdd_switch_sap_channel(ap_adapter, restart_chan, true); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14868 | } |
| 14869 | } |
| 14870 | |
| 14871 | /** |
| 14872 | * hdd_set_connection_in_progress() - to set the connection in |
| 14873 | * progress flag |
| 14874 | * @value: value to set |
| 14875 | * |
| 14876 | * This function will set the passed value to connection in progress flag. |
| 14877 | * If value is previously being set to true then no need to set it again. |
| 14878 | * |
| 14879 | * Return: true if value is being set correctly and false otherwise. |
| 14880 | */ |
| 14881 | bool hdd_set_connection_in_progress(bool value) |
| 14882 | { |
| 14883 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14884 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14885 | |
| 14886 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14887 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14888 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14889 | return false; |
| 14890 | } |
| 14891 | |
| 14892 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 14893 | /* |
| 14894 | * if the value is set to true previously and if someone is |
| 14895 | * trying to make it true again then it could be some race |
| 14896 | * condition being triggered. Avoid this situation by returning |
| 14897 | * false |
| 14898 | */ |
| 14899 | if (hdd_ctx->connection_in_progress && value) |
| 14900 | status = false; |
| 14901 | else |
| 14902 | hdd_ctx->connection_in_progress = value; |
| 14903 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 14904 | return status; |
| 14905 | } |
| 14906 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14907 | 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] | 14908 | { |
| 14909 | if (!adapter) { |
| 14910 | hdd_err("Invalid adapter"); |
| 14911 | return -EINVAL; |
| 14912 | } |
| 14913 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14914 | sme_cli_set_command(adapter->vdev_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14915 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 14916 | set_value, VDEV_CMD); |
| 14917 | return 0; |
| 14918 | |
| 14919 | } |
| 14920 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14921 | 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] | 14922 | { |
| 14923 | if (!adapter) { |
| 14924 | hdd_err("Invalid adapter"); |
| 14925 | return -EINVAL; |
| 14926 | } |
| 14927 | |
| 14928 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14929 | sme_cli_set_command(adapter->vdev_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14930 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 14931 | set_value, VDEV_CMD); |
| 14932 | return 0; |
| 14933 | } |
| 14934 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14935 | 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] | 14936 | *psoc, uint8_t vdev_id) |
| 14937 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14938 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14939 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 14940 | |
| 14941 | /* |
| 14942 | * Currently PSOC is not being used. But this logic will |
| 14943 | * change once we have the converged implementation of |
| 14944 | * HDD context per PSOC in place. This would break if |
| 14945 | * multiple vdev objects reuse the vdev id. |
| 14946 | */ |
| 14947 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 14948 | if (!adapter) |
| 14949 | hdd_err("Get adapter by vdev id failed"); |
| 14950 | |
| 14951 | return adapter; |
| 14952 | } |
| 14953 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14954 | 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] | 14955 | int8_t *rssi, int8_t *snr) |
| 14956 | { |
| 14957 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14958 | mac_handle_t mac_handle; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14959 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14960 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14961 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14962 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 14963 | status = sme_get_rssi_snr_by_bssid(mac_handle, |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14964 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14965 | if (QDF_STATUS_SUCCESS != status) { |
| 14966 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 14967 | return -EINVAL; |
| 14968 | } |
| 14969 | |
| 14970 | return 0; |
| 14971 | } |
| 14972 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14973 | /** |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14974 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 14975 | * @adapter - HDD adapter |
| 14976 | * |
| 14977 | * Return: 0 on success and non zero value on failure |
| 14978 | */ |
| 14979 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 14980 | { |
| 14981 | struct hdd_context *hdd_ctx; |
| 14982 | int ret; |
| 14983 | QDF_STATUS status; |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14984 | uint8_t sys_pref = 0; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14985 | |
| 14986 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 14987 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14988 | if (ret < 0) |
| 14989 | return ret; |
| 14990 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14991 | ucfg_policy_mgr_get_sys_pref(hdd_ctx->psoc, |
| 14992 | &sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14993 | /* set the system preferece to default */ |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14994 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->psoc, sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14995 | |
| 14996 | /* clear the bitmap */ |
| 14997 | adapter->active_ac = 0; |
| 14998 | |
| 14999 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 15000 | adapter->vdev_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15001 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 15002 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 15003 | adapter->vdev_id, |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 15004 | false, 0, 0, false); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15005 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 15006 | hdd_err("failed to reset limit off chan params"); |
| 15007 | ret = -EINVAL; |
| 15008 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 15009 | |
| 15010 | return ret; |
| 15011 | } |
| 15012 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15013 | void hdd_set_rx_mode_rps(bool enable) |
| 15014 | { |
| 15015 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 15016 | struct hdd_context *hdd_ctx; |
| 15017 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15018 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 15019 | if (!cds_cfg) |
| 15020 | return; |
| 15021 | |
| 15022 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 15023 | if (!hdd_ctx) |
| 15024 | return; |
| 15025 | |
| 15026 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 15027 | if (!adapter) |
| 15028 | return; |
| 15029 | |
| 15030 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15031 | if (enable && !cds_cfg->rps_enabled) |
| 15032 | hdd_send_rps_ind(adapter); |
| 15033 | else if (!enable && cds_cfg->rps_enabled) |
| 15034 | hdd_send_rps_disable_ind(adapter); |
| 15035 | } |
| 15036 | } |
| 15037 | |
Abhinav Kumar | 338e57d | 2019-02-04 17:30:10 +0530 | [diff] [blame] | 15038 | void hdd_hidden_ssid_enable_roaming(hdd_handle_t hdd_handle, uint8_t vdev_id) |
| 15039 | { |
| 15040 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
| 15041 | struct hdd_adapter *adapter; |
| 15042 | |
| 15043 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 15044 | |
| 15045 | if (!adapter) { |
| 15046 | hdd_err("Adapter is null"); |
| 15047 | return; |
| 15048 | } |
| 15049 | /* enable roaming on all adapters once hdd get hidden ssid rsp */ |
| 15050 | wlan_hdd_enable_roaming(adapter); |
| 15051 | } |
| 15052 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15053 | /* Register the module init/exit functions */ |
| 15054 | module_init(hdd_module_init); |
| 15055 | module_exit(hdd_module_exit); |
| 15056 | |
| 15057 | MODULE_LICENSE("Dual BSD/GPL"); |
| 15058 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 15059 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 15060 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15061 | static const struct kernel_param_ops con_mode_ops = { |
| 15062 | .set = con_mode_handler, |
| 15063 | .get = param_get_int, |
| 15064 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15065 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15066 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 15067 | .set = con_mode_handler_ftm, |
| 15068 | .get = param_get_int, |
| 15069 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 15070 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 15071 | #ifdef WLAN_FEATURE_EPPING |
| 15072 | static const struct kernel_param_ops con_mode_epping_ops = { |
| 15073 | .set = con_mode_handler_epping, |
| 15074 | .get = param_get_int, |
| 15075 | }; |
| 15076 | #endif |
| 15077 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15078 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15079 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 15080 | .set = con_mode_handler_monitor, |
| 15081 | .get = param_get_int, |
| 15082 | }; |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15083 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 15084 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15085 | static const struct kernel_param_ops fwpath_ops = { |
| 15086 | .set = fwpath_changed_handler, |
| 15087 | .get = param_get_string, |
| 15088 | }; |
| 15089 | |
| 15090 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 15091 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15092 | |
| 15093 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 15094 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15095 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 15096 | #ifdef WLAN_FEATURE_EPPING |
| 15097 | module_param_cb(con_mode_epping, &con_mode_epping_ops, |
| 15098 | &con_mode_epping, 0644); |
| 15099 | #endif |
| 15100 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15101 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15102 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 15103 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15104 | #endif |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15105 | |
| 15106 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 15107 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15108 | |
| 15109 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15110 | |
| 15111 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15112 | |
| 15113 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |
Dustin Brown | 4bbd546 | 2019-03-22 11:18:13 -0700 | [diff] [blame] | 15114 | |
| 15115 | static int timer_multiplier_get_handler(char *buffer, |
| 15116 | const struct kernel_param *kp) |
| 15117 | { |
| 15118 | return scnprintf(buffer, PAGE_SIZE, "%u", qdf_timer_get_multiplier()); |
| 15119 | } |
| 15120 | |
| 15121 | static int timer_multiplier_set_handler(const char *kmessage, |
| 15122 | const struct kernel_param *kp) |
| 15123 | { |
| 15124 | QDF_STATUS status; |
| 15125 | uint32_t scalar; |
| 15126 | |
| 15127 | status = qdf_uint32_parse(kmessage, &scalar); |
| 15128 | if (QDF_IS_STATUS_ERROR(status)) |
| 15129 | return qdf_status_to_os_return(status); |
| 15130 | |
| 15131 | if (!cfg_in_range(CFG_TIMER_MULTIPLIER, scalar)) |
| 15132 | return -ERANGE; |
| 15133 | |
| 15134 | qdf_timer_set_multiplier(scalar); |
| 15135 | |
| 15136 | return 0; |
| 15137 | } |
| 15138 | |
| 15139 | static const struct kernel_param_ops timer_multiplier_ops = { |
| 15140 | .get = timer_multiplier_get_handler, |
| 15141 | .set = timer_multiplier_set_handler, |
| 15142 | }; |
| 15143 | |
| 15144 | module_param_cb(timer_multiplier, &timer_multiplier_ops, NULL, 0644); |
| 15145 | |