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> |
gaurank kathpalia | 3ebc17b | 2019-05-29 10:25:09 +0530 | [diff] [blame] | 172 | #include "wlan_blm_ucfg_api.h" |
Tiger Yu | e40e783 | 2019-04-25 10:46:53 +0800 | [diff] [blame^] | 173 | #include "ol_txrx.h" |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 174 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 175 | #ifdef MODULE |
| 176 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 177 | #else |
| 178 | #define WLAN_MODULE_NAME "wlan" |
| 179 | #endif |
| 180 | |
| 181 | #ifdef TIMER_MANAGER |
| 182 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 183 | #else |
| 184 | #define TIMER_MANAGER_STR "" |
| 185 | #endif |
| 186 | |
| 187 | #ifdef MEMORY_DEBUG |
| 188 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 189 | #else |
| 190 | #define MEMORY_DEBUG_STR "" |
| 191 | #endif |
| 192 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 193 | #ifdef PANIC_ON_BUG |
| 194 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 195 | #else |
| 196 | #define PANIC_ON_BUG_STR "" |
| 197 | #endif |
| 198 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 199 | int wlan_start_ret_val; |
| 200 | static DECLARE_COMPLETION(wlan_start_comp); |
| 201 | static unsigned int dev_num = 1; |
| 202 | static struct cdev wlan_hdd_state_cdev; |
| 203 | static struct class *class; |
| 204 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 205 | #ifndef MODULE |
| 206 | static struct gwlan_loader *wlan_loader; |
| 207 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 208 | struct kobj_attribute *attr, |
| 209 | const char *buf, size_t count); |
| 210 | struct gwlan_loader { |
| 211 | bool loaded_state; |
| 212 | struct kobject *boot_wlan_obj; |
| 213 | struct attribute_group *attr_group; |
| 214 | }; |
| 215 | |
| 216 | static struct kobj_attribute wlan_boot_attribute = |
| 217 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 218 | |
| 219 | static struct attribute *attrs[] = { |
| 220 | &wlan_boot_attribute.attr, |
| 221 | NULL, |
| 222 | }; |
| 223 | |
| 224 | #define MODULE_INITIALIZED 1 |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 225 | |
| 226 | #ifdef MULTI_IF_NAME |
| 227 | #define WLAN_LOADER_NAME "boot_" MULTI_IF_NAME |
| 228 | #else |
| 229 | #define WLAN_LOADER_NAME "boot_wlan" |
| 230 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 231 | #endif |
| 232 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 233 | /* the Android framework expects this param even though we don't use it */ |
| 234 | #define BUF_LEN 20 |
| 235 | static char fwpath_buffer[BUF_LEN]; |
| 236 | static struct kparam_string fwpath = { |
| 237 | .string = fwpath_buffer, |
| 238 | .maxlen = BUF_LEN, |
| 239 | }; |
| 240 | |
| 241 | static char *country_code; |
| 242 | static int enable_11d = -1; |
| 243 | static int enable_dfs_chan_scan = -1; |
Rajeev Kumar | 588a254 | 2019-04-08 10:57:19 -0700 | [diff] [blame] | 244 | static bool is_mode_change_psoc_idle_shutdown; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 245 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 246 | #define WLAN_NLINK_CESIUM 30 |
| 247 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 248 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 249 | |
| 250 | #define WOW_MAX_FILTER_LISTS 1 |
| 251 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 252 | #define WOW_MIN_PATTERN_SIZE 6 |
| 253 | #define WOW_MAX_PATTERN_SIZE 64 |
| 254 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 255 | /* max peer can be tdls peers + self peer + bss peer */ |
| 256 | #define HDD_MAX_VDEV_PEER_COUNT (HDD_MAX_NUM_TDLS_STA + 2) |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 257 | #define IS_IDLE_STOP (!cds_is_driver_unloading() && \ |
| 258 | !cds_is_driver_recovering() && !cds_is_driver_loading()) |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 259 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 260 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 261 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 262 | .flags = WIPHY_WOWLAN_ANY | |
| 263 | WIPHY_WOWLAN_MAGIC_PKT | |
| 264 | WIPHY_WOWLAN_DISCONNECT | |
| 265 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 266 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 267 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 268 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 269 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 270 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 271 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 272 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 273 | }; |
| 274 | #endif |
| 275 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 276 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 277 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 278 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 280 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 281 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 282 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 283 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 284 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 285 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 286 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 287 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 288 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 289 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 290 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 291 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 292 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 293 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 294 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 295 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 296 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 297 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 298 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 299 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 300 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 301 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 302 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 303 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 304 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 305 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 306 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 307 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 308 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 309 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 310 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 311 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 312 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 313 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 314 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 315 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 316 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 317 | [QDF_MODULE_ID_ACTION_OUI] = {QDF_TRACE_LEVEL_ALL}, |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 318 | [QDF_MODULE_ID_CONFIG] = {QDF_TRACE_LEVEL_ALL}, |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 319 | [QDF_MODULE_ID_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 8d039c8 | 2018-07-11 20:41:14 +0530 | [diff] [blame] | 320 | [QDF_MODULE_ID_TARGET] = {QDF_TRACE_LEVEL_ALL}, |
Kiran Kumar Lokere | 4ce4048 | 2018-08-30 16:31:00 -0700 | [diff] [blame] | 321 | [QDF_MODULE_ID_CRYPTO] = {QDF_TRACE_LEVEL_ALL}, |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 322 | [QDF_MODULE_ID_FWOL] = {QDF_TRACE_LEVEL_ALL}, |
Abhishek Singh | 0b0105f | 2018-09-25 10:44:16 +0530 | [diff] [blame] | 323 | [QDF_MODULE_ID_SM_ENGINE] = {QDF_TRACE_LEVEL_ALL}, |
| 324 | [QDF_MODULE_ID_CMN_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Nachiket Kukade | 089b983 | 2018-12-12 16:38:17 +0530 | [diff] [blame] | 325 | [QDF_MODULE_ID_NAN] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 6ed4434 | 2019-02-07 21:11:00 +0530 | [diff] [blame] | 326 | [QDF_MODULE_ID_CP_STATS] = {QDF_TRACE_LEVEL_ALL}, |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame] | 327 | [QDF_MODULE_ID_INTEROP_ISSUES_AP] = {QDF_TRACE_LEVEL_ALL}, |
gaurank kathpalia | 7ef7218 | 2019-05-29 19:41:25 +0530 | [diff] [blame] | 328 | [QDF_MODULE_ID_BLACKLIST_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 329 | }; |
| 330 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 331 | struct notifier_block hdd_netdev_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 332 | |
| 333 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 334 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 335 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 336 | #endif |
| 337 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 338 | void hdd_start_complete(int ret) |
| 339 | { |
| 340 | wlan_start_ret_val = ret; |
| 341 | |
| 342 | complete(&wlan_start_comp); |
| 343 | } |
| 344 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 345 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 346 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 347 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 348 | * |
| 349 | * Return: none |
| 350 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 351 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 352 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 353 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 354 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 355 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 356 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 357 | } |
| 358 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 359 | #ifdef QCA_HL_NETDEV_FLOW_CONTROL |
| 360 | void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter, |
| 361 | enum netif_action_type action) |
| 362 | { |
| 363 | if (!adapter->tx_flow_timer_initialized) |
| 364 | return; |
| 365 | |
| 366 | if (action == WLAN_WAKE_NON_PRIORITY_QUEUE) { |
| 367 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
Ajit Pal Singh | e6da1de | 2018-12-27 16:20:45 +0530 | [diff] [blame] | 368 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = false; |
| 369 | adapter->hdd_stats.tx_rx_stats.txflow_unpause_cnt++; |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 370 | } else if (action == WLAN_STOP_NON_PRIORITY_QUEUE) { |
| 371 | QDF_STATUS status = |
| 372 | qdf_mc_timer_start(&adapter->tx_flow_control_timer, |
| 373 | WLAN_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 374 | |
| 375 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 376 | hdd_err("Failed to start tx_flow_control_timer"); |
| 377 | else |
| 378 | adapter-> |
| 379 | hdd_stats.tx_rx_stats.txflow_timer_cnt++; |
| 380 | |
| 381 | adapter->hdd_stats.tx_rx_stats.txflow_pause_cnt++; |
| 382 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = true; |
| 383 | } |
| 384 | } |
| 385 | #endif /* QCA_HL_NETDEV_FLOW_CONTROL */ |
| 386 | |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 387 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 388 | void wlan_hdd_update_tcp_rx_param(struct hdd_context *hdd_ctx, void *data) |
| 389 | { |
| 390 | if (!hdd_ctx) { |
| 391 | hdd_err("HDD context is null"); |
| 392 | return; |
| 393 | } |
| 394 | |
| 395 | if (!data) { |
| 396 | hdd_err("Data is null"); |
| 397 | return; |
| 398 | } |
| 399 | if (hdd_ctx->config->enable_tcp_param_update) |
| 400 | wlan_hdd_send_tcp_param_update_event(hdd_ctx, data, 1); |
| 401 | else |
| 402 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 403 | WLAN_SVC_WLAN_TP_IND, |
| 404 | data, |
| 405 | sizeof(struct wlan_rx_tp_data)); |
| 406 | } |
| 407 | |
| 408 | void wlan_hdd_update_tcp_tx_param(struct hdd_context *hdd_ctx, void *data) |
| 409 | { |
| 410 | enum wlan_tp_level next_tx_level; |
| 411 | struct wlan_tx_tp_data *tx_tp_data; |
| 412 | |
| 413 | if (!hdd_ctx) { |
| 414 | hdd_err("HDD context is null"); |
| 415 | return; |
| 416 | } |
| 417 | |
| 418 | if (!data) { |
| 419 | hdd_err("Data is null"); |
| 420 | return; |
| 421 | } |
| 422 | |
| 423 | tx_tp_data = (struct wlan_tx_tp_data *)data; |
| 424 | next_tx_level = tx_tp_data->level; |
| 425 | |
| 426 | if (hdd_ctx->config->enable_tcp_param_update) |
| 427 | wlan_hdd_send_tcp_param_update_event(hdd_ctx, data, 0); |
| 428 | else |
| 429 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 430 | WLAN_SVC_WLAN_TP_TX_IND, |
| 431 | &next_tx_level, |
| 432 | sizeof(next_tx_level)); |
| 433 | } |
| 434 | |
| 435 | /** |
| 436 | * wlan_hdd_send_tcp_param_update_event() - Send vendor event to update |
| 437 | * TCP parameter through Wi-Fi HAL |
| 438 | * @hdd_ctx: Pointer to HDD context |
| 439 | * @data: Parameters to update |
| 440 | * @dir: Direction(tx/rx) to update |
| 441 | * |
| 442 | * Return: None |
| 443 | */ |
| 444 | void wlan_hdd_send_tcp_param_update_event(struct hdd_context *hdd_ctx, |
| 445 | void *data, |
| 446 | uint8_t dir) |
| 447 | { |
| 448 | struct sk_buff *vendor_event; |
| 449 | uint32_t event_len; |
| 450 | bool tcp_limit_output = false; |
| 451 | bool tcp_del_ack_ind_enabled = false; |
| 452 | bool tcp_adv_win_scl_enabled = false; |
| 453 | enum wlan_tp_level next_tp_level = WLAN_SVC_TP_NONE; |
| 454 | |
| 455 | event_len = sizeof(uint8_t) + sizeof(uint8_t) + NLMSG_HDRLEN; |
| 456 | |
| 457 | if (dir == 0) /*TX Flow */ { |
| 458 | struct wlan_tx_tp_data *tx_tp_data = |
| 459 | (struct wlan_tx_tp_data *)data; |
| 460 | |
| 461 | next_tp_level = tx_tp_data->level; |
| 462 | |
| 463 | if (tx_tp_data->tcp_limit_output) { |
| 464 | /* TCP_LIMIT_OUTPUT_BYTES */ |
| 465 | event_len += sizeof(uint32_t); |
| 466 | tcp_limit_output = true; |
| 467 | } |
| 468 | } else if (dir == 1) /* RX Flow */ { |
| 469 | struct wlan_rx_tp_data *rx_tp_data = |
| 470 | (struct wlan_rx_tp_data *)data; |
| 471 | |
| 472 | next_tp_level = rx_tp_data->level; |
| 473 | |
| 474 | if (rx_tp_data->rx_tp_flags & TCP_DEL_ACK_IND_MASK) { |
| 475 | event_len += sizeof(uint32_t); /* TCP_DELACK_SEG */ |
| 476 | tcp_del_ack_ind_enabled = true; |
| 477 | } |
| 478 | if (rx_tp_data->rx_tp_flags & TCP_ADV_WIN_SCL_MASK) { |
| 479 | event_len += sizeof(uint32_t); /* TCP_ADV_WIN_SCALE */ |
| 480 | tcp_adv_win_scl_enabled = true; |
| 481 | } |
| 482 | } else { |
| 483 | hdd_err("Invalid Direction [%d]", dir); |
| 484 | return; |
| 485 | } |
| 486 | |
| 487 | vendor_event = |
| 488 | cfg80211_vendor_event_alloc( |
| 489 | hdd_ctx->wiphy, |
| 490 | NULL, event_len, |
| 491 | QCA_NL80211_VENDOR_SUBCMD_THROUGHPUT_CHANGE_EVENT_INDEX, |
| 492 | GFP_KERNEL); |
| 493 | |
| 494 | if (!vendor_event) { |
| 495 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 496 | return; |
| 497 | } |
| 498 | |
| 499 | if (nla_put_u8( |
| 500 | vendor_event, |
| 501 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_DIRECTION, |
| 502 | dir)) |
| 503 | goto tcp_param_change_nla_failed; |
| 504 | |
| 505 | if (nla_put_u8( |
| 506 | vendor_event, |
| 507 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_THROUGHPUT_LEVEL, |
| 508 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 509 | QCA_WLAN_THROUGHPUT_LEVEL_LOW : |
| 510 | QCA_WLAN_THROUGHPUT_LEVEL_HIGH))) |
| 511 | goto tcp_param_change_nla_failed; |
| 512 | |
| 513 | if (tcp_limit_output && |
| 514 | nla_put_u32( |
| 515 | vendor_event, |
| 516 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_LIMIT_OUTPUT_BYTES, |
| 517 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 518 | TCP_LIMIT_OUTPUT_BYTES_LOW : |
| 519 | TCP_LIMIT_OUTPUT_BYTES_HI))) |
| 520 | goto tcp_param_change_nla_failed; |
| 521 | |
| 522 | if (tcp_del_ack_ind_enabled && |
| 523 | (nla_put_u32( |
| 524 | vendor_event, |
| 525 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_DELACK_SEG, |
| 526 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 527 | TCP_DEL_ACK_LOW : TCP_DEL_ACK_HI)))) |
| 528 | goto tcp_param_change_nla_failed; |
| 529 | |
| 530 | if (tcp_adv_win_scl_enabled && |
| 531 | (nla_put_u32( |
| 532 | vendor_event, |
| 533 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_ADV_WIN_SCALE, |
| 534 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 535 | WIN_SCALE_LOW : WIN_SCALE_HI)))) |
| 536 | goto tcp_param_change_nla_failed; |
| 537 | |
| 538 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 539 | return; |
| 540 | |
| 541 | tcp_param_change_nla_failed: |
| 542 | hdd_err("nla_put api failed"); |
| 543 | kfree_skb(vendor_event); |
| 544 | } |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 545 | #endif /*WLAN_FEATURE_DP_BUS_BANDWIDTH*/ |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 546 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 547 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 548 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 549 | * @vdev_id: vdev_id |
| 550 | * @action: action type |
| 551 | * @reason: reason type |
| 552 | * |
| 553 | * Return: none |
| 554 | */ |
| 555 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 556 | enum netif_action_type action, enum netif_reason_type reason) |
| 557 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 558 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 559 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 560 | |
| 561 | if (!hdd_ctx) { |
| 562 | hdd_err("hdd ctx is NULL"); |
| 563 | return; |
| 564 | } |
| 565 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 566 | wlan_hdd_mod_fc_timer(adapter, action); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 567 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 571 | * Store WLAN driver version and timestamp info in global variables such that |
| 572 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 573 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 574 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 575 | #ifdef BUILD_TAG |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 576 | 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] | 577 | #else |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 578 | 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] | 579 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 580 | |
| 581 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 582 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 583 | * @hdd_ctx: HDD context |
| 584 | * @chan_list: buf hold returned chan list |
| 585 | * @chan_num: input buf size and output returned chan num |
| 586 | * |
| 587 | * This function helps get current available chan list from regulatory |
| 588 | * module. It excludes the "disabled" and "invalid" channels. |
| 589 | * |
| 590 | * Return: 0 for success. |
| 591 | */ |
| 592 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 593 | uint8_t *chan_list, |
| 594 | uint32_t *chan_num) |
| 595 | { |
| 596 | int i = 0, j = 0; |
| 597 | struct regulatory_channel *cur_chan_list; |
| 598 | struct wlan_objmgr_pdev *pdev; |
| 599 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 600 | if (!hdd_ctx || !hdd_ctx->pdev || !chan_list || !chan_num) |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 601 | return -EINVAL; |
| 602 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 603 | pdev = hdd_ctx->pdev; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 604 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 605 | sizeof(struct regulatory_channel)); |
| 606 | if (!cur_chan_list) |
| 607 | return -ENOMEM; |
| 608 | |
| 609 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 610 | QDF_STATUS_SUCCESS) { |
| 611 | qdf_mem_free(cur_chan_list); |
| 612 | return -EINVAL; |
| 613 | } |
| 614 | |
| 615 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 616 | uint32_t ch = cur_chan_list[i].chan_num; |
| 617 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 618 | ch); |
| 619 | |
| 620 | if (state != CHANNEL_STATE_DISABLE && |
| 621 | state != CHANNEL_STATE_INVALID && |
| 622 | j < *chan_num) { |
| 623 | chan_list[j] = (uint8_t)ch; |
| 624 | j++; |
| 625 | } |
| 626 | } |
| 627 | *chan_num = j; |
| 628 | qdf_mem_free(cur_chan_list); |
| 629 | return 0; |
| 630 | } |
| 631 | |
| 632 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 633 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 634 | * @adapter: HDD adapter |
| 635 | * @chan_number: Channel number |
| 636 | * @chan_bw: Bandwidth |
| 637 | * |
| 638 | * Checks if the given bandwidth is valid for the given channel number. |
| 639 | * |
| 640 | * Return: 0 for success, non-zero for failure |
| 641 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 642 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 643 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 644 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 645 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 646 | uint8_t chan[NUM_CHANNELS]; |
| 647 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 648 | bool found = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 649 | mac_handle_t mac_handle; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 650 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 651 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 652 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 653 | if (!mac_handle) { |
| 654 | hdd_err("Invalid MAC handle"); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 655 | return -EINVAL; |
| 656 | } |
| 657 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 658 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 659 | &len); |
| 660 | if (ret) { |
| 661 | hdd_err("error %d in getting valid channel list", ret); |
| 662 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | for (i = 0; i < len; i++) { |
| 666 | if (chan[i] == chan_number) { |
| 667 | found = true; |
| 668 | break; |
| 669 | } |
| 670 | } |
| 671 | |
| 672 | if (found == false) { |
| 673 | hdd_err("Channel not in driver's valid channel list"); |
| 674 | return -EOPNOTSUPP; |
| 675 | } |
| 676 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 677 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 678 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 679 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 680 | return -EINVAL; |
| 681 | } |
| 682 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 683 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 684 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 685 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 686 | return -EINVAL; |
| 687 | } |
| 688 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 689 | (chan_bw != CH_WIDTH_MAX)) { |
| 690 | hdd_err("Only BW20 possible on channel 14"); |
| 691 | return -EINVAL; |
| 692 | } |
| 693 | } |
| 694 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 695 | return 0; |
| 696 | } |
| 697 | |
Will Huang | 79af29f | 2019-04-11 15:46:26 +0800 | [diff] [blame] | 698 | uint8_t hdd_get_adapter_home_channel(struct hdd_adapter *adapter) |
| 699 | { |
| 700 | uint8_t home_channel = 0; |
| 701 | |
| 702 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 703 | adapter->device_mode == QDF_P2P_GO_MODE) && |
| 704 | test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
| 705 | home_channel = adapter->session.ap.operating_channel; |
| 706 | } else if ((adapter->device_mode == QDF_STA_MODE || |
| 707 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
| 708 | adapter->session.station.conn_info.conn_state == |
| 709 | eConnectionState_Associated) { |
| 710 | home_channel = |
| 711 | adapter->session.station.conn_info.channel; |
| 712 | } |
| 713 | |
| 714 | return home_channel; |
| 715 | } |
| 716 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 717 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 718 | static inline struct net_device *hdd_net_dev_from_notifier(void *context) |
| 719 | { |
| 720 | struct netdev_notifier_info *info = context; |
| 721 | |
| 722 | return info->dev; |
| 723 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 724 | #else |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 725 | static inline struct net_device *hdd_net_dev_from_notifier(void *context) |
| 726 | { |
| 727 | return context; |
| 728 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 729 | #endif |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 730 | |
| 731 | static int __hdd_netdev_notifier_call(struct net_device *net_dev, |
| 732 | unsigned long state) |
| 733 | { |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 734 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 735 | struct hdd_context *hdd_ctx; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 736 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 737 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 738 | hdd_enter_dev(net_dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 739 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 740 | if (!net_dev->ieee80211_ptr) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 741 | hdd_debug("ieee80211_ptr is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 742 | return NOTIFY_DONE; |
| 743 | } |
| 744 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 745 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 746 | if (!hdd_ctx) { |
| 747 | hdd_err("HDD Context is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 748 | return NOTIFY_DONE; |
| 749 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 750 | |
| 751 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 752 | hdd_debug("%s: Driver module is closed", __func__); |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 753 | return NOTIFY_DONE; |
| 754 | } |
| 755 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 756 | /* Make sure that this callback corresponds to our device. */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 757 | adapter = hdd_get_adapter_by_iface_name(hdd_ctx, net_dev->name); |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 758 | if (!adapter) { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 759 | hdd_debug("failed to look up adapter for '%s'", net_dev->name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 760 | return NOTIFY_DONE; |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 761 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 762 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 763 | if (adapter != WLAN_HDD_GET_PRIV_PTR(net_dev)) { |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 764 | hdd_err("HDD adapter mismatch!"); |
| 765 | return NOTIFY_DONE; |
| 766 | } |
| 767 | |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 768 | if (cds_is_driver_recovering()) { |
| 769 | hdd_debug("Driver is recovering"); |
| 770 | return NOTIFY_DONE; |
| 771 | } |
| 772 | |
| 773 | if (cds_is_driver_in_bad_state()) { |
| 774 | hdd_debug("Driver is in failed recovery state"); |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 775 | return NOTIFY_DONE; |
| 776 | } |
| 777 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 778 | hdd_debug("%s New Net Device State = %lu", net_dev->name, state); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 779 | |
| 780 | switch (state) { |
| 781 | case NETDEV_REGISTER: |
| 782 | break; |
| 783 | |
| 784 | case NETDEV_UNREGISTER: |
| 785 | break; |
| 786 | |
| 787 | case NETDEV_UP: |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 788 | sme_ch_avoid_update_req(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 789 | break; |
| 790 | |
| 791 | case NETDEV_DOWN: |
| 792 | break; |
| 793 | |
| 794 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 795 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 796 | complete(&adapter->linkup_event_var); |
| 797 | break; |
| 798 | |
| 799 | case NETDEV_GOING_DOWN: |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 800 | vdev = hdd_objmgr_get_vdev(adapter); |
| 801 | if (!vdev) |
| 802 | break; |
| 803 | if (ucfg_scan_get_vdev_status(vdev) != |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 804 | SCAN_NOT_IN_PROGRESS) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 805 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 806 | adapter->vdev_id, INVALID_SCAN_ID, |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 807 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 808 | } |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 809 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 810 | cds_flush_work(&adapter->scan_block_work); |
| 811 | /* Need to clean up blocked scan request */ |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 812 | wlan_hdd_cfg80211_scan_block(adapter); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 813 | hdd_debug("Scan is not Pending from user"); |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 814 | /* |
| 815 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 816 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 817 | * flag after which driver does not send the cfg80211_scan_done. |
| 818 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 819 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 820 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, net_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 821 | break; |
| 822 | |
| 823 | default: |
| 824 | break; |
| 825 | } |
| 826 | |
| 827 | return NOTIFY_DONE; |
| 828 | } |
| 829 | |
| 830 | /** |
| 831 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 832 | * @nb: pointer to notifier block |
| 833 | * @state: state |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 834 | * @context: notifier callback context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 835 | * |
| 836 | * Return: 0 on success, error number otherwise. |
| 837 | */ |
| 838 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 839 | unsigned long state, |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 840 | void *context) |
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 | struct net_device *net_dev = hdd_net_dev_from_notifier(context); |
| 843 | struct osif_vdev_sync *vdev_sync; |
| 844 | int 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 = osif_vdev_sync_op_start(net_dev, &vdev_sync); |
| 847 | if (errno) |
| 848 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 849 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 850 | errno = __hdd_netdev_notifier_call(net_dev, state); |
| 851 | |
| 852 | osif_vdev_sync_op_stop(vdev_sync); |
| 853 | |
| 854 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | struct notifier_block hdd_netdev_notifier = { |
| 858 | .notifier_call = hdd_netdev_notifier_call, |
| 859 | }; |
| 860 | |
| 861 | /* variable to hold the insmod parameters */ |
| 862 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 863 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 864 | static int con_mode_ftm; |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 865 | int con_mode_epping; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 866 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 867 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 868 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 869 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 870 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 871 | /** |
| 872 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 873 | * @ch_width: NL channel width |
| 874 | * |
| 875 | * Converts the NL channel width to the driver's internal representation |
| 876 | * |
| 877 | * Return: Converted channel width. In case of non matching NL channel width, |
| 878 | * CH_WIDTH_MAX will be returned. |
| 879 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 880 | 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] | 881 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 882 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 883 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 884 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 885 | switch (ch_width) { |
| 886 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 887 | case NL80211_CHAN_WIDTH_20: |
| 888 | return CH_WIDTH_20MHZ; |
| 889 | case NL80211_CHAN_WIDTH_40: |
| 890 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 891 | case NL80211_CHAN_WIDTH_80: |
| 892 | return CH_WIDTH_80MHZ; |
| 893 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 894 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 895 | return CH_WIDTH_80P80MHZ; |
| 896 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 897 | return CH_WIDTH_160MHZ; |
| 898 | else |
| 899 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 900 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 901 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 902 | return CH_WIDTH_160MHZ; |
| 903 | else |
| 904 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 905 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 906 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 907 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 908 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 909 | default: |
| 910 | hdd_err("Invalid channel width %d, setting to default", |
| 911 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 912 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 913 | } |
| 914 | } |
| 915 | |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 916 | QDF_STATUS hdd_nl_to_qdf_iface_type(enum nl80211_iftype nl_type, |
| 917 | enum QDF_OPMODE *out_qdf_type) |
| 918 | { |
| 919 | switch (nl_type) { |
| 920 | case NL80211_IFTYPE_ADHOC: |
| 921 | *out_qdf_type = QDF_IBSS_MODE; |
| 922 | break; |
| 923 | case NL80211_IFTYPE_AP: |
| 924 | *out_qdf_type = QDF_SAP_MODE; |
| 925 | break; |
| 926 | case NL80211_IFTYPE_MONITOR: |
| 927 | *out_qdf_type = QDF_MONITOR_MODE; |
| 928 | break; |
| 929 | case NL80211_IFTYPE_OCB: |
| 930 | *out_qdf_type = QDF_OCB_MODE; |
| 931 | break; |
| 932 | case NL80211_IFTYPE_P2P_CLIENT: |
| 933 | *out_qdf_type = QDF_P2P_CLIENT_MODE; |
| 934 | break; |
| 935 | case NL80211_IFTYPE_P2P_DEVICE: |
| 936 | *out_qdf_type = QDF_P2P_DEVICE_MODE; |
| 937 | break; |
| 938 | case NL80211_IFTYPE_P2P_GO: |
| 939 | *out_qdf_type = QDF_P2P_GO_MODE; |
| 940 | break; |
| 941 | case NL80211_IFTYPE_STATION: |
| 942 | *out_qdf_type = QDF_STA_MODE; |
| 943 | break; |
| 944 | case NL80211_IFTYPE_WDS: |
| 945 | *out_qdf_type = QDF_WDS_MODE; |
| 946 | break; |
| 947 | default: |
| 948 | hdd_err("Invalid nl80211 interface type %d", nl_type); |
| 949 | return QDF_STATUS_E_INVAL; |
| 950 | } |
| 951 | |
| 952 | return QDF_STATUS_SUCCESS; |
| 953 | } |
| 954 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 955 | uint8_t wlan_hdd_find_opclass(mac_handle_t mac_handle, uint8_t channel, |
| 956 | uint8_t bw_offset) |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 957 | { |
| 958 | uint8_t opclass = 0; |
| 959 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 960 | sme_get_opclass(mac_handle, channel, bw_offset, &opclass); |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 961 | return opclass; |
| 962 | } |
| 963 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 964 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 965 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 966 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 967 | * @bitmask: Bitmask of log levels to be enabled |
| 968 | * |
| 969 | * Called immediately after the cfg.ini is read in order to configure |
| 970 | * the desired trace levels. |
| 971 | * |
| 972 | * Return: None |
| 973 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 974 | 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] | 975 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 976 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 977 | int qdf_print_idx = -1; |
| 978 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 979 | /* |
| 980 | * if the bitmask is the default value, then a bitmask was not |
| 981 | * specified in cfg.ini, so leave the logging level alone (it |
| 982 | * will remain at the "compiled in" default value) |
| 983 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 984 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 985 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 986 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 987 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 988 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 989 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 990 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 991 | QDF_TRACE_LEVEL_NONE, 0); |
| 992 | |
| 993 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 994 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 995 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 996 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 997 | while (0 != bitmask) { |
| 998 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 999 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1000 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1001 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1002 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1003 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1004 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1005 | level++; |
| 1006 | bitmask >>= 1; |
| 1007 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1008 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1009 | } |
| 1010 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1011 | 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] | 1012 | { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1013 | if (!hdd_ctx) { |
| 1014 | hdd_err("HDD context is null (via %s)", func); |
| 1015 | return -ENODEV; |
| 1016 | } |
| 1017 | |
| 1018 | if (!hdd_ctx->config) { |
| 1019 | hdd_err("HDD config is null (via %s)", func); |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 1020 | return -ENODEV; |
| 1021 | } |
| 1022 | |
| 1023 | if (cds_is_driver_recovering()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1024 | hdd_debug("Recovery in progress (via %s); state:0x%x", |
| 1025 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1026 | return -EAGAIN; |
| 1027 | } |
| 1028 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 1029 | if (cds_is_load_or_unload_in_progress()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1030 | hdd_debug("Load/unload in progress (via %s); state:0x%x", |
| 1031 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1032 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 1033 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1034 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1035 | if (cds_is_driver_in_bad_state()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1036 | hdd_debug("Driver in bad state (via %s); state:0x%x", |
| 1037 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 1038 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1039 | } |
| 1040 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 1041 | if (cds_is_fw_down()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1042 | hdd_debug("FW is down (via %s); state:0x%x", |
| 1043 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 1044 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 1045 | } |
| 1046 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1047 | return 0; |
| 1048 | } |
| 1049 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1050 | int __hdd_validate_adapter(struct hdd_adapter *adapter, const char *func) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1051 | { |
| 1052 | if (!adapter) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1053 | hdd_err("adapter is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1054 | return -EINVAL; |
| 1055 | } |
| 1056 | |
| 1057 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1058 | hdd_err("bad adapter magic (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1059 | return -EINVAL; |
| 1060 | } |
| 1061 | |
| 1062 | if (!adapter->dev) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1063 | hdd_err("adapter net_device is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1064 | return -EINVAL; |
| 1065 | } |
| 1066 | |
| 1067 | if (!(adapter->dev->flags & IFF_UP)) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1068 | hdd_debug_rl("adapter '%s' is not up (via %s)", |
| 1069 | adapter->dev->name, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1070 | return -EAGAIN; |
| 1071 | } |
| 1072 | |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 1073 | return __wlan_hdd_validate_vdev_id(adapter->vdev_id, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1074 | } |
| 1075 | |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 1076 | 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] | 1077 | { |
Srinivas Girigowda | d8697d4 | 2019-03-08 15:34:39 -0800 | [diff] [blame] | 1078 | if (vdev_id == WLAN_UMAC_VDEV_ID_MAX) { |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 1079 | hdd_debug_rl("adapter is not up (via %s)", func); |
| 1080 | return -EINVAL; |
| 1081 | } |
| 1082 | |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 1083 | if (vdev_id >= WLAN_MAX_VDEVS) { |
| 1084 | hdd_err("bad vdev Id:%u (via %s)", vdev_id, func); |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 1085 | return -EINVAL; |
| 1086 | } |
| 1087 | |
| 1088 | return 0; |
| 1089 | } |
| 1090 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 1091 | QDF_STATUS __wlan_hdd_validate_mac_address(struct qdf_mac_addr *mac_addr, |
| 1092 | const char *func) |
| 1093 | { |
| 1094 | if (!mac_addr) { |
| 1095 | hdd_err("Received NULL mac address (via %s)", func); |
| 1096 | return QDF_STATUS_E_INVAL; |
| 1097 | } |
| 1098 | |
| 1099 | if (qdf_is_macaddr_zero(mac_addr)) { |
| 1100 | hdd_err("MAC is all zero (via %s)", func); |
| 1101 | return QDF_STATUS_E_INVAL; |
| 1102 | } |
| 1103 | |
| 1104 | if (qdf_is_macaddr_broadcast(mac_addr)) { |
| 1105 | hdd_err("MAC is Broadcast (via %s)", func); |
| 1106 | return QDF_STATUS_E_INVAL; |
| 1107 | } |
| 1108 | |
| 1109 | if (QDF_NET_IS_MAC_MULTICAST(mac_addr->bytes)) { |
| 1110 | hdd_err("MAC is Multicast (via %s)", func); |
| 1111 | return QDF_STATUS_E_INVAL; |
| 1112 | } |
| 1113 | |
| 1114 | return QDF_STATUS_SUCCESS; |
| 1115 | } |
| 1116 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1117 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1118 | * wlan_hdd_validate_modules_state() - Check modules status |
| 1119 | * @hdd_ctx: HDD context pointer |
| 1120 | * |
| 1121 | * Check's the driver module's state and returns true if the |
| 1122 | * modules are enabled returns false if modules are closed. |
| 1123 | * |
| 1124 | * Return: True if modules are enabled or false. |
| 1125 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1126 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1127 | { |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1128 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 1129 | hdd_info("Modules not enabled, Present status: %d", |
| 1130 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1131 | return false; |
| 1132 | } |
Dustin Brown | f688ea1 | 2019-03-19 17:02:32 -0700 | [diff] [blame] | 1133 | |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1134 | return true; |
| 1135 | } |
| 1136 | |
| 1137 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1138 | * 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] | 1139 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1140 | * |
| 1141 | * This function sets the IBSS power save config parameters to WMA |
| 1142 | * which will send it to firmware if FW supports IBSS power save |
| 1143 | * before vdev start. |
| 1144 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1145 | * 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] | 1146 | * on failure. |
| 1147 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1148 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1149 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1150 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1151 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1152 | if (!hdd_ctx) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1153 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1154 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1155 | } |
| 1156 | |
Manikandan Mohan | 2bd0977 | 2018-11-28 18:27:32 -0800 | [diff] [blame] | 1157 | return ucfg_mlme_ibss_power_save_setup(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1158 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1159 | } |
| 1160 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1161 | #ifdef FEATURE_RUNTIME_PM |
| 1162 | /** |
| 1163 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1164 | * @hdd_ctx: HDD context |
| 1165 | * |
| 1166 | * Return: None |
| 1167 | */ |
| 1168 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1169 | { |
| 1170 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1171 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1172 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1173 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1174 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1175 | wlan_scan_runtime_pm_init(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1176 | } |
| 1177 | |
| 1178 | /** |
| 1179 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1180 | * @hdd_ctx: HDD Context |
| 1181 | * |
| 1182 | * Return: None |
| 1183 | */ |
| 1184 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1185 | { |
| 1186 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1187 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1188 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1189 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1190 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1191 | wlan_scan_runtime_pm_deinit(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1192 | } |
| 1193 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1194 | #else /* FEATURE_RUNTIME_PM */ |
| 1195 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1196 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1197 | #endif /* FEATURE_RUNTIME_PM */ |
| 1198 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1199 | #define INTF_MACADDR_MASK 0x7 |
| 1200 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1201 | void hdd_update_macaddr(struct hdd_context *hdd_ctx, |
| 1202 | struct qdf_mac_addr hw_macaddr, bool generate_mac_auto) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1203 | { |
| 1204 | int8_t i; |
| 1205 | uint8_t macaddr_b3, tmp_br3; |
| 1206 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1207 | /* |
| 1208 | * If "generate_mac_auto" is true, it indicates that all the |
| 1209 | * addresses are derived addresses, else the first addresses |
| 1210 | * is not derived address (It is provided by fw). |
| 1211 | */ |
| 1212 | if (!generate_mac_auto) { |
| 1213 | qdf_mem_copy(hdd_ctx->provisioned_mac_addr[0].bytes, |
| 1214 | hw_macaddr.bytes, QDF_MAC_ADDR_SIZE); |
| 1215 | hdd_ctx->num_provisioned_addr++; |
| 1216 | hdd_info("hdd_ctx->provisioned_mac_addr[0]: " |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 1217 | QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1218 | QDF_MAC_ADDR_ARRAY(hdd_ctx-> |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1219 | provisioned_mac_addr[0].bytes)); |
| 1220 | } else { |
| 1221 | qdf_mem_copy(hdd_ctx->derived_mac_addr[0].bytes, |
| 1222 | hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1223 | QDF_MAC_ADDR_SIZE); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1224 | hdd_ctx->num_derived_addr++; |
| 1225 | hdd_info("hdd_ctx->derived_mac_addr[0]: " |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 1226 | QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1227 | QDF_MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[0].bytes)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1228 | } |
| 1229 | for (i = hdd_ctx->num_derived_addr; i < (QDF_MAX_CONCURRENCY_PERSONA - |
| 1230 | hdd_ctx->num_provisioned_addr); |
| 1231 | i++) { |
| 1232 | qdf_mem_copy(hdd_ctx->derived_mac_addr[i].bytes, |
| 1233 | hw_macaddr.bytes, |
| 1234 | QDF_MAC_ADDR_SIZE); |
| 1235 | macaddr_b3 = hdd_ctx->derived_mac_addr[i].bytes[3]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1236 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1237 | INTF_MACADDR_MASK; |
| 1238 | macaddr_b3 += tmp_br3; |
| 1239 | |
| 1240 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1241 | * mac address range before collision |
| 1242 | */ |
| 1243 | macaddr_b3 ^= (1 << 7); |
| 1244 | |
| 1245 | /* Set locally administered bit */ |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1246 | hdd_ctx->derived_mac_addr[i].bytes[0] |= 0x02; |
| 1247 | hdd_ctx->derived_mac_addr[i].bytes[3] = macaddr_b3; |
| 1248 | hdd_info("hdd_ctx->derived_mac_addr[%d]: " |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 1249 | QDF_MAC_ADDR_STR, i, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1250 | QDF_MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1251 | hdd_ctx->num_derived_addr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1252 | } |
| 1253 | } |
| 1254 | |
Jeff Johnson | 2de5879 | 2019-02-08 07:49:17 -0800 | [diff] [blame] | 1255 | #ifdef FEATURE_WLAN_TDLS |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1256 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1257 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1258 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1259 | struct tdls_start_params tdls_cfg; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1260 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1261 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 1262 | |
| 1263 | /* Populate the nss chain params from ini for this vdev type */ |
| 1264 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 1265 | QDF_TDLS_MODE, |
| 1266 | hdd_ctx->num_rf_chains); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1267 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1268 | cfg_tdls_set_vdev_nss_2g(hdd_ctx->psoc, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1269 | vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1270 | cfg_tdls_set_vdev_nss_5g(hdd_ctx->psoc, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1271 | vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]); |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1272 | hdd_init_tdls_config(&tdls_cfg); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1273 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1274 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1275 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1276 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1277 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1278 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1279 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1280 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1281 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1282 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1283 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1284 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
Arun Kumar Khandavalli | 43fdd25 | 2019-04-24 18:34:18 +0530 | [diff] [blame] | 1285 | tdls_cfg.tdls_osif_init_cb = wlan_cfg80211_tdls_osif_priv_init; |
| 1286 | tdls_cfg.tdls_osif_deinit_cb = wlan_cfg80211_tdls_osif_priv_deinit; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1287 | |
| 1288 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1289 | if (status != QDF_STATUS_SUCCESS) { |
| 1290 | hdd_err("failed pmo psoc configuration"); |
| 1291 | return -EINVAL; |
| 1292 | } |
| 1293 | |
| 1294 | hdd_ctx->tdls_umac_comp_active = true; |
| 1295 | /* enable napier specific tdls data path */ |
| 1296 | hdd_ctx->tdls_nap_active = true; |
| 1297 | |
| 1298 | return 0; |
| 1299 | } |
Jeff Johnson | 74c6bb2 | 2019-02-15 10:15:07 -0800 | [diff] [blame] | 1300 | #else |
| 1301 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1302 | { |
| 1303 | return 0; |
| 1304 | } |
| 1305 | #endif |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1306 | |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1307 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1308 | static void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1309 | struct wma_tgt_services *cfg) |
| 1310 | { |
| 1311 | bool roam_offload_enable; |
| 1312 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1313 | ucfg_mlme_get_roaming_offload(hdd_ctx->psoc, &roam_offload_enable); |
| 1314 | ucfg_mlme_set_roaming_offload(hdd_ctx->psoc, |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1315 | roam_offload_enable & |
| 1316 | cfg->en_roam_offload); |
| 1317 | } |
| 1318 | #else |
| 1319 | static inline void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1320 | struct wma_tgt_services *cfg) |
| 1321 | { |
| 1322 | } |
| 1323 | #endif |
| 1324 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1325 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1326 | struct wma_tgt_services *cfg) |
| 1327 | { |
| 1328 | struct hdd_config *config = hdd_ctx->config; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1329 | bool arp_offload_enable; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1330 | bool mawc_enabled; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1331 | #ifdef FEATURE_WLAN_TDLS |
| 1332 | bool tdls_support; |
| 1333 | bool tdls_off_channel; |
| 1334 | bool tdls_buffer_sta; |
| 1335 | uint32_t tdls_uapsd_mask; |
| 1336 | #endif |
Will Huang | b9cb124 | 2019-04-02 14:52:17 +0800 | [diff] [blame] | 1337 | bool get_peer_info_enable; |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1338 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1339 | /* Set up UAPSD */ |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 1340 | ucfg_mlme_set_sap_uapsd_flag(hdd_ctx->psoc, cfg->uapsd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1341 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1342 | /* 11AX mode support */ |
| 1343 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1344 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1345 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1346 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1347 | /* 11AC mode support */ |
| 1348 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1349 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1350 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1351 | |
| 1352 | /* ARP offload: override user setting if invalid */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1353 | arp_offload_enable = |
| 1354 | ucfg_pmo_is_arp_offload_enabled(hdd_ctx->psoc); |
| 1355 | ucfg_pmo_set_arp_offload_enabled(hdd_ctx->psoc, |
| 1356 | arp_offload_enable & cfg->arp_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1357 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1358 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1359 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1360 | if (cfg->pno_offload) |
Pragaspathi Thilagaraj | 24789d3 | 2018-12-10 22:28:03 +0530 | [diff] [blame] | 1361 | ucfg_scan_set_pno_offload(hdd_ctx->psoc, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1362 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1363 | #ifdef FEATURE_WLAN_TDLS |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1364 | cfg_tdls_get_support_enable(hdd_ctx->psoc, &tdls_support); |
| 1365 | cfg_tdls_set_support_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1366 | tdls_support & cfg->en_tdls); |
| 1367 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1368 | cfg_tdls_get_off_channel_enable(hdd_ctx->psoc, &tdls_off_channel); |
| 1369 | cfg_tdls_set_off_channel_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1370 | tdls_off_channel && |
| 1371 | cfg->en_tdls_offchan); |
| 1372 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1373 | cfg_tdls_get_buffer_sta_enable(hdd_ctx->psoc, &tdls_buffer_sta); |
| 1374 | cfg_tdls_set_buffer_sta_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1375 | tdls_buffer_sta && |
| 1376 | cfg->en_tdls_uapsd_buf_sta); |
| 1377 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1378 | cfg_tdls_get_uapsd_mask(hdd_ctx->psoc, &tdls_uapsd_mask); |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1379 | if (tdls_uapsd_mask && cfg->en_tdls_uapsd_sleep_sta) |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1380 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, true); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1381 | else |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1382 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1383 | #endif |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1384 | hdd_update_roam_offload(hdd_ctx, cfg); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1385 | |
Will Huang | b9cb124 | 2019-04-02 14:52:17 +0800 | [diff] [blame] | 1386 | if (ucfg_mlme_get_sap_get_peer_info( |
| 1387 | hdd_ctx->psoc, &get_peer_info_enable) == QDF_STATUS_SUCCESS) { |
| 1388 | get_peer_info_enable &= cfg->get_peer_info_enabled; |
| 1389 | ucfg_mlme_set_sap_get_peer_info(hdd_ctx->psoc, |
| 1390 | get_peer_info_enable); |
| 1391 | } |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1392 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1393 | ucfg_mlme_is_mawc_enabled(hdd_ctx->psoc, &mawc_enabled); |
| 1394 | ucfg_mlme_set_mawc_enabled(hdd_ctx->psoc, |
| 1395 | mawc_enabled & cfg->is_fw_mawc_capable); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1396 | hdd_update_tdls_config(hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1397 | sme_update_tgt_services(hdd_ctx->mac_handle, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1398 | } |
| 1399 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1400 | /** |
| 1401 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1402 | * @hdd_ctx: HDD context |
| 1403 | * |
| 1404 | * Sets the Nss per vdev type based on INI |
| 1405 | * |
| 1406 | * Return: None |
| 1407 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1408 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1409 | { |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1410 | uint8_t max_supp_nss = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1411 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1412 | QDF_STATUS status; |
| 1413 | bool bval; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1414 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1415 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1416 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1417 | hdd_err("unable to get vht_enable2x2"); |
| 1418 | |
| 1419 | if (bval && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1420 | max_supp_nss = 2; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1421 | |
| 1422 | hdd_debug("max nss %d", max_supp_nss); |
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 | mac_handle = hdd_ctx->mac_handle; |
| 1425 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1426 | NSS_CHAINS_BAND_2GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1427 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1428 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1429 | NSS_CHAINS_BAND_5GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1430 | } |
| 1431 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1432 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1433 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1434 | * @hdd_ctx: HDD context |
| 1435 | * |
| 1436 | * Updates wiphy vhtcap fields |
| 1437 | * |
| 1438 | * Return: None |
| 1439 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1440 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1441 | { |
| 1442 | struct ieee80211_supported_band *band_5g = |
| 1443 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1444 | QDF_STATUS status; |
| 1445 | uint8_t value = 0, value1 = 0; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1446 | |
| 1447 | if (!band_5g) { |
| 1448 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1449 | return; |
| 1450 | } |
| 1451 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1452 | status = ucfg_mlme_cfg_get_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 1453 | &value); |
| 1454 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1455 | hdd_err("unable to get tx_bfee_ant_supp"); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1456 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1457 | band_5g->vht_cap.cap |= |
| 1458 | (value << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1459 | |
| 1460 | value1 = NUM_OF_SOUNDING_DIMENSIONS; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1461 | band_5g->vht_cap.cap |= |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1462 | (value1 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1463 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 1464 | hdd_debug("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1465 | band_5g->vht_cap.cap, value, value1); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1466 | } |
| 1467 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1468 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1469 | struct wma_tgt_ht_cap *cfg) |
| 1470 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1471 | QDF_STATUS status; |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1472 | qdf_size_t value_len; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1473 | uint32_t value; |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1474 | uint8_t mpdu_density; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1475 | struct mlme_ht_capabilities_info ht_cap_info; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1476 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1477 | bool b_enable1x1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1478 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1479 | /* get the MPDU density */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1480 | status = ucfg_mlme_get_ht_mpdu_density(hdd_ctx->psoc, &mpdu_density); |
| 1481 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1482 | hdd_err("could not get HT MPDU Density"); |
| 1483 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1484 | } |
| 1485 | |
| 1486 | /* |
| 1487 | * MPDU density: |
| 1488 | * override user's setting if value is larger |
| 1489 | * than the one supported by target |
| 1490 | */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1491 | if (mpdu_density > cfg->mpdu_density) { |
| 1492 | status = ucfg_mlme_set_ht_mpdu_density(hdd_ctx->psoc, |
| 1493 | cfg->mpdu_density); |
| 1494 | if (QDF_IS_STATUS_ERROR(status)) |
| 1495 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1496 | } |
| 1497 | |
| 1498 | /* get the HT capability info */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1499 | 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] | 1500 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1501 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1502 | return; |
| 1503 | } |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1504 | |
| 1505 | /* check and update RX STBC */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1506 | if (ht_cap_info.rx_stbc && !cfg->ht_rx_stbc) |
| 1507 | ht_cap_info.rx_stbc = cfg->ht_rx_stbc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1508 | |
| 1509 | /* Set the LDPC capability */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1510 | ht_cap_info.adv_coding_cap = cfg->ht_rx_ldpc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1511 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1512 | if (ht_cap_info.short_gi_20_mhz && !cfg->ht_sgi_20) |
| 1513 | ht_cap_info.short_gi_20_mhz = cfg->ht_sgi_20; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1514 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1515 | if (ht_cap_info.short_gi_40_mhz && !cfg->ht_sgi_40) |
| 1516 | ht_cap_info.short_gi_40_mhz = cfg->ht_sgi_40; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1517 | |
| 1518 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1519 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1520 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1521 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &b_enable1x1); |
| 1522 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1523 | hdd_err("unable to get vht_enable2x2"); |
| 1524 | |
| 1525 | b_enable1x1 = b_enable1x1 && (cfg->num_rf_chains == 2); |
| 1526 | |
| 1527 | status = ucfg_mlme_set_vht_enable2x2(hdd_ctx->psoc, b_enable1x1); |
| 1528 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1529 | hdd_err("unable to set vht_enable2x2"); |
| 1530 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1531 | if (!b_enable1x1) { |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1532 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1533 | |
| 1534 | /* 1x1 */ |
| 1535 | /* Update Rx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1536 | status = ucfg_mlme_cfg_set_vht_rx_supp_data_rate( |
| 1537 | hdd_ctx->psoc, |
| 1538 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1539 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1540 | hdd_err("Failed to set rx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1541 | /* Update Tx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1542 | status = ucfg_mlme_cfg_set_vht_tx_supp_data_rate( |
| 1543 | hdd_ctx->psoc, |
| 1544 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1545 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1546 | hdd_err("Failed to set tx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1547 | } |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1548 | if (!(cfg->ht_tx_stbc && b_enable1x1)) |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1549 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1550 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1551 | 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] | 1552 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1553 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1554 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1555 | value_len = SIZE_OF_SUPPORTED_MCS_SET; |
| 1556 | if (ucfg_mlme_get_supported_mcs_set( |
| 1557 | hdd_ctx->psoc, mcs_set, |
| 1558 | &value_len) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1559 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1560 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1561 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1562 | |
| 1563 | if (b_enable1x1) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1564 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1565 | mcs_set[value] = |
| 1566 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1567 | |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1568 | status = ucfg_mlme_set_supported_mcs_set( |
| 1569 | hdd_ctx->psoc, |
| 1570 | mcs_set, |
| 1571 | (qdf_size_t)SIZE_OF_SUPPORTED_MCS_SET); |
| 1572 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1573 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1574 | } |
| 1575 | } |
| 1576 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1577 | } |
| 1578 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1579 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1580 | struct wma_tgt_vht_cap *cfg) |
| 1581 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1582 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1583 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1584 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1585 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1586 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1587 | struct wma_caps_per_phy caps_per_phy; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1588 | uint8_t val = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1589 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1590 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1591 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1592 | return; |
| 1593 | } |
| 1594 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1595 | status = ucfg_mlme_update_vht_cap(hdd_ctx->psoc, cfg); |
| 1596 | if (QDF_IS_STATUS_ERROR(status)) |
| 1597 | hdd_err("could not update vht capabilities"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1598 | |
| 1599 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1600 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1601 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1602 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1603 | else |
| 1604 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1605 | |
| 1606 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1607 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1608 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1609 | VHT_CAP_160_AND_80P80_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1610 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1611 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1612 | band_5g->vht_cap.cap |= |
| 1613 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1614 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1615 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1616 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1617 | VHT_CAP_160_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1618 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1619 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1620 | band_5g->vht_cap.cap |= |
| 1621 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1622 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1623 | } |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1624 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1625 | status = |
| 1626 | ucfg_mlme_cfg_get_vht_chan_width(hdd_ctx->psoc, &val); |
| 1627 | if (QDF_IS_STATUS_ERROR(status)) |
| 1628 | hdd_err("could not get channel_width"); |
| 1629 | |
| 1630 | val = QDF_MIN(val, ch_width); |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1631 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, val); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1632 | if (QDF_IS_STATUS_ERROR(status)) |
| 1633 | hdd_err("could not set the channel width"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1634 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1635 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1636 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1637 | hdd_debug("VHT RxLDPC capability is set"); |
| 1638 | } else { |
| 1639 | /* |
| 1640 | * Get the RX LDPC capability for the NON DBS |
| 1641 | * hardware mode for 5G band |
| 1642 | */ |
| 1643 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1644 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1645 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1646 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1647 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1648 | hdd_debug("VHT RX LDPC capability is set"); |
| 1649 | } |
| 1650 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1651 | |
| 1652 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1653 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1654 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1655 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1656 | |
| 1657 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1658 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1659 | |
| 1660 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1661 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1662 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1663 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1664 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1665 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1666 | |
| 1667 | band_5g->vht_cap.cap |= |
| 1668 | (cfg->vht_max_ampdu_len_exp << |
| 1669 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1670 | |
| 1671 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1672 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1673 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1674 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1675 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1676 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1677 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1678 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1679 | |
| 1680 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1681 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1682 | |
| 1683 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1684 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1685 | /** |
| 1686 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1687 | * @hdd_ctx: Pointer to the HDD context |
| 1688 | * |
| 1689 | * Auto-generate mac address using device serial number. |
| 1690 | * Keep the first 3 bytes of OUI as before and replace |
| 1691 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1692 | * |
| 1693 | * Return: 0 for success |
| 1694 | * Non zero failure code for errors |
| 1695 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1696 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1697 | { |
| 1698 | unsigned int serialno = 0; |
| 1699 | struct qdf_mac_addr mac_addr = { |
| 1700 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1701 | }; |
| 1702 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1703 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1704 | if (serialno == 0) |
| 1705 | return -EINVAL; |
| 1706 | |
| 1707 | serialno &= 0x00ffffff; |
| 1708 | |
| 1709 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1710 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1711 | mac_addr.bytes[5] = serialno & 0xff; |
| 1712 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1713 | hdd_update_macaddr(hdd_ctx, mac_addr, true); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1714 | return 0; |
| 1715 | } |
| 1716 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1717 | static void hdd_sar_target_config(struct hdd_context *hdd_ctx, |
| 1718 | struct wma_tgt_cfg *cfg) |
| 1719 | { |
| 1720 | hdd_ctx->sar_version = cfg->sar_version; |
| 1721 | } |
| 1722 | |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1723 | static void hdd_update_vhtcap_2g(struct hdd_context *hdd_ctx) |
| 1724 | { |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1725 | uint32_t chip_mode = 0; |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1726 | QDF_STATUS status; |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1727 | bool b2g_vht_cfg = false; |
| 1728 | bool b2g_vht_target = false; |
| 1729 | struct wma_caps_per_phy caps_per_phy; |
| 1730 | struct wmi_unified *wmi_handle; |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1731 | |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1732 | wmi_handle = get_wmi_unified_hdl_from_psoc(hdd_ctx->psoc); |
| 1733 | if (!wmi_handle) { |
| 1734 | hdd_err("wmi handle is NULL"); |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1735 | return; |
| 1736 | } |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1737 | |
| 1738 | 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] | 1739 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1740 | hdd_err("Failed to get 2g vht mode"); |
| 1741 | return; |
| 1742 | } |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1743 | if (wmi_service_enabled(wmi_handle, wmi_service_ext_msg)) { |
| 1744 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1745 | HW_MODE_DBS_NONE, |
| 1746 | CDS_BAND_ALL); |
| 1747 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1748 | hdd_err("Failed to get phy caps"); |
| 1749 | return; |
| 1750 | } |
| 1751 | if (caps_per_phy.vht_2g) |
| 1752 | b2g_vht_target = true; |
| 1753 | } else { |
| 1754 | status = wlan_reg_get_chip_mode(hdd_ctx->pdev, &chip_mode); |
| 1755 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1756 | hdd_err("Failed to get chip mode"); |
| 1757 | return; |
| 1758 | } |
| 1759 | b2g_vht_target = |
| 1760 | (chip_mode & WMI_HOST_REGDMN_MODE_11AC_VHT20_2G) ? |
| 1761 | true : false; |
| 1762 | } |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1763 | |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1764 | b2g_vht_cfg = b2g_vht_cfg && b2g_vht_target; |
| 1765 | hdd_debug("vht 2g target: %d, cfg: %d", b2g_vht_target, b2g_vht_cfg); |
| 1766 | 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] | 1767 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1768 | hdd_err("Failed to update 2g vht mode"); |
| 1769 | return; |
| 1770 | } |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1771 | } |
| 1772 | |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1773 | 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] | 1774 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1775 | int ret; |
Jeff Johnson | ea70b94 | 2018-07-02 09:42:31 -0700 | [diff] [blame] | 1776 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1777 | uint8_t temp_band_cap, band_capability; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1778 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1779 | uint8_t antenna_mode; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1780 | uint8_t sub_20_chan_width; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1781 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1782 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1783 | bool bval = false; |
| 1784 | uint8_t value = 0; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1785 | uint32_t fine_time_meas_cap = 0; |
gaurank kathpalia | fa7ad0a | 2019-03-12 19:17:56 +0530 | [diff] [blame] | 1786 | enum nss_chains_band_info band; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1787 | |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1788 | if (!hdd_ctx) { |
| 1789 | hdd_err("HDD context is NULL"); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1790 | return -EINVAL; |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1791 | } |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1792 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1793 | if (ret) { |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1794 | QDF_DEBUG_PANIC("Failed to create pdev; errno:%d", ret); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1795 | return -EINVAL; |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1796 | } |
| 1797 | |
| 1798 | hdd_debug("New pdev has been created with pdev_id = %u", |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1799 | hdd_ctx->pdev->pdev_objmgr.wlan_pdev_id); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1800 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1801 | status = dispatcher_pdev_open(hdd_ctx->pdev); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1802 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1803 | QDF_DEBUG_PANIC("dispatcher pdev open failed; status:%d", |
| 1804 | status); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1805 | ret = qdf_status_to_os_return(status); |
| 1806 | goto exit; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1807 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1808 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 1809 | status = hdd_component_pdev_open(hdd_ctx->pdev); |
| 1810 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1811 | QDF_DEBUG_PANIC("hdd component pdev open failed; status:%d", |
| 1812 | status); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1813 | ret = qdf_status_to_os_return(status); |
| 1814 | goto dispatcher_close; |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 1815 | } |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1816 | |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1817 | cdp_pdev_set_ctrl_pdev(cds_get_context(QDF_MODULE_ID_SOC), |
| 1818 | cds_get_context(QDF_MODULE_ID_TXRX), |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1819 | (struct cdp_ctrl_objmgr_pdev *)hdd_ctx->pdev); |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1820 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1821 | wlan_pdev_set_dp_handle(hdd_ctx->pdev, |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1822 | cds_get_context(QDF_MODULE_ID_TXRX)); |
| 1823 | |
Will Huang | 0724417 | 2018-05-14 14:23:30 +0800 | [diff] [blame] | 1824 | hdd_objmgr_update_tgt_max_vdev_psoc(hdd_ctx, cfg->max_intf_count); |
| 1825 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1826 | ucfg_ipa_set_dp_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1827 | cds_get_context(QDF_MODULE_ID_SOC)); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1828 | ucfg_ipa_set_txrx_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1829 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1830 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->pdev, |
Vevek Venkatesan | 78f7f09 | 2019-05-23 17:16:28 +0530 | [diff] [blame] | 1831 | hdd_softap_ipa_start_xmit); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1832 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->pdev, |
Vevek Venkatesan | 3b6be82 | 2019-05-28 18:19:15 +0530 | [diff] [blame] | 1833 | hdd_ipa_send_nbuf_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1834 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1835 | status = ucfg_mlme_get_sub_20_chan_width(hdd_ctx->psoc, |
| 1836 | &sub_20_chan_width); |
| 1837 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1838 | hdd_err("Failed to get sub_20_chan_width config"); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1839 | ret = qdf_status_to_os_return(status); |
| 1840 | goto pdev_close; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1841 | } |
| 1842 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1843 | if (cds_cfg) { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1844 | if (sub_20_chan_width != |
| 1845 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1846 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1847 | cds_cfg->sub_20_channel_width = |
| 1848 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1849 | } else { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1850 | cds_cfg->sub_20_channel_width = sub_20_chan_width; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1851 | } |
| 1852 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1853 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1854 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 1855 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1856 | hdd_err("Failed to get MLME band capability"); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1857 | ret = qdf_status_to_os_return(status); |
| 1858 | goto pdev_close; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1859 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1860 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1861 | /* first store the INI band capability */ |
| 1862 | temp_band_cap = band_capability; |
| 1863 | |
| 1864 | band_capability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1865 | hdd_ctx->is_fils_roaming_supported = |
| 1866 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1867 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1868 | hdd_ctx->config->is_11k_offload_supported = |
| 1869 | cfg->services.is_11k_offload_supported; |
| 1870 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1871 | /* |
| 1872 | * now overwrite the target band capability with INI |
| 1873 | * setting if INI setting is a subset |
| 1874 | */ |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1875 | if ((band_capability == BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1876 | (temp_band_cap != BAND_ALL)) |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1877 | band_capability = temp_band_cap; |
| 1878 | else if ((band_capability != BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1879 | (temp_band_cap != BAND_ALL) && |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1880 | (band_capability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1881 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1882 | } |
| 1883 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1884 | status = ucfg_mlme_set_band_capability(hdd_ctx->psoc, band_capability); |
| 1885 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1886 | hdd_err("Failed to set MLME Band Capability"); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1887 | ret = qdf_status_to_os_return(status); |
| 1888 | goto pdev_close; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1889 | } |
| 1890 | |
| 1891 | hdd_ctx->curr_band = band_capability; |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1892 | |
Qun Zhang | 043635a | 2019-02-27 15:19:29 +0800 | [diff] [blame] | 1893 | status = wlan_hdd_update_wiphy_supported_band(hdd_ctx); |
| 1894 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1895 | hdd_err("Failed to update wiphy band info"); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 1896 | goto pdev_close; |
Qun Zhang | 043635a | 2019-02-27 15:19:29 +0800 | [diff] [blame] | 1897 | } |
| 1898 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1899 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1900 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1901 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1902 | } |
| 1903 | |
| 1904 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1905 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1906 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) |
| 1907 | qdf_mem_copy(&hdd_ctx->hw_macaddr, &cfg->hw_macaddr, |
| 1908 | QDF_MAC_ADDR_SIZE); |
| 1909 | else |
| 1910 | hdd_info("hw_mac is zero"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1911 | |
| 1912 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1913 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1914 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 1915 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 1916 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 1917 | sizeof(cfg->hw_bd_info)); |
| 1918 | |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 1919 | if (cfg->max_intf_count > WLAN_MAX_VDEVS) { |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 1920 | hdd_err("fw max vdevs (%u) > host max vdevs (%u); using %u", |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 1921 | cfg->max_intf_count, WLAN_MAX_VDEVS, WLAN_MAX_VDEVS); |
| 1922 | hdd_ctx->max_intf_count = WLAN_MAX_VDEVS; |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 1923 | } else { |
| 1924 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1925 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1926 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1927 | hdd_sar_target_config(hdd_ctx, cfg); |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1928 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1929 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1930 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
Pragaspathi Thilagaraj | eb36728 | 2019-02-19 00:42:28 +0530 | [diff] [blame] | 1931 | status = ucfg_mlme_set_fw_supported_roaming_akm( |
| 1932 | hdd_ctx->psoc, |
| 1933 | cfg->ft_akm_service_bitmap); |
| 1934 | if (QDF_IS_STATUS_ERROR(status)) |
| 1935 | hdd_err("Failed to set ft akm suites bitmap"); |
| 1936 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1937 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1938 | |
| 1939 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1940 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1941 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1942 | if (cfg->services.en_11ax) { |
| 1943 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1944 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1945 | } |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 1946 | hdd_update_tgt_twt_cap(hdd_ctx, cfg); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1947 | |
gaurank kathpalia | fa7ad0a | 2019-03-12 19:17:56 +0530 | [diff] [blame] | 1948 | for (band = NSS_CHAINS_BAND_2GHZ; band < NSS_CHAINS_BAND_MAX; band++) { |
| 1949 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1950 | QDF_STA_MODE, band); |
| 1951 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1952 | QDF_SAP_MODE, band); |
| 1953 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1954 | QDF_TDLS_MODE, band); |
| 1955 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1956 | QDF_P2P_DEVICE_MODE, |
| 1957 | band); |
| 1958 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1959 | QDF_OCB_MODE, band); |
| 1960 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1961 | QDF_TDLS_MODE, band); |
| 1962 | } |
| 1963 | |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1964 | hdd_update_vdev_nss(hdd_ctx); |
| 1965 | |
gaurank kathpalia | 5fcefa9 | 2018-10-24 15:03:15 +0530 | [diff] [blame] | 1966 | hdd_ctx->dynamic_nss_chains_support = |
| 1967 | cfg->dynamic_nss_chains_support; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1968 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, &fine_time_meas_cap); |
| 1969 | fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
| 1970 | status = ucfg_mlme_set_fine_time_meas_cap(hdd_ctx->psoc, |
| 1971 | fine_time_meas_cap); |
| 1972 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1973 | hdd_err("failed to set fine_time_meas_cap, 0x%x, ox%x", |
| 1974 | fine_time_meas_cap, cfg->fine_time_measurement_cap); |
| 1975 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 1976 | &fine_time_meas_cap); |
| 1977 | } |
| 1978 | |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1979 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1980 | hdd_debug("fine_time_meas_cap: 0x%x", fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1981 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1982 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1983 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1984 | hdd_err("unable to get vht_enable2x2"); |
| 1985 | |
| 1986 | antenna_mode = (bval == 0x01) ? |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1987 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1988 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1989 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1990 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1991 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1992 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1993 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1994 | 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] | 1995 | &value); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1996 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1997 | status = false; |
| 1998 | hdd_err("set tx_bfee_ant_supp failed"); |
| 1999 | } |
| 2000 | |
Pragaspathi Thilagaraj | 6fc0a9a | 2019-05-17 16:49:45 +0530 | [diff] [blame] | 2001 | if ((value > MLME_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2002 | !cfg->tx_bfee_8ss_enabled) { |
Pragaspathi Thilagaraj | 6fc0a9a | 2019-05-17 16:49:45 +0530 | [diff] [blame] | 2003 | status = ucfg_mlme_cfg_set_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 2004 | MLME_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2005 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2006 | status = false; |
| 2007 | hdd_err("set tx_bfee_ant_supp failed"); |
| 2008 | } |
| 2009 | } |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2010 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2011 | mac_handle = hdd_ctx->mac_handle; |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2012 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2013 | hdd_debug("txBFCsnValue %d", value); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2014 | |
| 2015 | /* |
| 2016 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2017 | */ |
| 2018 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2019 | |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 2020 | hdd_update_vhtcap_2g(hdd_ctx); |
| 2021 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2022 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2023 | |
Ashish Kumar Dhanotiya | 908925d | 2019-03-01 17:35:30 +0530 | [diff] [blame] | 2024 | 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] | 2025 | /* |
| 2026 | * This needs to be done after HDD pdev is created and stored since |
| 2027 | * it will access the HDD pdev object lock. |
| 2028 | */ |
| 2029 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2030 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2031 | /* Configure NAN datapath features */ |
| 2032 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Nachiket Kukade | 85aa378 | 2018-11-02 20:12:34 +0530 | [diff] [blame] | 2033 | ucfg_nan_set_tgt_caps(hdd_ctx->psoc, &cfg->nan_caps); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2034 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2035 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 2036 | hdd_ctx->obss_scan_offload = cfg->services.obss_scan_offload; |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 2037 | status = ucfg_mlme_set_obss_detection_offload_enabled( |
| 2038 | hdd_ctx->psoc, cfg->obss_detection_offloaded); |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2039 | if (QDF_IS_STATUS_ERROR(status)) |
| 2040 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2041 | |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 2042 | status = ucfg_mlme_set_obss_color_collision_offload_enabled( |
| 2043 | hdd_ctx->psoc, cfg->obss_color_collision_offloaded); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2044 | if (QDF_IS_STATUS_ERROR(status)) |
| 2045 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Arif Hussain | 5068908 | 2019-03-26 12:07:58 -0700 | [diff] [blame] | 2046 | |
| 2047 | ucfg_mlme_get_bcast_twt(hdd_ctx->psoc, &bval); |
| 2048 | if (bval) |
| 2049 | ucfg_mlme_set_bcast_twt(hdd_ctx->psoc, cfg->bcast_twt_support); |
| 2050 | else |
| 2051 | hdd_debug("bcast twt is disable in ini, fw cap %d", |
| 2052 | cfg->bcast_twt_support); |
Arun Kumar Khandavalli | a423458 | 2019-03-20 16:16:05 +0530 | [diff] [blame] | 2053 | return 0; |
| 2054 | |
| 2055 | dispatcher_close: |
| 2056 | dispatcher_pdev_close(hdd_ctx->pdev); |
| 2057 | pdev_close: |
| 2058 | hdd_component_pdev_close(hdd_ctx->pdev); |
| 2059 | exit: |
| 2060 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 2061 | |
| 2062 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2063 | } |
| 2064 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2065 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2066 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2067 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2068 | struct hdd_ap_ctx *ap_ctx; |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2069 | bool dfs_disable_channel_switch = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2070 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2071 | if (!hdd_ctx) { |
| 2072 | hdd_info("Couldn't get hdd_ctx"); |
| 2073 | return true; |
| 2074 | } |
| 2075 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2076 | ucfg_mlme_get_dfs_disable_channel_switch(hdd_ctx->psoc, |
| 2077 | &dfs_disable_channel_switch); |
| 2078 | if (dfs_disable_channel_switch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2079 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2080 | hdd_ctx, dfs_disable_channel_switch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2081 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2082 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2083 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2084 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2085 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2086 | |
| 2087 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2088 | QDF_P2P_GO_MODE == adapter->device_mode) && |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2089 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2090 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2091 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2092 | true; |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 2093 | hdd_info("tx blocked for vdev: %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2094 | adapter->vdev_id); |
bings | 6fb9bf6 | 2018-07-05 14:01:53 +0800 | [diff] [blame] | 2095 | if (adapter->txrx_vdev) |
| 2096 | cdp_fc_vdev_flush( |
| 2097 | cds_get_context(QDF_MODULE_ID_SOC), |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2098 | adapter->txrx_vdev); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2099 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2100 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2101 | |
| 2102 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2103 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2104 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2105 | bool hdd_is_valid_mac_address(const uint8_t *mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2106 | { |
| 2107 | int xdigit = 0; |
| 2108 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2109 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2110 | while (*mac_addr) { |
| 2111 | if (isxdigit(*mac_addr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2112 | xdigit++; |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2113 | } else if (':' == *mac_addr) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2114 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2115 | break; |
| 2116 | |
| 2117 | ++separator; |
| 2118 | } else { |
| 2119 | /* Invalid MAC found */ |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2120 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2121 | } |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2122 | ++mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2123 | } |
| 2124 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2125 | } |
| 2126 | |
| 2127 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2128 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2129 | * @dev: Handle to struct net_device to be updated. |
| 2130 | * |
| 2131 | * Return: None |
| 2132 | */ |
| 2133 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2134 | { |
| 2135 | dev->header_ops = NULL; |
| 2136 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2137 | dev->hard_header_len = ETH_HLEN; |
| 2138 | dev->mtu = ETH_DATA_LEN; |
| 2139 | dev->addr_len = ETH_ALEN; |
| 2140 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2141 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2142 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2143 | |
| 2144 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2145 | } |
| 2146 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2147 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2148 | /** |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2149 | * hdd_mon_turn_off_ps_and_wow() - Update monitor mode struct net_device. |
| 2150 | * @hdd_ctx: Pointer to HDD context. |
| 2151 | * |
| 2152 | * Return: None |
| 2153 | */ |
| 2154 | static void hdd_mon_turn_off_ps_and_wow(struct hdd_context *hdd_ctx) |
| 2155 | { |
| 2156 | ucfg_pmo_set_power_save_mode(hdd_ctx->psoc, PS_NOT_SUPPORTED); |
| 2157 | ucfg_pmo_set_wow_enable(hdd_ctx->psoc, PMO_WOW_DISABLE_BOTH); |
| 2158 | } |
| 2159 | |
| 2160 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2161 | * __hdd__mon_open() - HDD Open function |
| 2162 | * @dev: Pointer to net_device structure |
| 2163 | * |
| 2164 | * This is called in response to ifconfig up |
| 2165 | * |
| 2166 | * Return: 0 for success; non-zero for failure |
| 2167 | */ |
| 2168 | static int __hdd_mon_open(struct net_device *dev) |
| 2169 | { |
| 2170 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2171 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2172 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2173 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2174 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2175 | |
| 2176 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2177 | if (ret) |
| 2178 | return ret; |
| 2179 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2180 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2181 | |
| 2182 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 2183 | ret = hdd_trigger_psoc_idle_restart(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2184 | if (ret) { |
| 2185 | hdd_err("Failed to start WLAN modules return"); |
| 2186 | return ret; |
| 2187 | } |
| 2188 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2189 | |
| 2190 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2191 | ret = hdd_start_adapter(adapter); |
| 2192 | if (ret) { |
| 2193 | hdd_err("Failed to start adapter :%d", |
| 2194 | adapter->device_mode); |
| 2195 | return ret; |
| 2196 | } |
| 2197 | hdd_err("hdd_start_adapters() successful !"); |
| 2198 | } |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2199 | hdd_mon_turn_off_ps_and_wow(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2200 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2201 | } |
| 2202 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2203 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2204 | |
| 2205 | if (!ret) |
| 2206 | ret = hdd_enable_monitor_mode(dev); |
| 2207 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2208 | return ret; |
| 2209 | } |
| 2210 | |
| 2211 | /** |
| 2212 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2213 | * @dev: Pointer to net_device structure |
| 2214 | * |
| 2215 | * This is called in response to ifconfig up |
| 2216 | * |
| 2217 | * Return: 0 for success; non-zero for failure |
| 2218 | */ |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2219 | static int hdd_mon_open(struct net_device *net_dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2220 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2221 | int errno; |
| 2222 | struct osif_vdev_sync *vdev_sync; |
| 2223 | |
| 2224 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 2225 | if (errno) |
| 2226 | return errno; |
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 | errno = __hdd_mon_open(net_dev); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2229 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2230 | osif_vdev_sync_trans_stop(vdev_sync); |
| 2231 | |
| 2232 | return errno; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2233 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2234 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2235 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2236 | static QDF_STATUS |
| 2237 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2238 | { |
| 2239 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2240 | QDF_STATUS status; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2241 | uint32_t chnl_sel_logic_conc = 0; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2242 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2243 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2244 | |
| 2245 | if (!hdd_ctx) { |
| 2246 | hdd_err("HDD context is NULL"); |
| 2247 | return QDF_STATUS_E_FAILURE; |
| 2248 | } |
| 2249 | |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2250 | /* |
| 2251 | * ROME platform doesn't support any DBS related commands in FW, |
| 2252 | * so if driver sends wmi command with dual_mac_config with all set to |
| 2253 | * 0 then FW wouldn't respond back and driver would timeout on waiting |
| 2254 | * for response. Check if FW supports DBS to eliminate ROME vs |
| 2255 | * NON-ROME platform. |
| 2256 | */ |
| 2257 | if (!policy_mgr_find_if_fw_supports_dbs(hdd_ctx->psoc)) |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2258 | return QDF_STATUS_SUCCESS; |
| 2259 | |
| 2260 | cfg.scan_config = 0; |
| 2261 | cfg.fw_mode_config = 0; |
| 2262 | 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] | 2263 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc)) { |
| 2264 | status = |
| 2265 | ucfg_policy_mgr_get_chnl_select_plcy(hdd_ctx->psoc, |
| 2266 | &chnl_sel_logic_conc); |
| 2267 | if (status != QDF_STATUS_SUCCESS) { |
| 2268 | hdd_err("can't get chnl sel policy, use def"); |
| 2269 | return status; |
| 2270 | } |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2271 | } |
| 2272 | status = |
| 2273 | ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 2274 | &dual_mac_feature); |
| 2275 | if (status != QDF_STATUS_SUCCESS) { |
| 2276 | hdd_err("ucfg_policy_mgr_get_dual_mac_feature failed, use def"); |
| 2277 | return status; |
| 2278 | } |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2279 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2280 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2281 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2282 | hdd_ctx->psoc, &cfg.scan_config, |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2283 | &cfg.fw_mode_config, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2284 | dual_mac_feature, |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2285 | chnl_sel_logic_conc); |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2286 | |
| 2287 | if (status != QDF_STATUS_SUCCESS) { |
| 2288 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2289 | status); |
| 2290 | return status; |
| 2291 | } |
| 2292 | } |
| 2293 | |
| 2294 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2295 | cfg.scan_config, cfg.fw_mode_config); |
| 2296 | |
| 2297 | status = sme_soc_set_dual_mac_config(cfg); |
| 2298 | if (status != QDF_STATUS_SUCCESS) { |
| 2299 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2300 | return status; |
| 2301 | } |
| 2302 | |
| 2303 | return QDF_STATUS_SUCCESS; |
| 2304 | } |
| 2305 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2306 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2307 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2308 | * @adapter: pointer to HDD adapter |
| 2309 | * |
| 2310 | * This function is called to start the device specific adapter for |
| 2311 | * the mode passed in the adapter's device_mode. |
| 2312 | * |
| 2313 | * Return: 0 for success; non-zero for failure |
| 2314 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2315 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2316 | { |
| 2317 | |
| 2318 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2319 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2320 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2321 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2322 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2323 | |
| 2324 | switch (device_mode) { |
| 2325 | case QDF_P2P_CLIENT_MODE: |
| 2326 | case QDF_P2P_DEVICE_MODE: |
| 2327 | case QDF_OCB_MODE: |
| 2328 | case QDF_STA_MODE: |
| 2329 | case QDF_MONITOR_MODE: |
| 2330 | ret = hdd_start_station_adapter(adapter); |
| 2331 | if (ret) |
| 2332 | goto err_start_adapter; |
Alok Kumar | 81e1d73 | 2018-09-04 11:10:36 +0530 | [diff] [blame] | 2333 | |
| 2334 | hdd_nud_ignore_tracking(adapter, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2335 | break; |
| 2336 | case QDF_P2P_GO_MODE: |
| 2337 | case QDF_SAP_MODE: |
| 2338 | ret = hdd_start_ap_adapter(adapter); |
| 2339 | if (ret) |
| 2340 | goto err_start_adapter; |
| 2341 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2342 | case QDF_IBSS_MODE: |
| 2343 | /* |
| 2344 | * For IBSS interface is initialized as part of |
| 2345 | * hdd_init_station_mode() |
| 2346 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2347 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2348 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2349 | /* vdevs are dynamically managed by firmware in FTM */ |
Arun Kumar Khandavalli | f573e06 | 2019-04-16 17:17:40 +0530 | [diff] [blame] | 2350 | hdd_register_wext(adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2351 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2352 | default: |
| 2353 | hdd_err("Invalid session type %d", device_mode); |
| 2354 | QDF_ASSERT(0); |
| 2355 | goto err_start_adapter; |
| 2356 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2357 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2358 | if (hdd_set_fw_params(adapter)) |
| 2359 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2360 | |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 2361 | if (adapter->vdev_id != WLAN_UMAC_VDEV_ID_MAX) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2362 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2363 | if (ret < 0) { |
| 2364 | hdd_err("Failed to register frames - ret %d", ret); |
| 2365 | goto err_start_adapter; |
| 2366 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2367 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2368 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2369 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2370 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2371 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2372 | hdd_exit(); |
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 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2375 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2376 | err_start_adapter: |
| 2377 | return -EINVAL; |
| 2378 | } |
| 2379 | |
| 2380 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2381 | * hdd_enable_power_management() - API to Enable Power Management |
| 2382 | * |
| 2383 | * API invokes Bus Interface Layer power management functionality |
| 2384 | * |
| 2385 | * Return: None |
| 2386 | */ |
| 2387 | static void hdd_enable_power_management(void) |
| 2388 | { |
| 2389 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2390 | |
| 2391 | if (!hif_ctx) { |
| 2392 | hdd_err("Bus Interface Context is Invalid"); |
| 2393 | return; |
| 2394 | } |
| 2395 | |
| 2396 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2397 | } |
| 2398 | |
| 2399 | /** |
| 2400 | * hdd_disable_power_management() - API to disable Power Management |
| 2401 | * |
| 2402 | * API disable Bus Interface Layer Power management functionality |
| 2403 | * |
| 2404 | * Return: None |
| 2405 | */ |
| 2406 | static void hdd_disable_power_management(void) |
| 2407 | { |
| 2408 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2409 | |
| 2410 | if (!hif_ctx) { |
| 2411 | hdd_err("Bus Interface Context is Invalid"); |
| 2412 | return; |
| 2413 | } |
| 2414 | |
| 2415 | hif_disable_power_management(hif_ctx); |
| 2416 | } |
| 2417 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2418 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2419 | { |
| 2420 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2421 | size_t target_hw_name_len; |
| 2422 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2423 | uint8_t *buf; |
| 2424 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2425 | |
| 2426 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2427 | if (!hif_sc) { |
| 2428 | hdd_err("HIF context is NULL"); |
| 2429 | return; |
| 2430 | } |
| 2431 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2432 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2433 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2434 | &target_hw_name); |
| 2435 | |
| 2436 | if (hdd_ctx->target_hw_name) |
| 2437 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2438 | |
| 2439 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2440 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2441 | if (hdd_ctx->target_hw_name) |
| 2442 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2443 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2444 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2445 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2446 | if (buf) { |
| 2447 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2448 | hdd_info("%s", buf); |
| 2449 | qdf_mem_free(buf); |
| 2450 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2451 | } |
| 2452 | |
| 2453 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2454 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2455 | * @hdd_ctx: Pointer to hdd context |
| 2456 | * |
| 2457 | * Return: none |
| 2458 | */ |
| 2459 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2460 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2461 | { |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2462 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM] = {0}; |
| 2463 | qdf_size_t out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2464 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2465 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2466 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2467 | if (!hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2468 | return; |
| 2469 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2470 | if (!hdd_ctx->config) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2471 | /* Do nothing if hdd_ctx is invalid */ |
| 2472 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2473 | return; |
| 2474 | } |
| 2475 | |
| 2476 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2477 | |
| 2478 | if (!cds_ctx) { |
| 2479 | hdd_err("Invalid CDS Context"); |
| 2480 | return; |
| 2481 | } |
| 2482 | |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2483 | for (i = 0; i < QCA_WLAN_AC_ALL; i++) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2484 | switch (i) { |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2485 | case QCA_WLAN_AC_BE: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2486 | qdf_uint8_array_parse( |
| 2487 | cfg_get(hdd_ctx->psoc, |
| 2488 | CFG_DP_ENABLE_TX_SCHED_WRR_BE), |
| 2489 | tx_sched_wrr_param, |
| 2490 | sizeof(tx_sched_wrr_param), |
| 2491 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2492 | break; |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2493 | case QCA_WLAN_AC_BK: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2494 | qdf_uint8_array_parse( |
| 2495 | cfg_get(hdd_ctx->psoc, |
| 2496 | CFG_DP_ENABLE_TX_SCHED_WRR_BK), |
| 2497 | tx_sched_wrr_param, |
| 2498 | sizeof(tx_sched_wrr_param), |
| 2499 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2500 | break; |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2501 | case QCA_WLAN_AC_VI: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2502 | qdf_uint8_array_parse( |
| 2503 | cfg_get(hdd_ctx->psoc, |
| 2504 | CFG_DP_ENABLE_TX_SCHED_WRR_VI), |
| 2505 | tx_sched_wrr_param, |
| 2506 | sizeof(tx_sched_wrr_param), |
| 2507 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2508 | break; |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2509 | case QCA_WLAN_AC_VO: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2510 | qdf_uint8_array_parse( |
| 2511 | cfg_get(hdd_ctx->psoc, |
| 2512 | CFG_DP_ENABLE_TX_SCHED_WRR_VO), |
| 2513 | tx_sched_wrr_param, |
| 2514 | sizeof(tx_sched_wrr_param), |
| 2515 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2516 | break; |
| 2517 | default: |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2518 | break; |
| 2519 | } |
| 2520 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2521 | if (out_size == TX_SCHED_WRR_PARAMS_NUM) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2522 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2523 | tx_sched_wrr_param[0]; |
| 2524 | cds_ctx->ac_specs[i].credit_threshold = |
| 2525 | tx_sched_wrr_param[1]; |
| 2526 | cds_ctx->ac_specs[i].send_limit = |
| 2527 | tx_sched_wrr_param[2]; |
| 2528 | cds_ctx->ac_specs[i].credit_reserve = |
| 2529 | tx_sched_wrr_param[3]; |
| 2530 | cds_ctx->ac_specs[i].discard_weight = |
| 2531 | tx_sched_wrr_param[4]; |
| 2532 | } |
| 2533 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2534 | out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2535 | } |
| 2536 | } |
| 2537 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2538 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2539 | const size_t version_len, uint8_t *version) |
| 2540 | { |
| 2541 | uint32_t size; |
| 2542 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2543 | |
| 2544 | if (!hdd_ctx) { |
| 2545 | hdd_err("Invalid context, HDD context is null"); |
| 2546 | return 0; |
| 2547 | } |
| 2548 | |
Ashish Kumar Dhanotiya | 7353f88 | 2018-05-15 12:50:19 +0530 | [diff] [blame] | 2549 | if (!version || version_len == 0) { |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2550 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2551 | return 0; |
| 2552 | } |
| 2553 | |
| 2554 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2555 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2556 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2557 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2558 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2559 | |
| 2560 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2561 | "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] | 2562 | QWLAN_VERSIONSTR, |
| 2563 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2564 | hdd_ctx->target_hw_name, |
| 2565 | hdd_ctx->hw_bd_info.bdf_version, |
| 2566 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2567 | hdd_ctx->hw_bd_info.customer_id, |
| 2568 | hdd_ctx->hw_bd_info.project_id, |
| 2569 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2570 | |
| 2571 | return size; |
| 2572 | } |
| 2573 | |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2574 | int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, |
| 2575 | struct sap_config *sap_config) |
| 2576 | { |
| 2577 | uint8_t preamble = 0, nss = 0, rix = 0; |
| 2578 | int ret; |
| 2579 | mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle; |
| 2580 | |
| 2581 | if (!sap_config) { |
| 2582 | if (!sme_is_feature_supported_by_fw(DOT11AX)) { |
| 2583 | hdd_err("Target does not support 11ax"); |
| 2584 | return -EIO; |
| 2585 | } |
| 2586 | } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax && |
| 2587 | sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) { |
| 2588 | hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d", |
| 2589 | sap_config->SapHw_mode, sap_config->channel); |
| 2590 | return -EIO; |
| 2591 | } |
| 2592 | |
| 2593 | if (set_value != 0xff) { |
| 2594 | rix = RC_2_RATE_IDX_11AX(set_value); |
| 2595 | preamble = WMI_RATE_PREAMBLE_HE; |
| 2596 | nss = HT_RC_2_STREAMS_11AX(set_value); |
| 2597 | |
| 2598 | set_value = hdd_assemble_rate_code(preamble, nss, rix); |
| 2599 | } else { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2600 | ret = sme_set_auto_rate_he_ltf(mac_handle, adapter->vdev_id, |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2601 | QCA_WLAN_HE_LTF_AUTO); |
| 2602 | } |
| 2603 | |
| 2604 | hdd_info("SET_11AX_RATE val %d rix %d preamble %x nss %d", |
| 2605 | set_value, rix, preamble, nss); |
| 2606 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2607 | ret = wma_cli_set_command(adapter->vdev_id, |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2608 | WMI_VDEV_PARAM_FIXED_RATE, |
| 2609 | set_value, VDEV_CMD); |
| 2610 | |
| 2611 | return ret; |
| 2612 | } |
| 2613 | |
| 2614 | int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate) |
| 2615 | { |
| 2616 | int set_value; |
| 2617 | |
| 2618 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 2619 | set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble); |
| 2620 | else |
| 2621 | set_value = (preamble << 6) | (nss << 4) | rate; |
| 2622 | |
| 2623 | return set_value; |
| 2624 | } |
| 2625 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2626 | #ifdef FEATURE_WLAN_WAPI |
| 2627 | /** |
| 2628 | * hdd_wapi_security_sta_exist() - return wapi security sta exist or not |
| 2629 | * |
| 2630 | * This API returns the wapi security station exist or not |
| 2631 | * |
| 2632 | * Return: true - wapi security station exist |
| 2633 | */ |
| 2634 | static bool hdd_wapi_security_sta_exist(void) |
| 2635 | { |
| 2636 | struct hdd_adapter *adapter = NULL; |
| 2637 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2638 | |
| 2639 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2640 | if ((adapter->device_mode == QDF_STA_MODE) && |
| 2641 | adapter->wapi_info.wapi_mode && |
| 2642 | (adapter->wapi_info.wapi_auth_mode != WAPI_AUTH_MODE_OPEN)) |
| 2643 | return true; |
| 2644 | } |
| 2645 | return false; |
| 2646 | } |
| 2647 | #else |
| 2648 | static bool hdd_wapi_security_sta_exist(void) |
| 2649 | { |
| 2650 | return false; |
| 2651 | } |
| 2652 | #endif |
| 2653 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2654 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2655 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2656 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2657 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2658 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2659 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2660 | |
| 2661 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2662 | if (!adapter) { |
| 2663 | hdd_err("Adapter is NULL"); |
| 2664 | return PM_MAX_NUM_OF_MODE; |
| 2665 | } |
| 2666 | |
| 2667 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2668 | adapter->device_mode); |
| 2669 | } |
| 2670 | |
Abhishek Singh | 3bbf6cb | 2019-03-28 14:05:43 +0530 | [diff] [blame] | 2671 | /** |
| 2672 | * hdd_is_chan_switch_in_progress() - Check if any adapter has channel switch in |
| 2673 | * progress |
| 2674 | * |
| 2675 | * Return: true, if any adapter has channel switch in |
| 2676 | * progress else false |
| 2677 | */ |
| 2678 | static bool hdd_is_chan_switch_in_progress(void) |
| 2679 | { |
| 2680 | struct hdd_adapter *adapter = NULL; |
| 2681 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2682 | |
| 2683 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2684 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 2685 | adapter->device_mode == QDF_P2P_GO_MODE) && |
| 2686 | qdf_atomic_read(&adapter->ch_switch_in_progress)) { |
| 2687 | hdd_debug("channel switch progress for vdev_id %d", |
| 2688 | adapter->vdev_id); |
| 2689 | return true; |
| 2690 | } |
| 2691 | } |
| 2692 | |
| 2693 | return false; |
| 2694 | } |
| 2695 | |
| 2696 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2697 | static void hdd_register_policy_manager_callback( |
| 2698 | struct wlan_objmgr_psoc *psoc) |
| 2699 | { |
| 2700 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2701 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2702 | qdf_mem_zero(&hdd_cbacks, sizeof(hdd_cbacks)); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2703 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2704 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2705 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2706 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2707 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2708 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2709 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2710 | hdd_cbacks.hdd_wapi_security_sta_exist = |
| 2711 | hdd_wapi_security_sta_exist; |
Abhishek Singh | 3bbf6cb | 2019-03-28 14:05:43 +0530 | [diff] [blame] | 2712 | hdd_cbacks.hdd_is_chan_switch_in_progress = |
| 2713 | hdd_is_chan_switch_in_progress; |
| 2714 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2715 | if (QDF_STATUS_SUCCESS != |
| 2716 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2717 | hdd_err("HDD callback registration with policy manager failed"); |
| 2718 | } |
| 2719 | } |
| 2720 | #else |
| 2721 | static void hdd_register_policy_manager_callback( |
| 2722 | struct wlan_objmgr_psoc *psoc) |
| 2723 | { |
| 2724 | } |
| 2725 | #endif |
| 2726 | |
Nachiket Kukade | 2fb1fdb | 2019-01-08 15:35:27 +0530 | [diff] [blame] | 2727 | #ifdef WLAN_FEATURE_NAN |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2728 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2729 | { |
| 2730 | struct nan_callbacks cb_obj = {0}; |
| 2731 | |
| 2732 | cb_obj.ndi_open = hdd_ndi_open; |
| 2733 | cb_obj.ndi_close = hdd_ndi_close; |
| 2734 | cb_obj.ndi_start = hdd_ndi_start; |
| 2735 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2736 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2737 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2738 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2739 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2740 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2741 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2742 | os_if_nan_register_hdd_callbacks(hdd_ctx->psoc, &cb_obj); |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2743 | } |
jiad | ff1ac13 | 2018-11-26 16:27:48 +0800 | [diff] [blame] | 2744 | #else |
| 2745 | static inline void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
| 2746 | { |
| 2747 | } |
| 2748 | #endif |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2749 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2750 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2751 | /** |
| 2752 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2753 | * @hdd_ctx: the global HDD context |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2754 | * @is_ssr: true if SSR is in progress |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2755 | * |
| 2756 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2757 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2758 | * |
| 2759 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2760 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2761 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2762 | * fixed. |
| 2763 | * |
| 2764 | * Return: None |
| 2765 | */ |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2766 | 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] | 2767 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2768 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2769 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2770 | wlan_objmgr_psoc_check_for_peer_leaks(hdd_ctx->psoc); |
| 2771 | wlan_objmgr_psoc_check_for_vdev_leaks(hdd_ctx->psoc); |
| 2772 | wlan_objmgr_psoc_check_for_pdev_leaks(hdd_ctx->psoc); |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2773 | |
| 2774 | /* many adapter resources are not freed by design during SSR */ |
| 2775 | if (is_ssr) |
| 2776 | return; |
| 2777 | |
Dustin Brown | c279631 | 2019-03-13 16:43:36 -0700 | [diff] [blame] | 2778 | qdf_delayed_work_check_for_leaks(); |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2779 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2780 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 2781 | qdf_periodic_work_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2782 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2783 | } |
| 2784 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2785 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2786 | #else |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2787 | static inline void hdd_check_for_leaks(struct hdd_context *hdd_ctx, bool is_ssr) |
| 2788 | { } |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2789 | |
| 2790 | #define hdd_debug_domain_set(domain) |
| 2791 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2792 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2793 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2794 | * hdd_update_country_code - Update country code |
| 2795 | * @hdd_ctx: HDD context |
| 2796 | * |
| 2797 | * Update country code based on module parameter country_code |
| 2798 | * |
| 2799 | * Return: 0 on success and errno on failure |
| 2800 | */ |
| 2801 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2802 | { |
| 2803 | if (!country_code) |
| 2804 | return 0; |
| 2805 | |
| 2806 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2807 | } |
| 2808 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2809 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2810 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2811 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2812 | qdf_device_t qdf_dev; |
| 2813 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2814 | bool unint = false; |
| 2815 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2816 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2817 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2818 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2819 | if (!qdf_dev) { |
| 2820 | hdd_err("QDF Device Context is Invalid return"); |
| 2821 | return -EINVAL; |
| 2822 | } |
| 2823 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 2824 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2825 | |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2826 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2827 | hdd_debug("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2828 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2829 | return 0; |
| 2830 | } |
| 2831 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2832 | switch (hdd_ctx->driver_status) { |
| 2833 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2834 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2835 | unint = true; |
| 2836 | /* Fall through dont add break here */ |
| 2837 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2838 | hdd_info("Wlan transitioning (CLOSED -> ENABLED)"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2839 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2840 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2841 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2842 | if (!reinit && !unint) { |
| 2843 | ret = pld_power_on(qdf_dev->dev); |
| 2844 | if (ret) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2845 | hdd_err("Failed to power up device; errno:%d", |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2846 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2847 | goto release_lock; |
| 2848 | } |
| 2849 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2850 | |
| 2851 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2852 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2853 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2854 | qdf_dev->bus_type, |
| 2855 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2856 | HIF_ENABLE_TYPE_PROBE); |
| 2857 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2858 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2859 | goto power_down; |
| 2860 | } |
| 2861 | |
| 2862 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2863 | if (!hif_ctx) { |
| 2864 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2865 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2866 | goto power_down; |
| 2867 | } |
| 2868 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2869 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2870 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2871 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2872 | status); |
| 2873 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2874 | goto hif_close; |
| 2875 | } |
| 2876 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 2877 | if (hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) { |
| 2878 | status = epping_open(); |
| 2879 | if (status) { |
| 2880 | hdd_err("Failed to open in epping mode: %d", |
| 2881 | status); |
| 2882 | ret = -EINVAL; |
| 2883 | goto cds_free; |
| 2884 | } |
| 2885 | |
| 2886 | status = epping_enable(qdf_dev->dev, false); |
| 2887 | if (status) { |
| 2888 | hdd_err("Failed to enable in epping mode : %d", |
| 2889 | status); |
| 2890 | epping_close(); |
| 2891 | goto cds_free; |
| 2892 | } |
| 2893 | |
| 2894 | hdd_info("epping mode enabled"); |
| 2895 | break; |
| 2896 | } |
| 2897 | |
jitiphil | 4c256a3 | 2018-09-07 08:51:52 +0530 | [diff] [blame] | 2898 | ucfg_ipa_component_config_update(hdd_ctx->psoc); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2899 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2900 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2901 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2902 | status = hdd_component_psoc_open(hdd_ctx->psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2903 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2904 | hdd_err("Failed to Open legacy components; status: %d", |
| 2905 | status); |
| 2906 | ret = qdf_status_to_os_return(status); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 2907 | goto cds_free; |
| 2908 | } |
| 2909 | |
| 2910 | ret = hdd_update_config(hdd_ctx); |
| 2911 | if (ret) { |
| 2912 | hdd_err("Failed to update configuration; errno: %d", |
| 2913 | ret); |
| 2914 | goto cds_free; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2915 | } |
| 2916 | |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 2917 | status = wbuff_module_init(); |
| 2918 | if (QDF_IS_STATUS_ERROR(status)) |
| 2919 | hdd_err("WBUFF init unsuccessful; status: %d", status); |
| 2920 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2921 | status = cds_open(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2922 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2923 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2924 | ret = qdf_status_to_os_return(status); |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 2925 | goto psoc_close; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2926 | } |
| 2927 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 2928 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 2929 | |
Manjunathappa Prakash | b6b4ff1 | 2018-06-04 12:32:33 -0700 | [diff] [blame] | 2930 | if (hdd_ctx->config->rx_thread_affinity_mask) |
| 2931 | cds_set_rx_thread_cpu_mask( |
| 2932 | hdd_ctx->config->rx_thread_affinity_mask); |
| 2933 | |
| 2934 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2935 | ret = hdd_update_components_config(hdd_ctx); |
| 2936 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2937 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2938 | ret); |
| 2939 | goto close; |
| 2940 | } |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2941 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2942 | status = cds_dp_open(hdd_ctx->psoc); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2943 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2944 | hdd_err("Failed to Open cds post open; status: %d", |
| 2945 | status); |
| 2946 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2947 | goto close; |
| 2948 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2949 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2950 | ret = hdd_register_cb(hdd_ctx); |
| 2951 | if (ret) { |
| 2952 | hdd_err("Failed to register HDD callbacks!"); |
| 2953 | goto cds_txrx_free; |
| 2954 | } |
| 2955 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2956 | /* |
| 2957 | * NAN compoenet requires certian operations like, open adapter, |
| 2958 | * close adapter, etc. to be initiated by HDD, for those |
| 2959 | * register HDD callbacks with UMAC's NAN componenet. |
| 2960 | */ |
| 2961 | hdd_nan_register_callbacks(hdd_ctx); |
| 2962 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2963 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2964 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2965 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2966 | ret = qdf_status_to_os_return(status); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2967 | goto deregister_cb; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2968 | } |
| 2969 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2970 | hdd_register_policy_manager_callback( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2971 | hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2972 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2973 | hdd_sysfs_create_driver_root_obj(); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2974 | hdd_sysfs_create_version_interface(hdd_ctx->psoc); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2975 | hdd_sysfs_create_powerstats_interface(); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2976 | hdd_update_hw_sw_info(hdd_ctx); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2977 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2978 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2979 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2980 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2981 | break; |
| 2982 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2983 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2984 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2985 | if (ret) { |
| 2986 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2987 | goto destroy_driver_sysfs; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2988 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2989 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2990 | hdd_enable_power_management(); |
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 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2993 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2994 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2995 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2996 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2997 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2998 | goto release_lock; |
| 2999 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3000 | |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 3001 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 3002 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 3003 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3004 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3005 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3006 | return 0; |
| 3007 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 3008 | destroy_driver_sysfs: |
| 3009 | hdd_sysfs_destroy_powerstats_interface(); |
| 3010 | hdd_sysfs_destroy_version_interface(); |
| 3011 | hdd_sysfs_destroy_driver_root_obj(); |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 3012 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3013 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 3014 | deregister_cb: |
| 3015 | hdd_deregister_cb(hdd_ctx); |
| 3016 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 3017 | cds_txrx_free: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3018 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 3019 | |
| 3020 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 3021 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 3022 | dispatcher_pdev_close(hdd_ctx->pdev); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 3023 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 3024 | } |
| 3025 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3026 | cds_dp_close(hdd_ctx->psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3027 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3028 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3029 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3030 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 3031 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3032 | cds_close(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3033 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 3034 | psoc_close: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3035 | hdd_component_psoc_close(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 3036 | cds_deinit_ini_config(); |
| 3037 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 3038 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3039 | ol_cds_free(); |
| 3040 | |
| 3041 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 3042 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 3043 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3044 | power_down: |
| 3045 | if (!reinit && !unint) |
| 3046 | pld_power_off(qdf_dev->dev); |
| 3047 | release_lock: |
Abhinav Kumar | 7ae9b7b | 2017-12-19 15:11:54 +0530 | [diff] [blame] | 3048 | if (hdd_ctx->target_hw_name) { |
| 3049 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 3050 | hdd_ctx->target_hw_name = NULL; |
| 3051 | } |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 3052 | |
| 3053 | hdd_check_for_leaks(hdd_ctx, reinit); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 3054 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 3055 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3056 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3057 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 3058 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3059 | } |
| 3060 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3061 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3062 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3063 | { |
| 3064 | int ret = os_if_wifi_pos_register_nl(); |
| 3065 | |
| 3066 | if (ret) |
| 3067 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 3068 | |
| 3069 | return ret; |
| 3070 | } |
| 3071 | |
| 3072 | static int hdd_deactivate_wifi_pos(void) |
| 3073 | { |
| 3074 | int ret = os_if_wifi_pos_deregister_nl(); |
| 3075 | |
| 3076 | if (ret) |
| 3077 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 3078 | |
| 3079 | return ret; |
| 3080 | } |
| 3081 | |
| 3082 | /** |
| 3083 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 3084 | * @hdd_ctx: hdd context |
| 3085 | * |
| 3086 | * Return: status of operation |
| 3087 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3088 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3089 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3090 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3091 | uint16_t neighbor_scan_max_chan_time; |
| 3092 | uint16_t neighbor_scan_min_chan_time; |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3093 | |
| 3094 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 3095 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 3096 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 3097 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 3098 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 3099 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3100 | ucfg_mlme_get_neighbor_scan_max_chan_time(psoc, |
| 3101 | &neighbor_scan_max_chan_time); |
| 3102 | ucfg_mlme_get_neighbor_scan_min_chan_time(psoc, |
| 3103 | &neighbor_scan_min_chan_time); |
| 3104 | wifi_pos_set_dwell_time_min(psoc, neighbor_scan_min_chan_time); |
| 3105 | wifi_pos_set_dwell_time_max(psoc, neighbor_scan_max_chan_time); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3106 | } |
| 3107 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3108 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3109 | { |
| 3110 | return oem_activate_service(hdd_ctx); |
| 3111 | } |
| 3112 | |
| 3113 | static int hdd_deactivate_wifi_pos(void) |
| 3114 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 3115 | return oem_deactivate_service(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3116 | } |
| 3117 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3118 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3119 | { |
| 3120 | } |
| 3121 | #endif |
| 3122 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3123 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3124 | * __hdd_open() - HDD Open function |
| 3125 | * @dev: Pointer to net_device structure |
| 3126 | * |
| 3127 | * This is called in response to ifconfig up |
| 3128 | * |
| 3129 | * Return: 0 for success; non-zero for failure |
| 3130 | */ |
| 3131 | static int __hdd_open(struct net_device *dev) |
| 3132 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3133 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3134 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3135 | int ret; |
| 3136 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3137 | hdd_enter_dev(dev); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3138 | |
| 3139 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3140 | TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3141 | adapter->vdev_id, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3142 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 3143 | /* Nothing to be done if device is unloading */ |
| 3144 | if (cds_is_driver_unloading()) { |
| 3145 | hdd_err("Driver is unloading can not open the hdd"); |
| 3146 | return -EBUSY; |
| 3147 | } |
| 3148 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 3149 | if (cds_is_driver_recovering()) { |
| 3150 | hdd_err("WLAN is currently recovering; Please try again."); |
| 3151 | return -EBUSY; |
| 3152 | } |
| 3153 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3154 | /* |
| 3155 | * This scenario can be hit in cases where in the wlan driver after |
| 3156 | * registering the netdevices and there is a failure in driver |
| 3157 | * initialization. So return error gracefully because the netdevices |
| 3158 | * will be de-registered as part of the load failure. |
| 3159 | */ |
| 3160 | |
| 3161 | if (!cds_is_driver_loaded()) { |
| 3162 | hdd_err("Failed to start the wlan driver!!"); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3163 | return -EIO; |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3164 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3165 | |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 3166 | ret = hdd_trigger_psoc_idle_restart(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3167 | if (ret) { |
| 3168 | hdd_err("Failed to start WLAN modules return"); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3169 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3170 | } |
| 3171 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3172 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3173 | ret = hdd_start_adapter(adapter); |
| 3174 | if (ret) { |
| 3175 | hdd_err("Failed to start adapter :%d", |
| 3176 | adapter->device_mode); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3177 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3178 | } |
| 3179 | } |
| 3180 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3181 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3182 | 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] | 3183 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3184 | /* Enable TX queues only when we are connected */ |
| 3185 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3186 | WLAN_START_ALL_NETIF_QUEUE, |
| 3187 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3188 | } |
| 3189 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3190 | /* Enable carrier and transmit queues for NDI */ |
| 3191 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3192 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3193 | wlan_hdd_netif_queue_control(adapter, |
| 3194 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3195 | WLAN_CONTROL_PATH); |
| 3196 | } |
| 3197 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3198 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3199 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3200 | |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3201 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3202 | } |
| 3203 | |
| 3204 | /** |
| 3205 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3206 | * @net_dev: Pointer to net_device structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3207 | * |
| 3208 | * This is called in response to ifconfig up |
| 3209 | * |
| 3210 | * Return: 0 for success; non-zero for failure |
| 3211 | */ |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3212 | static int hdd_open(struct net_device *net_dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3213 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3214 | int errno; |
| 3215 | struct osif_vdev_sync *vdev_sync; |
| 3216 | |
| 3217 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 3218 | if (errno) |
| 3219 | return errno; |
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 | errno = __hdd_open(net_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3222 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3223 | osif_vdev_sync_trans_stop(vdev_sync); |
| 3224 | |
| 3225 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3226 | } |
| 3227 | |
gaurank kathpalia | ac8504a | 2019-06-03 14:51:36 +0530 | [diff] [blame] | 3228 | static bool |
| 3229 | hdd_is_any_sta_interface_open(struct hdd_context *hdd_ctx) |
| 3230 | { |
| 3231 | struct hdd_adapter *adapter; |
| 3232 | |
| 3233 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 3234 | if (adapter->device_mode == QDF_STA_MODE && |
| 3235 | (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 3236 | test_bit(SME_SESSION_OPENED, &adapter->event_flags))) |
| 3237 | return true; |
| 3238 | } |
| 3239 | |
| 3240 | return false; |
| 3241 | } |
| 3242 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3243 | /** |
| 3244 | * __hdd_stop() - HDD stop function |
| 3245 | * @dev: Pointer to net_device structure |
| 3246 | * |
| 3247 | * This is called in response to ifconfig down |
| 3248 | * |
| 3249 | * Return: 0 for success; non-zero for failure |
| 3250 | */ |
| 3251 | static int __hdd_stop(struct net_device *dev) |
| 3252 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3253 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3254 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3255 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3256 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3257 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3258 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3259 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3260 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3261 | TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3262 | adapter->vdev_id, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3263 | |
| 3264 | ret = wlan_hdd_validate_context(hdd_ctx); |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3265 | if (ret) { |
| 3266 | set_bit(DOWN_DURING_SSR, &adapter->event_flags); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3267 | return ret; |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3268 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3269 | |
| 3270 | /* Nothing to be done if the interface is not opened */ |
| 3271 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3272 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3273 | return -ENODEV; |
| 3274 | } |
| 3275 | |
| 3276 | /* Make sure the interface is marked as closed */ |
| 3277 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3278 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3279 | mac_handle = hdd_ctx->mac_handle; |
| 3280 | |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3281 | hdd_debug("Disabling Auto Power save timer"); |
| 3282 | sme_ps_disable_auto_ps_timer( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3283 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3284 | adapter->vdev_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3285 | |
| 3286 | /* |
| 3287 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3288 | * be called on that interface |
| 3289 | */ |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 3290 | hdd_debug("Disabling queues, adapter device mode: %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 3291 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3292 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3293 | wlan_hdd_netif_queue_control(adapter, |
| 3294 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3295 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3296 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3297 | if (adapter->device_mode == QDF_STA_MODE) |
| 3298 | hdd_lpass_notify_stop(hdd_ctx); |
| 3299 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3300 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3301 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3302 | * bursty in nature and depends on the need to transfer. The service |
| 3303 | * layer may down the interface after the usage and up again when |
| 3304 | * required. In some sense, the NDI is expected to be available |
| 3305 | * (like SAP) iface until NDI delete request is issued by the service |
| 3306 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3307 | * interface (NDI). |
| 3308 | */ |
| 3309 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3310 | return 0; |
| 3311 | |
| 3312 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3313 | * The interface is marked as down for outside world (aka kernel) |
| 3314 | * But the driver is pretty much alive inside. The driver needs to |
| 3315 | * tear down the existing connection on the netdev (session) |
| 3316 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3317 | * for this interface. The call also needs to wait until the above |
| 3318 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3319 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3320 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3321 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3322 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3323 | |
| 3324 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3325 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3326 | |
gaurank kathpalia | ac8504a | 2019-06-03 14:51:36 +0530 | [diff] [blame] | 3327 | /* If no STA interface is open, then flush out the BLM entries */ |
| 3328 | if (!hdd_is_any_sta_interface_open(hdd_ctx)) |
| 3329 | ucfg_blm_flush_reject_ap_list(hdd_ctx->pdev); |
| 3330 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3331 | if (!hdd_is_any_interface_open(hdd_ctx)) |
| 3332 | hdd_psoc_idle_timer_start(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3333 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3334 | hdd_exit(); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3335 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3336 | return 0; |
| 3337 | } |
| 3338 | |
| 3339 | /** |
| 3340 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3341 | * @dev: pointer to net_device structure |
| 3342 | * |
| 3343 | * This is called in response to ifconfig down |
| 3344 | * |
| 3345 | * Return: 0 for success and error number for failure |
| 3346 | */ |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3347 | static int hdd_stop(struct net_device *net_dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3348 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3349 | int errno; |
| 3350 | struct osif_vdev_sync *vdev_sync; |
| 3351 | |
| 3352 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 3353 | if (errno) |
| 3354 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3355 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3356 | errno = __hdd_stop(net_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3357 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3358 | osif_vdev_sync_trans_stop(vdev_sync); |
| 3359 | |
| 3360 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3361 | } |
| 3362 | |
| 3363 | /** |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3364 | * hdd_uninit() - HDD uninit function |
| 3365 | * @dev: Pointer to net_device structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3366 | * |
| 3367 | * This is called during the netdev unregister to uninitialize all data |
| 3368 | * associated with the device |
| 3369 | * |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3370 | * This function must be protected by a transition |
| 3371 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3372 | * Return: None |
| 3373 | */ |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3374 | static void hdd_uninit(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3375 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3376 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3377 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3378 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3379 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3380 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3381 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 3382 | hdd_err("Invalid magic"); |
| 3383 | goto exit; |
| 3384 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3385 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3386 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3387 | if (!hdd_ctx) { |
| 3388 | hdd_err("NULL hdd_ctx"); |
| 3389 | goto exit; |
| 3390 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3391 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3392 | if (dev != adapter->dev) |
| 3393 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3394 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3395 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3396 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3397 | /* after uninit our adapter structure will no longer be valid */ |
| 3398 | adapter->dev = NULL; |
| 3399 | adapter->magic = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3400 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3401 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3402 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3403 | } |
| 3404 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3405 | static int hdd_open_cesium_nl_sock(void) |
| 3406 | { |
| 3407 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3408 | struct netlink_kernel_cfg cfg = { |
| 3409 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3410 | .input = NULL |
| 3411 | }; |
| 3412 | #endif |
| 3413 | int ret = 0; |
| 3414 | |
| 3415 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3416 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3417 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3418 | THIS_MODULE, |
| 3419 | #endif |
| 3420 | &cfg); |
| 3421 | #else |
| 3422 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3423 | WLAN_NLINK_MCAST_GRP_ID, |
| 3424 | NULL, NULL, THIS_MODULE); |
| 3425 | #endif |
| 3426 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3427 | if (!cesium_nl_srv_sock) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3428 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3429 | ret = -ECONNREFUSED; |
| 3430 | } |
| 3431 | |
| 3432 | return ret; |
| 3433 | } |
| 3434 | |
| 3435 | static void hdd_close_cesium_nl_sock(void) |
| 3436 | { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3437 | if (cesium_nl_srv_sock) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3438 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3439 | cesium_nl_srv_sock = NULL; |
| 3440 | } |
| 3441 | } |
| 3442 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3443 | void hdd_update_dynamic_mac(struct hdd_context *hdd_ctx, |
| 3444 | struct qdf_mac_addr *curr_mac_addr, |
| 3445 | struct qdf_mac_addr *new_mac_addr) |
| 3446 | { |
| 3447 | uint8_t i; |
| 3448 | |
| 3449 | hdd_enter(); |
| 3450 | |
| 3451 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3452 | if (!qdf_mem_cmp( |
| 3453 | curr_mac_addr->bytes, |
| 3454 | &hdd_ctx->dynamic_mac_list[i].dynamic_mac.bytes[0], |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3455 | sizeof(struct qdf_mac_addr))) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3456 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[i].dynamic_mac, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3457 | new_mac_addr->bytes, |
| 3458 | sizeof(struct qdf_mac_addr)); |
| 3459 | break; |
| 3460 | } |
| 3461 | } |
| 3462 | |
| 3463 | hdd_exit(); |
| 3464 | } |
| 3465 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3466 | /** |
| 3467 | * __hdd_set_mac_address() - set the user specified mac address |
| 3468 | * @dev: Pointer to the net device. |
| 3469 | * @addr: Pointer to the sockaddr. |
| 3470 | * |
| 3471 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3472 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3473 | * |
| 3474 | * Return: 0 for success, non zero for failure |
| 3475 | */ |
| 3476 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3477 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3478 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3479 | struct hdd_adapter *adapter_temp; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3480 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3481 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3482 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3483 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3484 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3485 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3486 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3487 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3488 | if (netif_running(dev)) { |
| 3489 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3490 | return -EBUSY; |
| 3491 | } |
| 3492 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3493 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3494 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3495 | if (0 != ret) |
| 3496 | return ret; |
| 3497 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3498 | 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] | 3499 | adapter_temp = hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes); |
| 3500 | if (adapter_temp) { |
| 3501 | if (!qdf_str_cmp(adapter_temp->dev->name, dev->name)) |
| 3502 | return 0; |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3503 | 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] | 3504 | adapter_temp->dev->name, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3505 | QDF_MAC_ADDR_ARRAY(mac_addr.bytes)); |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3506 | return -EINVAL; |
| 3507 | } |
| 3508 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 3509 | qdf_ret_status = wlan_hdd_validate_mac_address(&mac_addr); |
| 3510 | if (QDF_IS_STATUS_ERROR(qdf_ret_status)) |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3511 | return -EINVAL; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3512 | |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3513 | 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] | 3514 | QDF_MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3515 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3516 | hdd_update_dynamic_mac(hdd_ctx, &adapter->mac_addr, &mac_addr); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3517 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3518 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3519 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3520 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3521 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3522 | } |
| 3523 | |
| 3524 | /** |
| 3525 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3526 | * function from SSR |
| 3527 | * @net_dev: pointer to net_device structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3528 | * @addr: Pointer to the sockaddr |
| 3529 | * |
| 3530 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3531 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3532 | * |
| 3533 | * Return: 0 for success. |
| 3534 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3535 | 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] | 3536 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3537 | struct osif_vdev_sync *vdev_sync; |
| 3538 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3539 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3540 | errno = osif_vdev_sync_op_start(net_dev, &vdev_sync); |
| 3541 | if (errno) |
| 3542 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3543 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3544 | errno = __hdd_set_mac_address(net_dev, addr); |
| 3545 | |
| 3546 | osif_vdev_sync_op_stop(vdev_sync); |
| 3547 | |
| 3548 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3549 | } |
| 3550 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3551 | 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] | 3552 | { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3553 | int i, j; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3554 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3555 | i = qdf_ffz(hdd_ctx->derived_intf_addr_mask); |
| 3556 | if (i < 0 || i >= hdd_ctx->num_derived_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3557 | return NULL; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3558 | qdf_atomic_set_bit(i, &hdd_ctx->derived_intf_addr_mask); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3559 | hdd_info("Assigning MAC from derived list" QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3560 | QDF_MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3561 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3562 | /* Copy the mac in dynamic mac list at first free position */ |
| 3563 | for (j = 0; j < QDF_MAX_CONCURRENCY_PERSONA; j++) { |
| 3564 | if (qdf_is_macaddr_zero(&hdd_ctx-> |
| 3565 | dynamic_mac_list[j].dynamic_mac)) |
| 3566 | break; |
| 3567 | } |
| 3568 | if (j == QDF_MAX_CONCURRENCY_PERSONA) { |
| 3569 | hdd_err("Max interfaces are up"); |
| 3570 | return NULL; |
| 3571 | } |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 3572 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3573 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[j].dynamic_mac.bytes, |
| 3574 | &hdd_ctx->derived_mac_addr[i].bytes, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3575 | sizeof(struct qdf_mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3576 | hdd_ctx->dynamic_mac_list[j].is_provisioned_mac = false; |
| 3577 | hdd_ctx->dynamic_mac_list[j].bit_position = i; |
| 3578 | |
| 3579 | return hdd_ctx->derived_mac_addr[i].bytes; |
| 3580 | } |
| 3581 | |
| 3582 | static uint8_t *wlan_hdd_get_provisioned_intf_addr(struct hdd_context *hdd_ctx) |
| 3583 | { |
| 3584 | int i, j; |
| 3585 | |
| 3586 | i = qdf_ffz(hdd_ctx->provisioned_intf_addr_mask); |
| 3587 | if (i < 0 || i >= hdd_ctx->num_provisioned_addr) |
| 3588 | return NULL; |
| 3589 | qdf_atomic_set_bit(i, &hdd_ctx->provisioned_intf_addr_mask); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3590 | hdd_info("Assigning MAC from provisioned list" QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3591 | QDF_MAC_ADDR_ARRAY(hdd_ctx->provisioned_mac_addr[i].bytes)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3592 | |
| 3593 | /* Copy the mac in dynamic mac list at first free position */ |
| 3594 | for (j = 0; j < QDF_MAX_CONCURRENCY_PERSONA; j++) { |
| 3595 | if (qdf_is_macaddr_zero(&hdd_ctx-> |
| 3596 | dynamic_mac_list[j].dynamic_mac)) |
| 3597 | break; |
| 3598 | } |
| 3599 | if (j == QDF_MAX_CONCURRENCY_PERSONA) { |
| 3600 | hdd_err("Max interfaces are up"); |
| 3601 | return NULL; |
| 3602 | } |
| 3603 | |
| 3604 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[j].dynamic_mac.bytes, |
| 3605 | &hdd_ctx->provisioned_mac_addr[i].bytes, |
| 3606 | sizeof(struct qdf_mac_addr)); |
| 3607 | hdd_ctx->dynamic_mac_list[j].is_provisioned_mac = true; |
| 3608 | hdd_ctx->dynamic_mac_list[j].bit_position = i; |
| 3609 | return hdd_ctx->provisioned_mac_addr[i].bytes; |
| 3610 | } |
| 3611 | |
| 3612 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx, |
| 3613 | enum QDF_OPMODE interface_type) |
| 3614 | { |
| 3615 | uint8_t *mac_addr = NULL; |
| 3616 | |
| 3617 | if (qdf_atomic_test_bit(interface_type, |
| 3618 | (unsigned long *) |
| 3619 | (&hdd_ctx->config->provisioned_intf_pool))) |
| 3620 | mac_addr = wlan_hdd_get_provisioned_intf_addr(hdd_ctx); |
| 3621 | |
| 3622 | if ((!mac_addr) && |
| 3623 | (qdf_atomic_test_bit(interface_type, |
| 3624 | (unsigned long *) |
| 3625 | (&hdd_ctx->config->derived_intf_pool)))) |
| 3626 | mac_addr = wlan_hdd_get_derived_intf_addr(hdd_ctx); |
| 3627 | |
| 3628 | if (!mac_addr) |
| 3629 | hdd_err("MAC is not available in both the lists"); |
| 3630 | return mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3631 | } |
| 3632 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3633 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3634 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3635 | { |
| 3636 | int i; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3637 | int mac_pos_in_mask; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3638 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3639 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3640 | if (!memcmp(releaseAddr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3641 | hdd_ctx->dynamic_mac_list[i].dynamic_mac.bytes, |
| 3642 | QDF_MAC_ADDR_SIZE)) { |
| 3643 | mac_pos_in_mask = |
| 3644 | hdd_ctx->dynamic_mac_list[i].bit_position; |
| 3645 | if (hdd_ctx->dynamic_mac_list[i].is_provisioned_mac) { |
| 3646 | qdf_atomic_clear_bit( |
| 3647 | mac_pos_in_mask, |
| 3648 | &hdd_ctx-> |
| 3649 | provisioned_intf_addr_mask); |
| 3650 | hdd_info("Releasing MAC from provisioned list"); |
| 3651 | hdd_info( |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3652 | QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3653 | QDF_MAC_ADDR_ARRAY(releaseAddr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3654 | } else { |
| 3655 | qdf_atomic_clear_bit( |
| 3656 | mac_pos_in_mask, &hdd_ctx-> |
| 3657 | derived_intf_addr_mask); |
| 3658 | hdd_info("Releasing MAC from derived list"); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3659 | hdd_info(QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3660 | QDF_MAC_ADDR_ARRAY(releaseAddr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3661 | } |
| 3662 | qdf_zero_macaddr(&hdd_ctx-> |
| 3663 | dynamic_mac_list[i].dynamic_mac); |
| 3664 | hdd_ctx->dynamic_mac_list[i].is_provisioned_mac = |
| 3665 | false; |
| 3666 | hdd_ctx->dynamic_mac_list[i].bit_position = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3667 | break; |
| 3668 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3669 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3670 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3671 | if (i == QDF_MAX_CONCURRENCY_PERSONA) |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3672 | hdd_err("Releasing non existing MAC" QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3673 | QDF_MAC_ADDR_ARRAY(releaseAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3674 | } |
| 3675 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3676 | /** |
| 3677 | * __hdd_set_multicast_list() - set the multicast address list |
| 3678 | * @dev: Pointer to the WLAN device. |
| 3679 | * @skb: Pointer to OS packet (sk_buff). |
| 3680 | * |
| 3681 | * This funciton sets the multicast address list. |
| 3682 | * |
| 3683 | * Return: None |
| 3684 | */ |
| 3685 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3686 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3687 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3688 | int i = 0, errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3689 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3690 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3691 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3692 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3693 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3694 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3695 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3696 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3697 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3698 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3699 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 3700 | if (errno) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3701 | goto out; |
| 3702 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3703 | errno = hdd_validate_adapter(adapter); |
| 3704 | if (errno) |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3705 | goto out; |
| 3706 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3707 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3708 | hdd_err("%s: Driver module is closed", __func__); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3709 | goto out; |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3710 | } |
| 3711 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3712 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 3713 | if (!mc_list_request) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3714 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3715 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3716 | /* Delete already configured multicast address list */ |
| 3717 | if (adapter->mc_addr_list.mc_cnt > 0) { |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3718 | hdd_debug("clear previously configured MC address list"); |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3719 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3720 | pmo_mc_list_change_notify); |
| 3721 | } |
| 3722 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3723 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3724 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3725 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3726 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3727 | } else { |
| 3728 | mc_count = netdev_mc_count(dev); |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 3729 | if (mc_count > ucfg_pmo_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3730 | 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] | 3731 | ucfg_pmo_max_mc_addr_supported(psoc)); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3732 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3733 | pmo_mc_list_change_notify); |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3734 | adapter->mc_addr_list.mc_cnt = 0; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3735 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3736 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3737 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 3738 | hdd_debug("ha_addr[%d] "QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3739 | i, QDF_MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3740 | if (i == mc_count) |
| 3741 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3742 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3743 | 0, ETH_ALEN); |
| 3744 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3745 | ha->addr, ETH_ALEN); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3746 | hdd_debug("mlist[%d] = %pM", i, |
| 3747 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3748 | i++; |
| 3749 | } |
| 3750 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3751 | |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3752 | adapter->mc_addr_list.mc_cnt = mc_count; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3753 | mc_list_request->psoc = psoc; |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3754 | mc_list_request->vdev_id = adapter->vdev_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3755 | mc_list_request->count = mc_count; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3756 | |
| 3757 | errno = hdd_cache_mc_addr_list(mc_list_request); |
| 3758 | if (errno) { |
| 3759 | 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] | 3760 | adapter->vdev_id, errno); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3761 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3762 | } |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3763 | |
| 3764 | hdd_enable_mc_addr_filtering(adapter, pmo_mc_list_change_notify); |
| 3765 | |
| 3766 | free_req: |
| 3767 | qdf_mem_free(mc_list_request); |
| 3768 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3769 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3770 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3771 | } |
| 3772 | |
| 3773 | /** |
| 3774 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3775 | * @net_dev: pointer to net_device |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3776 | * |
| 3777 | * Return: none |
| 3778 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3779 | static void hdd_set_multicast_list(struct net_device *net_dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3780 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3781 | struct osif_vdev_sync *vdev_sync; |
| 3782 | |
| 3783 | if (osif_vdev_sync_op_start(net_dev, &vdev_sync)) |
| 3784 | return; |
| 3785 | |
| 3786 | __hdd_set_multicast_list(net_dev); |
| 3787 | |
| 3788 | osif_vdev_sync_op_stop(vdev_sync); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3789 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3790 | |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3791 | #ifdef WLAN_FEATURE_TSF_PTP |
| 3792 | static const struct ethtool_ops wlan_ethtool_ops = { |
| 3793 | .get_ts_info = wlan_get_ts_info, |
| 3794 | }; |
| 3795 | #endif |
| 3796 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3797 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3798 | .ndo_open = hdd_open, |
| 3799 | .ndo_stop = hdd_stop, |
| 3800 | .ndo_uninit = hdd_uninit, |
| 3801 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3802 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3803 | .ndo_get_stats = hdd_get_stats, |
| 3804 | .ndo_do_ioctl = hdd_ioctl, |
| 3805 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3806 | .ndo_select_queue = hdd_select_queue, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3807 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3808 | }; |
| 3809 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3810 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3811 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3812 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3813 | .ndo_open = hdd_mon_open, |
| 3814 | .ndo_stop = hdd_stop, |
| 3815 | .ndo_get_stats = hdd_get_stats, |
| 3816 | }; |
| 3817 | |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3818 | #ifdef WLAN_FEATURE_TSF_PTP |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3819 | /** |
| 3820 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3821 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3822 | * Return: None |
| 3823 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3824 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3825 | { |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3826 | if (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE) { |
| 3827 | dev->netdev_ops = &wlan_mon_drv_ops; |
| 3828 | } else { |
| 3829 | dev->netdev_ops = &wlan_drv_ops; |
| 3830 | dev->ethtool_ops = &wlan_ethtool_ops; |
| 3831 | } |
| 3832 | } |
| 3833 | #else |
| 3834 | void hdd_set_station_ops(struct net_device *dev) |
| 3835 | { |
| 3836 | if (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3837 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3838 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3839 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3840 | } |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3841 | |
| 3842 | #endif |
| 3843 | #else |
| 3844 | #ifdef WLAN_FEATURE_TSF_PTP |
| 3845 | void hdd_set_station_ops(struct net_device *dev) |
| 3846 | { |
| 3847 | dev->netdev_ops = &wlan_drv_ops; |
| 3848 | dev->ethtool_ops = &wlan_ethtool_ops; |
| 3849 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3850 | #else |
| 3851 | void hdd_set_station_ops(struct net_device *dev) |
| 3852 | { |
| 3853 | dev->netdev_ops = &wlan_drv_ops; |
| 3854 | } |
| 3855 | #endif |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3856 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3857 | |
| 3858 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3859 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3860 | * @hdd_ctx: global hdd context |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3861 | * @mac_addr: mac address to assign to the interface |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3862 | * @name: User-visible name of the interface |
| 3863 | * |
| 3864 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3865 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3866 | * |
| 3867 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3868 | */ |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3869 | static struct hdd_adapter * |
| 3870 | hdd_alloc_station_adapter(struct hdd_context *hdd_ctx, tSirMacAddr mac_addr, |
| 3871 | unsigned char name_assign_type, const char *name) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3872 | { |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3873 | struct net_device *dev; |
| 3874 | struct hdd_adapter *adapter; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3875 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3876 | QDF_STATUS qdf_status; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3877 | |
| 3878 | /* cfg80211 initialization and registration */ |
| 3879 | dev = alloc_netdev_mq(sizeof(*adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3880 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3881 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3882 | #endif |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3883 | (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE ? |
| 3884 | hdd_mon_mode_ether_setup : ether_setup), |
| 3885 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3886 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3887 | if (!dev) { |
| 3888 | hdd_err("Failed to allocate new net_device '%s'", name); |
| 3889 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3890 | } |
| 3891 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3892 | adapter = netdev_priv(dev); |
| 3893 | |
| 3894 | qdf_mem_zero(adapter, sizeof(*adapter)); |
| 3895 | sta_ctx = &adapter->session.station; |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 3896 | qdf_mem_set(sta_ctx->conn_info.sta_id, |
| 3897 | sizeof(sta_ctx->conn_info.sta_id), |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3898 | HDD_WLAN_INVALID_STA_ID); |
| 3899 | adapter->dev = dev; |
| 3900 | adapter->hdd_ctx = hdd_ctx; |
| 3901 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 3902 | adapter->vdev_id = WLAN_UMAC_VDEV_ID_MAX; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3903 | |
| 3904 | qdf_status = qdf_event_create(&adapter->qdf_session_open_event); |
| 3905 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3906 | goto free_net_dev; |
| 3907 | |
| 3908 | qdf_status = qdf_event_create(&adapter->qdf_session_close_event); |
| 3909 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3910 | goto free_net_dev; |
| 3911 | |
| 3912 | adapter->offloads_configured = false; |
| 3913 | adapter->is_link_up_service_needed = false; |
| 3914 | adapter->disconnection_in_progress = false; |
| 3915 | adapter->send_mode_change = true; |
| 3916 | |
| 3917 | /* Init the net_device structure */ |
| 3918 | strlcpy(dev->name, name, IFNAMSIZ); |
| 3919 | |
| 3920 | qdf_mem_copy(dev->dev_addr, mac_addr, sizeof(tSirMacAddr)); |
| 3921 | qdf_mem_copy(adapter->mac_addr.bytes, mac_addr, sizeof(tSirMacAddr)); |
| 3922 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 3923 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3924 | hdd_set_station_ops(adapter->dev); |
| 3925 | |
| 3926 | hdd_dev_setup_destructor(dev); |
| 3927 | dev->ieee80211_ptr = &adapter->wdev; |
| 3928 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
| 3929 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 3930 | adapter->wdev.netdev = dev; |
| 3931 | |
| 3932 | /* set dev's parent to underlying device */ |
| 3933 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
| 3934 | hdd_wmm_init(adapter); |
| 3935 | spin_lock_init(&adapter->pause_map_lock); |
| 3936 | adapter->start_time = qdf_system_ticks(); |
| 3937 | adapter->last_time = adapter->start_time; |
| 3938 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3939 | return adapter; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3940 | |
| 3941 | free_net_dev: |
| 3942 | free_netdev(adapter->dev); |
| 3943 | |
| 3944 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3945 | } |
| 3946 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3947 | 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] | 3948 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3949 | struct net_device *dev = adapter->dev; |
| 3950 | int ret; |
| 3951 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3952 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3953 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3954 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3955 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3956 | |
| 3957 | ret = dev_alloc_name(dev, dev->name); |
| 3958 | if (ret < 0) { |
| 3959 | hdd_err( |
| 3960 | "unable to get dev name: %s, err = 0x%x", |
| 3961 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3962 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3963 | } |
| 3964 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3965 | |
| 3966 | ret = register_netdevice(dev); |
| 3967 | if (ret) { |
| 3968 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3969 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3970 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3971 | } |
| 3972 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3973 | ret = register_netdev(dev); |
| 3974 | if (ret) { |
| 3975 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3976 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3977 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3978 | } |
| 3979 | } |
| 3980 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3981 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3982 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3983 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3984 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3985 | } |
| 3986 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3987 | QDF_STATUS hdd_sme_open_session_callback(uint8_t vdev_id, |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3988 | QDF_STATUS qdf_status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3989 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3990 | struct hdd_adapter *adapter; |
| 3991 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3992 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3993 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3994 | if (!hdd_ctx) { |
| 3995 | hdd_err("Invalid HDD_CTX"); |
| 3996 | return QDF_STATUS_E_FAILURE; |
| 3997 | } |
| 3998 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3999 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 4000 | if (!adapter) { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 4001 | hdd_err("NULL adapter for %d", vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4002 | return QDF_STATUS_E_INVAL; |
| 4003 | } |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 4004 | |
| 4005 | if (qdf_status == QDF_STATUS_SUCCESS) |
| 4006 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4007 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4008 | qdf_event_set(&adapter->qdf_session_open_event); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4009 | hdd_debug("session %d opened", adapter->vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4010 | |
| 4011 | return QDF_STATUS_SUCCESS; |
| 4012 | } |
| 4013 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 4014 | QDF_STATUS hdd_sme_close_session_callback(uint8_t vdev_id) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4015 | { |
| 4016 | struct hdd_adapter *adapter; |
| 4017 | struct hdd_context *hdd_ctx; |
| 4018 | |
| 4019 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4020 | if (!hdd_ctx) { |
| 4021 | hdd_err("Invalid HDD_CTX"); |
| 4022 | return QDF_STATUS_E_FAILURE; |
| 4023 | } |
| 4024 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 4025 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 4026 | if (!adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4027 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4028 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4029 | } |
| 4030 | |
| 4031 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4032 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4033 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4034 | } |
| 4035 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4036 | /* |
| 4037 | * For NAN Data interface, the close session results in the final |
| 4038 | * indication to the userspace |
| 4039 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 4040 | if (adapter->device_mode == QDF_NDI_MODE) |
| 4041 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4042 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4043 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4044 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4045 | /* |
| 4046 | * We can be blocked while waiting for scheduled work to be |
| 4047 | * flushed, and the adapter structure can potentially be freed, in |
| 4048 | * which case the magic will have been reset. So make sure the |
| 4049 | * magic is still good, and hence the adapter structure is still |
| 4050 | * valid, before signaling completion |
| 4051 | */ |
| 4052 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4053 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4054 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4055 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4056 | } |
| 4057 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4058 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4059 | { |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4060 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4061 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4062 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4063 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4064 | if (!vdev) |
| 4065 | return -EINVAL; |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4066 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4067 | status = pmo_vdev_ready(vdev); |
| 4068 | if (QDF_IS_STATUS_ERROR(status)) { |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4069 | hdd_objmgr_put_vdev(vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4070 | return qdf_status_to_os_return(status); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4071 | } |
| 4072 | |
| 4073 | status = ucfg_reg_11d_vdev_created_update(vdev); |
| 4074 | if (QDF_IS_STATUS_ERROR(status)) { |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4075 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4076 | return qdf_status_to_os_return(status); |
| 4077 | } |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4078 | |
| 4079 | if (wma_capability_enhanced_mcast_filter()) |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4080 | status = ucfg_pmo_enhanced_mc_filter_enable(vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4081 | else |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4082 | status = ucfg_pmo_enhanced_mc_filter_disable(vdev); |
| 4083 | |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4084 | hdd_objmgr_put_vdev(vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4085 | |
| 4086 | return qdf_status_to_os_return(status); |
| 4087 | } |
| 4088 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4089 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4090 | { |
| 4091 | QDF_STATUS status; |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4092 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4093 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4094 | uint8_t vdev_id; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4095 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4096 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4097 | vdev_id = adapter->vdev_id; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4098 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4099 | |
| 4100 | /* vdev created sanity check */ |
| 4101 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4102 | hdd_err("vdev %u does not exist", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4103 | return -EINVAL; |
| 4104 | } |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4105 | |
Abhishek Singh | 628bb6f | 2019-03-26 14:52:40 +0530 | [diff] [blame] | 4106 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4107 | |
| 4108 | /* |
| 4109 | * if this is the last active connection check & stop the |
| 4110 | * opportunistic timer first |
| 4111 | */ |
| 4112 | if ((policy_mgr_get_connection_count(hdd_ctx->psoc) == 1 && |
| 4113 | policy_mgr_mode_specific_connection_count(hdd_ctx->psoc, |
| 4114 | policy_mgr_convert_device_mode_to_qdf_type( |
| 4115 | adapter->device_mode), NULL) == 1) || |
| 4116 | !policy_mgr_get_connection_count(hdd_ctx->psoc)) |
| 4117 | policy_mgr_check_and_stop_opportunistic_timer(hdd_ctx->psoc, |
| 4118 | adapter->vdev_id); |
| 4119 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4120 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4121 | if (!vdev) |
| 4122 | return -EINVAL; |
Ashish Kumar Dhanotiya | 68ee2e4 | 2018-11-19 21:15:14 +0530 | [diff] [blame] | 4123 | |
| 4124 | ucfg_pmo_del_wow_pattern(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4125 | status = ucfg_reg_11d_vdev_delete_update(vdev); |
Abhishek Singh | 935e477 | 2018-11-21 14:14:10 +0530 | [diff] [blame] | 4126 | ucfg_scan_vdev_set_disable(vdev, REASON_VDEV_DOWN); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4127 | hdd_objmgr_put_vdev(vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4128 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4129 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4130 | qdf_event_reset(&adapter->qdf_session_close_event); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4131 | status = sme_close_session(hdd_ctx->mac_handle, adapter->vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4132 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4133 | hdd_err("failed to close sme session; status:%d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4134 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4135 | } |
| 4136 | |
| 4137 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4138 | status = qdf_wait_for_event_completion( |
| 4139 | &adapter->qdf_session_close_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4140 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4141 | |
| 4142 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4143 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4144 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4145 | if (adapter->device_mode == QDF_NDI_MODE) |
| 4146 | hdd_ndp_session_end_handler(adapter); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4147 | |
| 4148 | if (status == QDF_STATUS_E_TIMEOUT) |
| 4149 | hdd_err("timed out waiting for sme close session"); |
| 4150 | else if (adapter->qdf_session_close_event.force_set) |
| 4151 | hdd_info("SSR occurred during sme close session"); |
| 4152 | else |
| 4153 | hdd_err("failed to wait for sme close session; status:%u", |
| 4154 | status); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4155 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4156 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4157 | release_vdev: |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4158 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4159 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4160 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4161 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4162 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4163 | return errno; |
| 4164 | } |
| 4165 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4166 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4167 | |
| 4168 | return 0; |
| 4169 | } |
| 4170 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4171 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 4172 | struct sme_session_params *session_param, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4173 | csr_roam_complete_cb callback, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4174 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4175 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4176 | uint32_t type; |
| 4177 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4178 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4179 | |
| 4180 | /* determine vdev (sub)type */ |
| 4181 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4182 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4183 | hdd_err("failed to get vdev type: %d", status); |
| 4184 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4185 | } |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4186 | session_param->sme_session_id = adapter->vdev_id; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4187 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 4188 | session_param->type_of_persona = type; |
| 4189 | session_param->subtype_of_persona = sub_type; |
| 4190 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 4191 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 4192 | session_param->callback = callback; |
| 4193 | session_param->callback_ctx = callback_ctx; |
| 4194 | |
| 4195 | return 0; |
| 4196 | } |
| 4197 | |
gaurank kathpalia | 6c4b50c | 2019-02-28 14:07:48 +0530 | [diff] [blame] | 4198 | void |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4199 | hdd_store_nss_chains_cfg_in_vdev(struct hdd_adapter *adapter) |
| 4200 | { |
| 4201 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 4202 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4203 | |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4204 | /* Populate the nss chain params from ini for this vdev type */ |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4205 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 4206 | adapter->device_mode, |
| 4207 | hdd_ctx->num_rf_chains); |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4208 | |
| 4209 | /* Store the nss chain config into the vdev */ |
| 4210 | sme_store_nss_chains_cfg_in_vdev(adapter->vdev, &vdev_ini_cfg); |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4211 | } |
gaurank kathpalia | 6982d47 | 2018-10-31 21:54:15 +0530 | [diff] [blame] | 4212 | |
| 4213 | bool hdd_is_vdev_in_conn_state(struct hdd_adapter *adapter) |
| 4214 | { |
| 4215 | switch (adapter->device_mode) { |
| 4216 | case QDF_STA_MODE: |
| 4217 | case QDF_P2P_CLIENT_MODE: |
| 4218 | case QDF_P2P_DEVICE_MODE: |
| 4219 | return hdd_conn_is_connected( |
| 4220 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)); |
| 4221 | case QDF_SAP_MODE: |
| 4222 | case QDF_P2P_GO_MODE: |
| 4223 | return (test_bit(SOFTAP_BSS_STARTED, |
| 4224 | &adapter->event_flags)); |
| 4225 | default: |
| 4226 | hdd_err("Device mode %d invalid", adapter->device_mode); |
| 4227 | return 0; |
| 4228 | } |
| 4229 | |
| 4230 | return 0; |
| 4231 | } |
| 4232 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4233 | int hdd_vdev_create(struct hdd_adapter *adapter, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4234 | csr_roam_complete_cb callback, void *ctx) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4235 | { |
| 4236 | QDF_STATUS status; |
| 4237 | int errno; |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4238 | bool bval; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4239 | struct hdd_context *hdd_ctx; |
| 4240 | struct sme_session_params sme_session_params = {0}; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4241 | struct wlan_objmgr_vdev *vdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4242 | |
| 4243 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4244 | |
| 4245 | /* do vdev create via objmgr */ |
| 4246 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 4247 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4248 | if (errno) { |
| 4249 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 4250 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4251 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4252 | |
| 4253 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4254 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 4255 | if (QDF_STATUS_SUCCESS != status) { |
| 4256 | hdd_err("failed to reinit session open event"); |
| 4257 | return -EINVAL; |
| 4258 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4259 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 4260 | callback, ctx); |
| 4261 | if (errno) { |
| 4262 | hdd_err("failed to populating SME params"); |
| 4263 | goto objmgr_vdev_destroy_procedure; |
| 4264 | } |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4265 | status = sme_open_session(hdd_ctx->mac_handle, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4266 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4267 | hdd_err("failed to open sme session: %d", status); |
| 4268 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4269 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4270 | } |
| 4271 | |
| 4272 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4273 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4274 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4275 | if (QDF_STATUS_SUCCESS != status) { |
| 4276 | if (adapter->qdf_session_open_event.force_set) { |
| 4277 | /* |
| 4278 | * SSR/PDR has caused shutdown, which has forcefully |
| 4279 | * set the event. Return without the closing session. |
| 4280 | */ |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 4281 | adapter->vdev_id = WLAN_UMAC_VDEV_ID_MAX; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4282 | hdd_err("Session open event forcefully set"); |
| 4283 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4284 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 4285 | |
| 4286 | if (QDF_STATUS_E_TIMEOUT == status) |
| 4287 | hdd_err("Session failed to open within timeout period"); |
| 4288 | else |
| 4289 | hdd_err("Failed to wait for session open event(status-%d)", |
| 4290 | status); |
| 4291 | errno = -ETIMEDOUT; |
| 4292 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4293 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4294 | } |
| 4295 | |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 4296 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 4297 | hdd_err("Session failed to open due to vdev create failure"); |
| 4298 | errno = -EINVAL; |
| 4299 | goto objmgr_vdev_destroy_procedure; |
| 4300 | } |
| 4301 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4302 | /* firmware ready for component communication, raise vdev_ready event */ |
| 4303 | errno = hdd_vdev_ready(adapter); |
| 4304 | if (errno) { |
| 4305 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4306 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4307 | } |
| 4308 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4309 | if (adapter->device_mode == QDF_STA_MODE) { |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4310 | bval = false; |
| 4311 | status = ucfg_mlme_get_rtt_mac_randomization(hdd_ctx->psoc, |
| 4312 | &bval); |
| 4313 | if (QDF_IS_STATUS_ERROR(status)) |
| 4314 | hdd_err("unable to get RTT MAC randomization value"); |
| 4315 | |
| 4316 | hdd_debug("setting RTT mac randomization param: %d", bval); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4317 | errno = sme_cli_set_command(adapter->vdev_id, |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4318 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4319 | bval, |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4320 | VDEV_CMD); |
| 4321 | if (0 != errno) |
| 4322 | hdd_err("RTT mac randomization param set failed %d", |
| 4323 | errno); |
| 4324 | } |
| 4325 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4326 | if (adapter->device_mode == QDF_STA_MODE || |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4327 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
| 4328 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4329 | if (!vdev) |
| 4330 | goto hdd_vdev_destroy_procedure; |
| 4331 | 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] | 4332 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4333 | } |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4334 | |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4335 | hdd_store_nss_chains_cfg_in_vdev(adapter); |
| 4336 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4337 | hdd_info("vdev %d created successfully", adapter->vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4338 | |
| 4339 | return 0; |
| 4340 | |
| 4341 | /* |
| 4342 | * Due to legacy constraints, we need to destroy in the same order as |
| 4343 | * create. So, split error handling into 2 cases to accommodate. |
| 4344 | */ |
| 4345 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4346 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4347 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4348 | |
| 4349 | return errno; |
| 4350 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4351 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4352 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 4353 | |
| 4354 | return errno; |
| 4355 | } |
| 4356 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4357 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4358 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4359 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4360 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4361 | QDF_STATUS status; |
| 4362 | int ret_val; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4363 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4364 | bool bval = false; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4365 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4366 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4367 | mac_handle = hdd_ctx->mac_handle; |
| 4368 | sme_set_curr_device_mode(mac_handle, adapter->device_mode); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4369 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4370 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4371 | hdd_err("unable to get vht_enable2x2"); |
| 4372 | sme_set_pdev_ht_vht_ies(mac_handle, bval); |
| 4373 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4374 | sme_set_vdev_ies_per_band(mac_handle, adapter->vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4375 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 4376 | hdd_roam_profile_init(adapter); |
| 4377 | hdd_register_wext(adapter->dev); |
| 4378 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4379 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4380 | |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 4381 | qdf_mem_set(sta_ctx->conn_info.sta_id, |
| 4382 | sizeof(sta_ctx->conn_info.sta_id), |
| 4383 | HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4384 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4385 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4386 | status = sme_config_fast_roaming(mac_handle, adapter->vdev_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4387 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4388 | /* Set the default operation channel */ |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 4389 | sta_ctx->conn_info.channel = |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 4390 | hdd_ctx->config->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4391 | |
| 4392 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 4393 | sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4394 | |
| 4395 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4396 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4397 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4398 | status, status); |
| 4399 | goto error_init_txrx; |
| 4400 | } |
| 4401 | |
| 4402 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4403 | |
| 4404 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4405 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4406 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4407 | status, status); |
| 4408 | goto error_wmm_init; |
| 4409 | } |
| 4410 | |
| 4411 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4412 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4413 | ret_val = sme_cli_set_command(adapter->vdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4414 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4415 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4416 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4417 | if (ret_val) |
| 4418 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4419 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4420 | /* |
| 4421 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4422 | * during that time, then as part of SSR init, do not enable |
| 4423 | * the LRO again. Keep the LRO state same as before SSR. |
| 4424 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 4425 | if (cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 4426 | cfg_dp_lro_enable) && |
| 4427 | !(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4428 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4429 | |
Rakshith Suresh Patkar | 9f5c586 | 2019-02-04 16:23:02 +0530 | [diff] [blame] | 4430 | if (cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 4431 | cfg_dp_enable_ip_tcp_udp_checksum_offload)) |
| 4432 | adapter->dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 4433 | adapter->dev->features |= NETIF_F_RXCSUM; |
| 4434 | |
| 4435 | hdd_set_tso_flags(hdd_ctx, adapter->dev); |
| 4436 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4437 | /* rcpi info initialization */ |
| 4438 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4439 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4440 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4441 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4442 | error_wmm_init: |
| 4443 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4444 | hdd_deinit_tx_rx(adapter); |
| 4445 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4446 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4447 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4448 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4449 | return status; |
| 4450 | } |
| 4451 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4452 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4453 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4454 | * @hdd_ctx: global hdd context |
| 4455 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4456 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4457 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4458 | * |
| 4459 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4460 | * |
| 4461 | * Return: None. |
| 4462 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4463 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4464 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4465 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4466 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4467 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4468 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4469 | if (adapter->dev) { |
| 4470 | if (rtnl_held) |
| 4471 | adapter->dev->wireless_handlers = NULL; |
| 4472 | else { |
| 4473 | rtnl_lock(); |
| 4474 | adapter->dev->wireless_handlers = NULL; |
| 4475 | rtnl_unlock(); |
| 4476 | } |
| 4477 | } |
| 4478 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4479 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4480 | hdd_deinit_tx_rx(adapter); |
| 4481 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4482 | } |
| 4483 | |
| 4484 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4485 | hdd_wmm_adapter_close(adapter); |
| 4486 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4487 | } |
| 4488 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4489 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4490 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4491 | } |
| 4492 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4493 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4494 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4495 | bool rtnl_held) |
| 4496 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4497 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4498 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4499 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4500 | case QDF_STA_MODE: |
| 4501 | case QDF_P2P_CLIENT_MODE: |
| 4502 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4503 | case QDF_IBSS_MODE: |
| 4504 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4505 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4506 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4507 | break; |
| 4508 | } |
| 4509 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4510 | case QDF_SAP_MODE: |
| 4511 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4512 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4513 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4514 | break; |
| 4515 | } |
| 4516 | |
| 4517 | default: |
| 4518 | break; |
| 4519 | } |
| 4520 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4521 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4522 | } |
| 4523 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4524 | static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx, |
| 4525 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4526 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4527 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4528 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4529 | |
| 4530 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4531 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4532 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4533 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4534 | return; |
| 4535 | } |
| 4536 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4537 | hdd_nud_deinit_tracking(adapter); |
| 4538 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4539 | hdd_apf_context_destroy(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4540 | qdf_spinlock_destroy(&adapter->vdev_lock); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4541 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4542 | wlan_hdd_debugfs_csr_deinit(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 4543 | if (adapter->device_mode == QDF_STA_MODE) |
| 4544 | hdd_sysfs_destroy_adapter_root_obj(adapter); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4545 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4546 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4547 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4548 | /* |
| 4549 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4550 | * the driver is almost closed and cannot handle either control |
| 4551 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4552 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4553 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4554 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4555 | * the interface is closed and restricts any operations on that |
| 4556 | */ |
| 4557 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4558 | |
| 4559 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4560 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4561 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4562 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4563 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4564 | /* |
| 4565 | * Note that the adapter is no longer valid at this point |
| 4566 | * since the memory has been reclaimed |
| 4567 | */ |
| 4568 | } |
| 4569 | } |
| 4570 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4571 | 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] | 4572 | tSirMacAddr mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4573 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4574 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4575 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4576 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4577 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 4578 | mac_addr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4579 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4580 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4581 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4582 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4583 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4584 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4585 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4586 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4587 | /** |
| 4588 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4589 | * @hdd_ctx: HDD Context |
| 4590 | * @adapter: HDD Adapter |
| 4591 | * |
| 4592 | * This function set the FW Debug log level based on the INI. |
| 4593 | * |
| 4594 | * Return: None |
| 4595 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4596 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4597 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4598 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4599 | QDF_STATUS status; |
| 4600 | uint16_t enable_fw_log_level, enable_fw_log_type; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4601 | int ret; |
| 4602 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4603 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4604 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4605 | 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] | 4606 | return; |
| 4607 | } |
| 4608 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4609 | /* Enable FW logs based on INI configuration */ |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4610 | status = ucfg_fwol_get_enable_fw_log_type(hdd_ctx->psoc, |
| 4611 | &enable_fw_log_type); |
| 4612 | if (QDF_IS_STATUS_ERROR(status)) |
| 4613 | return; |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4614 | ret = sme_cli_set_command(adapter->vdev_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4615 | WMI_DBGLOG_TYPE, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4616 | enable_fw_log_type, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4617 | DBG_CMD); |
| 4618 | if (ret != 0) |
| 4619 | hdd_err("Failed to enable FW log type ret %d", |
| 4620 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4621 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4622 | status = ucfg_fwol_get_enable_fw_log_level(hdd_ctx->psoc, |
| 4623 | &enable_fw_log_level); |
| 4624 | if (QDF_IS_STATUS_ERROR(status)) |
| 4625 | return; |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4626 | ret = sme_cli_set_command(adapter->vdev_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4627 | WMI_DBGLOG_LOG_LEVEL, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4628 | enable_fw_log_level, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4629 | DBG_CMD); |
| 4630 | if (ret != 0) |
| 4631 | hdd_err("Failed to enable FW log level ret %d", |
| 4632 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4633 | |
lifeng | faa83cb | 2018-11-24 01:53:56 +0800 | [diff] [blame] | 4634 | sme_enable_fw_module_log_level(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4635 | adapter->vdev_id); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4636 | } |
| 4637 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4638 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4639 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4640 | { |
| 4641 | } |
| 4642 | |
| 4643 | #endif |
| 4644 | |
| 4645 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4646 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4647 | * @adapter: HDD adapter |
| 4648 | * |
| 4649 | * Return: 0 on success or errno on failure |
| 4650 | */ |
| 4651 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4652 | { |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4653 | QDF_STATUS status; |
| 4654 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4655 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4656 | bool enable2x2 = false, enable_bt_chain_sep = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4657 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
| 4658 | |
| 4659 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 4660 | &dual_mac_feature); |
| 4661 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4662 | hdd_err("unable to get dual mac feature"); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4663 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4664 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &enable2x2); |
| 4665 | if (QDF_IS_STATUS_ERROR(status)) |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4666 | hdd_err("unable to get vht_enable2x2"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4667 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4668 | status = ucfg_mlme_get_bt_chain_separation_flag(hdd_ctx->psoc, |
| 4669 | &enable_bt_chain_sep); |
| 4670 | if (QDF_IS_STATUS_ERROR(status)) |
| 4671 | hdd_debug("unable to get BT chain separation. using default"); |
| 4672 | |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4673 | hdd_debug("enable2x2: %d, lte_coex: %d, disable_DBS: %d", |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4674 | enable2x2, hdd_ctx->lte_coex_ant_share, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4675 | dual_mac_feature); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4676 | hdd_debug("enable_bt_chain_separation %d", enable_bt_chain_sep); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4677 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4678 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4679 | HW_MODE_DBS_NONE, |
| 4680 | CDS_BAND_ALL); |
| 4681 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4682 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4683 | return qdf_status_to_os_return(status); |
| 4684 | } |
| 4685 | |
| 4686 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4687 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4688 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4689 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4690 | hdd_debug("firmware not capable. skip chain mask programming"); |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4691 | return 0; |
| 4692 | } |
| 4693 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4694 | if (enable2x2 && !enable_bt_chain_sep) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4695 | hdd_debug("2x2 enabled. skip chain mask programming"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4696 | return 0; |
| 4697 | } |
| 4698 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4699 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4700 | hdd_debug("DBS enabled(%d). skip chain mask programming", |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4701 | dual_mac_feature); |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4702 | return 0; |
| 4703 | } |
| 4704 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4705 | if (hdd_ctx->lte_coex_ant_share) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4706 | hdd_debug("lte ant sharing enabled. skip chainmask programming"); |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4707 | return 0; |
| 4708 | } |
| 4709 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4710 | status = ucfg_mlme_configure_chain_mask(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4711 | adapter->vdev_id); |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4712 | if (status != QDF_STATUS_SUCCESS) |
| 4713 | goto error; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4714 | |
| 4715 | return 0; |
| 4716 | |
| 4717 | error: |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4718 | hdd_err("WMI PDEV set param failed"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4719 | return -EINVAL; |
| 4720 | } |
| 4721 | |
| 4722 | /** |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4723 | * hdd_send_coex_config_params() - Send coex config params to FW |
| 4724 | * @hdd_ctx: HDD context |
| 4725 | * @adapter: Primary adapter context |
| 4726 | * |
| 4727 | * This function is used to send all coex config related params to FW |
| 4728 | * |
| 4729 | * Return: 0 on success and -EINVAL on failure |
| 4730 | */ |
| 4731 | static int hdd_send_coex_config_params(struct hdd_context *hdd_ctx, |
| 4732 | struct hdd_adapter *adapter) |
| 4733 | { |
| 4734 | struct coex_config_params coex_cfg_params = {0}; |
| 4735 | struct wlan_fwol_coex_config config = {0}; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 4736 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4737 | QDF_STATUS status; |
| 4738 | |
| 4739 | if (!hdd_ctx) { |
| 4740 | hdd_err("hdd_ctx is invalid"); |
| 4741 | goto err; |
| 4742 | } |
| 4743 | |
| 4744 | if (!adapter) { |
| 4745 | hdd_err("adapter is invalid"); |
| 4746 | goto err; |
| 4747 | } |
| 4748 | |
| 4749 | if (!psoc) { |
| 4750 | hdd_err("HDD psoc is invalid"); |
| 4751 | goto err; |
| 4752 | } |
| 4753 | |
| 4754 | status = ucfg_fwol_get_coex_config_params(psoc, &config); |
| 4755 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4756 | hdd_err("Unable to get coex config params"); |
| 4757 | goto err; |
| 4758 | } |
| 4759 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4760 | coex_cfg_params.vdev_id = adapter->vdev_id; |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4761 | coex_cfg_params.config_type = WMI_COEX_CONFIG_TX_POWER; |
| 4762 | coex_cfg_params.config_arg1 = config.max_tx_power_for_btc; |
| 4763 | |
| 4764 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4765 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4766 | hdd_err("Failed to send coex Tx power"); |
| 4767 | goto err; |
| 4768 | } |
| 4769 | |
| 4770 | coex_cfg_params.config_type = WMI_COEX_CONFIG_HANDOVER_RSSI; |
| 4771 | coex_cfg_params.config_arg1 = config.wlan_low_rssi_threshold; |
| 4772 | |
| 4773 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4774 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4775 | hdd_err("Failed to send coex handover RSSI"); |
| 4776 | goto err; |
| 4777 | } |
| 4778 | |
| 4779 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BTC_MODE; |
| 4780 | coex_cfg_params.config_arg1 = config.btc_mode; |
| 4781 | |
| 4782 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4783 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4784 | hdd_err("Failed to send coex BTC mode"); |
| 4785 | goto err; |
| 4786 | } |
| 4787 | |
| 4788 | coex_cfg_params.config_type = WMI_COEX_CONFIG_ANTENNA_ISOLATION; |
| 4789 | coex_cfg_params.config_arg1 = config.antenna_isolation; |
| 4790 | |
| 4791 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4792 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4793 | hdd_err("Failed to send coex antenna isolation"); |
| 4794 | goto err; |
| 4795 | } |
| 4796 | |
| 4797 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_LOW_RSSI_THRESHOLD; |
| 4798 | coex_cfg_params.config_arg1 = config.bt_low_rssi_threshold; |
| 4799 | |
| 4800 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4801 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4802 | hdd_err("Failed to send coex BT low RSSI threshold"); |
| 4803 | goto err; |
| 4804 | } |
| 4805 | |
| 4806 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_INTERFERENCE_LEVEL; |
| 4807 | coex_cfg_params.config_arg1 = config.bt_interference_low_ll; |
| 4808 | coex_cfg_params.config_arg2 = config.bt_interference_low_ul; |
| 4809 | coex_cfg_params.config_arg3 = config.bt_interference_medium_ll; |
| 4810 | coex_cfg_params.config_arg4 = config.bt_interference_medium_ul; |
| 4811 | coex_cfg_params.config_arg5 = config.bt_interference_high_ll; |
| 4812 | coex_cfg_params.config_arg6 = config.bt_interference_high_ul; |
| 4813 | |
| 4814 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4815 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4816 | hdd_err("Failed to send coex BT interference level"); |
| 4817 | goto err; |
| 4818 | } |
stonez | c9936cb | 2019-03-11 16:41:22 +0800 | [diff] [blame] | 4819 | |
| 4820 | if (wlan_hdd_mpta_helper_enable(&coex_cfg_params, &config)) |
| 4821 | goto err; |
| 4822 | |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4823 | return 0; |
| 4824 | err: |
| 4825 | return -EINVAL; |
| 4826 | } |
| 4827 | |
| 4828 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4829 | * hdd_set_fw_params() - Set parameters to firmware |
| 4830 | * @adapter: HDD adapter |
| 4831 | * |
| 4832 | * This function Sets various parameters to fw once the |
| 4833 | * adapter is started. |
| 4834 | * |
| 4835 | * Return: 0 on success or errno on failure |
| 4836 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4837 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4838 | { |
| 4839 | int ret; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4840 | uint16_t upper_brssi_thresh, lower_brssi_thresh, rts_profile; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4841 | bool enable_dtim_1chrx; |
| 4842 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4843 | struct hdd_context *hdd_ctx; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4844 | bool bval = false; |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4845 | uint8_t max_amsdu_len, enable_tx_sch_delay; |
| 4846 | uint32_t dtim_sel_diversity, enable_secondary_rate; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4847 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4848 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4849 | |
| 4850 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4851 | if (!hdd_ctx) |
| 4852 | return -EINVAL; |
| 4853 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4854 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4855 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4856 | return 0; |
| 4857 | } |
| 4858 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4859 | ret = -1; |
| 4860 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_lprx_enable(hdd_ctx->psoc, |
| 4861 | &bval))) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4862 | ret = sme_cli_set_command(adapter->vdev_id, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4863 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4864 | bval, PDEV_CMD); |
| 4865 | } |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4866 | if (ret) { |
| 4867 | hdd_err("Failed to set LPRx"); |
| 4868 | goto error; |
| 4869 | } |
| 4870 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 4871 | ucfg_mlme_get_dtim_selection_diversity(hdd_ctx->psoc, |
| 4872 | &dtim_sel_diversity); |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4873 | |
| 4874 | ret = sme_cli_set_command( |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4875 | adapter->vdev_id, |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4876 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 4877 | dtim_sel_diversity, PDEV_CMD); |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4878 | if (ret) { |
| 4879 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4880 | goto error; |
| 4881 | } |
| 4882 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4883 | ret = -1; |
| 4884 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_enable_tx_sch_delay( |
| 4885 | hdd_ctx->psoc, &enable_tx_sch_delay))) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4886 | ret = sme_cli_set_command(adapter->vdev_id, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4887 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4888 | enable_tx_sch_delay, PDEV_CMD); |
| 4889 | } |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4890 | if (ret) { |
| 4891 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4892 | goto error; |
| 4893 | } |
| 4894 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4895 | ret = -1; |
| 4896 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_enable_secondary_rate( |
| 4897 | hdd_ctx->psoc, &enable_secondary_rate))) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4898 | ret = sme_cli_set_command(adapter->vdev_id, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4899 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4900 | enable_secondary_rate, PDEV_CMD); |
| 4901 | } |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4902 | if (ret) { |
| 4903 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4904 | goto error; |
| 4905 | } |
| 4906 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4907 | if (adapter->device_mode == QDF_STA_MODE) { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4908 | status = ucfg_get_upper_brssi_thresh(hdd_ctx->psoc, |
| 4909 | &upper_brssi_thresh); |
| 4910 | if (QDF_IS_STATUS_ERROR(status)) |
| 4911 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4912 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4913 | sme_set_smps_cfg(adapter->vdev_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4914 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4915 | upper_brssi_thresh); |
| 4916 | |
| 4917 | status = ucfg_get_lower_brssi_thresh(hdd_ctx->psoc, |
| 4918 | &lower_brssi_thresh); |
| 4919 | if (QDF_IS_STATUS_ERROR(status)) |
| 4920 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4921 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4922 | sme_set_smps_cfg(adapter->vdev_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4923 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4924 | lower_brssi_thresh); |
| 4925 | |
| 4926 | status = ucfg_get_enable_dtim_1chrx(hdd_ctx->psoc, |
| 4927 | &enable_dtim_1chrx); |
| 4928 | if (QDF_IS_STATUS_ERROR(status)) |
| 4929 | return -EINVAL; |
| 4930 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4931 | sme_set_smps_cfg(adapter->vdev_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4932 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4933 | enable_dtim_1chrx); |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4934 | } |
| 4935 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4936 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4937 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4938 | hdd_err("unable to get vht_enable2x2"); |
| 4939 | |
| 4940 | if (bval) { |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4941 | hdd_debug("configuring 2x2 mode fw params"); |
| 4942 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4943 | ret = sme_set_cck_tx_fir_override(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4944 | adapter->vdev_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4945 | if (ret) { |
| 4946 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4947 | ret); |
| 4948 | goto error; |
| 4949 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4950 | |
| 4951 | if (hdd_configure_chain_mask(adapter)) |
| 4952 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4953 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4954 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4955 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4956 | hdd_debug("configuring 1x1 mode fw params"); |
| 4957 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4958 | /* |
| 4959 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4960 | * we are passing two value |
| 4961 | * as param_id << 29 | param_value. |
| 4962 | * Below param_value = 0(disable) |
| 4963 | */ |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4964 | ret = sme_cli_set_command(adapter->vdev_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4965 | WMI_STA_SMPS_PARAM_CMDID, |
| 4966 | HDD_DTIM_1CHAIN_RX_ID << |
| 4967 | HDD_SMPS_PARAM_VALUE_S, |
| 4968 | VDEV_CMD); |
| 4969 | if (ret) { |
| 4970 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4971 | goto error; |
| 4972 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4973 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4974 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4975 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4976 | |
| 4977 | if (hdd_configure_chain_mask(adapter)) |
| 4978 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4979 | } |
| 4980 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4981 | ret = sme_set_enable_mem_deep_sleep(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4982 | adapter->vdev_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4983 | if (ret) { |
| 4984 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4985 | goto error; |
| 4986 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4987 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4988 | status = ucfg_fwol_get_rts_profile(hdd_ctx->psoc, &rts_profile); |
| 4989 | if (QDF_IS_STATUS_ERROR(status)) |
| 4990 | return -EINVAL; |
| 4991 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4992 | ret = sme_cli_set_command(adapter->vdev_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4993 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4994 | rts_profile, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4995 | VDEV_CMD); |
| 4996 | if (ret) { |
| 4997 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4998 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4999 | } |
| 5000 | |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 5001 | status = ucfg_mlme_get_max_amsdu_num(hdd_ctx->psoc, &max_amsdu_len); |
| 5002 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5003 | hdd_err("Failed to get Max AMSDU Num"); |
| 5004 | goto error; |
| 5005 | } |
| 5006 | |
| 5007 | hdd_debug("SET AMSDU num %d", max_amsdu_len); |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 5008 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5009 | ret = wma_cli_set_command(adapter->vdev_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 5010 | GEN_VDEV_PARAM_AMSDU, |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 5011 | max_amsdu_len, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 5012 | GEN_CMD); |
| 5013 | if (ret != 0) { |
| 5014 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 5015 | goto error; |
| 5016 | } |
| 5017 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 5018 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 5019 | |
| 5020 | ret = hdd_send_coex_config_params(hdd_ctx, adapter); |
| 5021 | if (ret) { |
| 5022 | hdd_warn("Error initializing coex config params"); |
| 5023 | goto error; |
| 5024 | } |
| 5025 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5026 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 5027 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 5028 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5029 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 5030 | error: |
| 5031 | return -EINVAL; |
| 5032 | } |
| 5033 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5034 | /** |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5035 | * hdd_init_completion() - Initialize Completion Variables |
| 5036 | * @adapter: HDD adapter |
| 5037 | * |
| 5038 | * This function Initialize the completion variables for |
| 5039 | * a particular adapter |
| 5040 | * |
| 5041 | * Return: None |
| 5042 | */ |
| 5043 | static void hdd_init_completion(struct hdd_adapter *adapter) |
| 5044 | { |
| 5045 | init_completion(&adapter->disconnect_comp_var); |
| 5046 | init_completion(&adapter->roaming_comp_var); |
| 5047 | init_completion(&adapter->linkup_event_var); |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5048 | init_completion(&adapter->sta_authorized_event); |
| 5049 | init_completion(&adapter->offchannel_tx_event); |
| 5050 | init_completion(&adapter->tx_action_cnf_event); |
| 5051 | init_completion(&adapter->ibss_peer_info_comp); |
| 5052 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
| 5053 | } |
| 5054 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5055 | static void hdd_reset_locally_admin_bit(struct hdd_context *hdd_ctx, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5056 | tSirMacAddr mac_addr) |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5057 | { |
| 5058 | int i; |
| 5059 | /* |
| 5060 | * Reset locally administered bit for dynamic_mac_list |
| 5061 | * also as while releasing the MAC address for any |
| 5062 | * interface mac will be compared with dynamic mac list |
| 5063 | */ |
| 5064 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
| 5065 | if (!qdf_mem_cmp( |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5066 | mac_addr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5067 | &hdd_ctx-> |
| 5068 | dynamic_mac_list[i].dynamic_mac.bytes[0], |
| 5069 | sizeof(struct qdf_mac_addr))) { |
| 5070 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT( |
| 5071 | hdd_ctx-> |
| 5072 | dynamic_mac_list[i].dynamic_mac.bytes); |
| 5073 | break; |
| 5074 | } |
| 5075 | } |
| 5076 | /* |
| 5077 | * Reset locally administered bit if the device mode is |
| 5078 | * STA |
| 5079 | */ |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5080 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(mac_addr); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5081 | hdd_debug("locally administered bit reset in sta mode: " |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 5082 | QDF_MAC_ADDR_STR, QDF_MAC_ADDR_ARRAY(mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5083 | } |
| 5084 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 5085 | static void wlan_hdd_cfg80211_scan_block_cb(struct work_struct *work) |
| 5086 | { |
| 5087 | struct hdd_adapter *adapter = |
| 5088 | container_of(work, struct hdd_adapter, scan_block_work); |
| 5089 | struct osif_vdev_sync *vdev_sync; |
| 5090 | |
| 5091 | if (osif_vdev_sync_op_start(adapter->dev, &vdev_sync)) |
| 5092 | return; |
| 5093 | |
| 5094 | wlan_hdd_cfg80211_scan_block(adapter); |
| 5095 | |
| 5096 | osif_vdev_sync_op_stop(vdev_sync); |
| 5097 | } |
| 5098 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5099 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5100 | * hdd_open_adapter() - open and setup the hdd adatper |
| 5101 | * @hdd_ctx: global hdd context |
| 5102 | * @session_type: type of the interface to be created |
| 5103 | * @iface_name: User-visible name of the interface |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5104 | * @mac_addr: MAC address to assign to the interface |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5105 | * @name_assign_type: the name of assign type of the netdev |
| 5106 | * @rtnl_held: the rtnl lock hold flag |
| 5107 | * |
| 5108 | * This function open and setup the hdd adpater according to the device |
| 5109 | * type request, assign the name, the mac address assigned, and then prepared |
| 5110 | * the hdd related parameters, queue, lock and ready to start. |
| 5111 | * |
| 5112 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 5113 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5114 | 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] | 5115 | const char *iface_name, tSirMacAddr mac_addr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5116 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5117 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5118 | { |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5119 | struct net_device *ndev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5120 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5121 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5122 | |
| 5123 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 5124 | /* |
| 5125 | * Max limit reached on the number of vdevs configured by the |
| 5126 | * host. Return error |
| 5127 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5128 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 5129 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5130 | return NULL; |
| 5131 | } |
| 5132 | |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5133 | status = wlan_hdd_validate_mac_address((struct qdf_mac_addr *)mac_addr); |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5134 | if (QDF_IS_STATUS_ERROR(status)) { |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5135 | /* Not received valid mac_addr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5136 | 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] | 5137 | return NULL; |
| 5138 | } |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5139 | |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5140 | status = hdd_check_for_existing_macaddr(hdd_ctx, mac_addr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5141 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 5142 | hdd_err("Duplicate MAC addr: " QDF_MAC_ADDR_STR |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5143 | " already exists", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 5144 | QDF_MAC_ADDR_ARRAY(mac_addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5145 | return NULL; |
| 5146 | } |
| 5147 | |
| 5148 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5149 | case QDF_STA_MODE: |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5150 | if (!hdd_ctx->config->mac_provision) { |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5151 | hdd_reset_locally_admin_bit(hdd_ctx, mac_addr); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5152 | /* |
| 5153 | * After resetting locally administered bit |
| 5154 | * again check if the new mac address is already |
| 5155 | * exists. |
| 5156 | */ |
| 5157 | status = hdd_check_for_existing_macaddr(hdd_ctx, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5158 | mac_addr); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5159 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 5160 | hdd_err("Duplicate MAC addr: " QDF_MAC_ADDR_STR |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5161 | " already exists", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 5162 | QDF_MAC_ADDR_ARRAY(mac_addr)); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5163 | return NULL; |
| 5164 | } |
| 5165 | } |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 5166 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5167 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5168 | case QDF_P2P_CLIENT_MODE: |
| 5169 | case QDF_P2P_DEVICE_MODE: |
| 5170 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 5171 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5172 | case QDF_MONITOR_MODE: |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5173 | adapter = hdd_alloc_station_adapter(hdd_ctx, mac_addr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5174 | name_assign_type, |
| 5175 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5176 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5177 | if (!adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5178 | hdd_err("failed to allocate adapter for session %d", |
| 5179 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5180 | return NULL; |
| 5181 | } |
| 5182 | |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5183 | ndev = adapter->dev; |
| 5184 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5185 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5186 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5187 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5188 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5189 | else if (QDF_MONITOR_MODE == session_type) |
| 5190 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5191 | else |
| 5192 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5193 | |
| 5194 | adapter->device_mode = session_type; |
| 5195 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5196 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5197 | /* |
| 5198 | * Workqueue which gets scheduled in IPv4 notification |
| 5199 | * callback |
| 5200 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5201 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5202 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5203 | |
| 5204 | #ifdef WLAN_NS_OFFLOAD |
| 5205 | /* |
| 5206 | * Workqueue which gets scheduled in IPv6 |
| 5207 | * notification callback. |
| 5208 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5209 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5210 | hdd_ipv6_notifier_work_queue); |
| 5211 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5212 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5213 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5214 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5215 | |
| 5216 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5217 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5218 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5219 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5220 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5221 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5222 | hdd_nud_init_tracking(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 5223 | if (adapter->device_mode == QDF_STA_MODE || |
| 5224 | adapter->device_mode == QDF_P2P_DEVICE_MODE) |
| 5225 | hdd_sysfs_create_adapter_root_obj(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5226 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 5227 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 5228 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5229 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5230 | case QDF_P2P_GO_MODE: |
| 5231 | case QDF_SAP_MODE: |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5232 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, mac_addr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5233 | name_assign_type, |
| 5234 | (uint8_t *) iface_name); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5235 | if (!adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5236 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5237 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5238 | return NULL; |
| 5239 | } |
| 5240 | |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5241 | ndev = adapter->dev; |
| 5242 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5243 | adapter->wdev.iftype = |
| 5244 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5245 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5246 | NL80211_IFTYPE_P2P_GO; |
| 5247 | adapter->device_mode = session_type; |
| 5248 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 5249 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5250 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5251 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5252 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5253 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5254 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5255 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5256 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5257 | |
| 5258 | /* |
| 5259 | * Workqueue which gets scheduled in IPv4 notification |
| 5260 | * callback |
| 5261 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5262 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5263 | hdd_ipv4_notifier_work_queue); |
| 5264 | |
| 5265 | #ifdef WLAN_NS_OFFLOAD |
| 5266 | /* |
| 5267 | * Workqueue which gets scheduled in IPv6 |
| 5268 | * notification callback. |
| 5269 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5270 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5271 | hdd_ipv6_notifier_work_queue); |
| 5272 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5273 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5274 | case QDF_FTM_MODE: |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5275 | adapter = hdd_alloc_station_adapter(hdd_ctx, mac_addr, |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5276 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 5277 | iface_name); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5278 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5279 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 5280 | return NULL; |
| 5281 | } |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5282 | |
| 5283 | ndev = adapter->dev; |
| 5284 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5285 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5286 | adapter->device_mode = session_type; |
| 5287 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5288 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5289 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5290 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5291 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5292 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5293 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5294 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5295 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5296 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5297 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5298 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5299 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5300 | return NULL; |
| 5301 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5302 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5303 | qdf_spinlock_create(&adapter->vdev_lock); |
| 5304 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5305 | hdd_init_completion(adapter); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5306 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 5307 | qdf_list_create(&adapter->blocked_scan_request_q, WLAN_MAX_SCAN_COUNT); |
| 5308 | qdf_mutex_create(&adapter->blocked_scan_request_q_lock); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5309 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5310 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5311 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5312 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5313 | } |
| 5314 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5315 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5316 | if (adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5317 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5318 | adapter = NULL; |
| 5319 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5320 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5321 | return NULL; |
| 5322 | } |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 5323 | hdd_apf_context_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5324 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5325 | if (QDF_STATUS_SUCCESS == status) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5326 | policy_mgr_set_concurrency_mode(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5327 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5328 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5329 | /* Adapter successfully added. Increment the vdev count */ |
| 5330 | hdd_ctx->current_intf_count++; |
| 5331 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5332 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5333 | hdd_ctx->current_intf_count); |
| 5334 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 5335 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5336 | } |
| 5337 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 5338 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 5339 | hdd_err("Interface %s wow debug_fs init failed", |
| 5340 | netdev_name(adapter->dev)); |
| 5341 | |
| 5342 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 5343 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5344 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 5345 | if (adapter->device_mode == QDF_STA_MODE) |
| 5346 | wlan_hdd_debugfs_csr_init(adapter); |
| 5347 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5348 | return adapter; |
| 5349 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5350 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5351 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5352 | |
| 5353 | if (ndev) |
| 5354 | free_netdev(ndev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5355 | |
| 5356 | return NULL; |
| 5357 | } |
| 5358 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5359 | static void __hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5360 | struct hdd_adapter *adapter, |
| 5361 | bool rtnl_held) |
| 5362 | { |
| 5363 | qdf_list_destroy(&adapter->blocked_scan_request_q); |
| 5364 | qdf_mutex_destroy(&adapter->blocked_scan_request_q_lock); |
| 5365 | policy_mgr_clear_concurrency_mode(hdd_ctx->psoc, adapter->device_mode); |
| 5366 | |
| 5367 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5368 | |
| 5369 | if (hdd_ctx->current_intf_count != 0) |
| 5370 | hdd_ctx->current_intf_count--; |
| 5371 | } |
| 5372 | |
| 5373 | void hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5374 | struct hdd_adapter *adapter, |
| 5375 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5376 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5377 | /* |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5378 | * Stop the global bus bandwidth timer while touching the adapter list |
| 5379 | * to avoid bad memory access by the timer handler. |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5380 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5381 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5382 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5383 | hdd_remove_adapter(hdd_ctx, adapter); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5384 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5385 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5386 | /* conditionally restart the bw timer */ |
| 5387 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5388 | } |
| 5389 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5390 | 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] | 5391 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5392 | struct hdd_adapter *adapter; |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5393 | struct osif_vdev_sync *vdev_sync; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5394 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5395 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5396 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5397 | while (QDF_IS_STATUS_SUCCESS(hdd_remove_front_adapter(hdd_ctx, |
| 5398 | &adapter))) { |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5399 | vdev_sync = osif_vdev_sync_unregister(adapter->dev); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5400 | if (vdev_sync) |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5401 | osif_vdev_sync_wait_for_ops(vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5402 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5403 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
| 5404 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5405 | |
| 5406 | if (vdev_sync) |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5407 | osif_vdev_sync_destroy(vdev_sync); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5408 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5409 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5410 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5411 | } |
| 5412 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5413 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5414 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5415 | struct qdf_mac_addr *bssid = NULL; |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5416 | tSirUpdateIE update_ie; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5417 | mac_handle_t mac_handle; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5418 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5419 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5420 | case QDF_STA_MODE: |
| 5421 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5422 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5423 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5424 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 5425 | bssid = &sta_ctx->conn_info.bssid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5426 | break; |
| 5427 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5428 | case QDF_SAP_MODE: |
| 5429 | case QDF_P2P_GO_MODE: |
| 5430 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5431 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5432 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5433 | break; |
| 5434 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5435 | case QDF_FTM_MODE: |
| 5436 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5437 | default: |
| 5438 | /* |
| 5439 | * wlan_hdd_reset_prob_rspies should not have been called |
| 5440 | * for these kind of devices |
| 5441 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5442 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5443 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5444 | return; |
| 5445 | } |
| 5446 | |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5447 | qdf_copy_macaddr(&update_ie.bssid, bssid); |
| 5448 | update_ie.smeSessionId = adapter->vdev_id; |
| 5449 | update_ie.ieBufferlength = 0; |
| 5450 | update_ie.pAdditionIEBuffer = NULL; |
| 5451 | update_ie.append = true; |
| 5452 | update_ie.notify = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5453 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 5454 | if (sme_update_add_ie(mac_handle, |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5455 | &update_ie, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5456 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5457 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5458 | } |
| 5459 | } |
| 5460 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5461 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 5462 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5463 | { |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5464 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 5465 | struct hdd_station_ctx *sta_ctx; |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5466 | struct sap_context *sap_ctx; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5467 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5468 | union iwreq_data wrqu; |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5469 | tSirUpdateIE update_ie; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5470 | unsigned long rc; |
Jeff Johnson | 8f8ceb9 | 2019-03-24 08:16:55 -0700 | [diff] [blame] | 5471 | struct sap_config *sap_config; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5472 | mac_handle_t mac_handle; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5473 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5474 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5475 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5476 | |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 5477 | if (adapter->vdev_id != WLAN_UMAC_VDEV_ID_MAX) |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 5478 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5479 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5480 | hdd_nud_ignore_tracking(adapter, true); |
| 5481 | hdd_nud_reset_tracking(adapter); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5482 | hdd_nud_flush_work(adapter); |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5483 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5484 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5485 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5486 | wlan_hdd_netif_queue_control(adapter, |
| 5487 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5488 | WLAN_CONTROL_PATH); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5489 | |
| 5490 | mac_handle = hdd_ctx->mac_handle; |
| 5491 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5492 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5493 | case QDF_STA_MODE: |
| 5494 | case QDF_P2P_CLIENT_MODE: |
| 5495 | case QDF_IBSS_MODE: |
| 5496 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5497 | case QDF_NDI_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5498 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5499 | |
| 5500 | if (adapter->device_mode == QDF_NDI_MODE || |
| 5501 | hdd_conn_is_connected(sta_ctx) || |
| 5502 | hdd_is_connecting(sta_ctx)) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5503 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5504 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5505 | roam_profile = hdd_roam_profile(adapter); |
| 5506 | /* For NDI do not use roam_profile */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5507 | if (adapter->device_mode == QDF_NDI_MODE) |
| 5508 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5509 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5510 | adapter->vdev_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5511 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5512 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5513 | eCSR_BSS_TYPE_START_IBSS) |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5514 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5515 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5516 | adapter->vdev_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5517 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Abhinav Kumar | 19a7a40 | 2018-07-12 17:36:57 +0530 | [diff] [blame] | 5518 | else if (adapter->device_mode == QDF_STA_MODE) |
| 5519 | wlan_hdd_disconnect(adapter, |
| 5520 | eCSR_DISCONNECT_REASON_DEAUTH); |
| 5521 | else |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5522 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5523 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5524 | adapter->vdev_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5525 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5526 | /* success implies disconnect is queued */ |
| 5527 | if (QDF_IS_STATUS_SUCCESS(status) && |
| 5528 | adapter->device_mode != QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5529 | rc = wait_for_completion_timeout( |
| 5530 | &adapter->disconnect_comp_var, |
| 5531 | msecs_to_jiffies |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 5532 | (SME_DISCONNECT_TIMEOUT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5533 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5534 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5535 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5536 | if (QDF_IS_STATUS_ERROR(status)) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5537 | hdd_warn("failed to post disconnect"); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5538 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5539 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5540 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5541 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5542 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5543 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5544 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5545 | |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5546 | wlan_hdd_scan_abort(adapter); |
Wu Gao | 4a1ec8c | 2018-07-23 19:18:40 +0800 | [diff] [blame] | 5547 | wlan_hdd_cleanup_actionframe(adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5548 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5549 | hdd_clear_fils_connection_info(adapter); |
Ashish Kumar Dhanotiya | 3651083 | 2019-02-20 22:13:25 +0530 | [diff] [blame] | 5550 | |
Liangwei Dong | a44d55b | 2019-03-20 03:22:08 -0400 | [diff] [blame] | 5551 | status = wlan_hdd_flush_pmksa_cache(adapter); |
Ashish Kumar Dhanotiya | 3651083 | 2019-02-20 22:13:25 +0530 | [diff] [blame] | 5552 | if (QDF_IS_STATUS_ERROR(status)) |
| 5553 | hdd_err("Cannot flush PMKIDCache"); |
| 5554 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5555 | hdd_deregister_hl_netdev_fc_timer(adapter); |
| 5556 | |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5557 | hdd_deregister_tx_flow_control(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5558 | |
| 5559 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5560 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5561 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5562 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5563 | #endif |
| 5564 | #endif |
| 5565 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5566 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5567 | struct wlan_objmgr_vdev *vdev; |
| 5568 | |
| 5569 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5570 | if (vdev) { |
| 5571 | wlan_cfg80211_sched_scan_stop(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5572 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5573 | } |
| 5574 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5575 | |
Pragaspathi Thilagaraj | e6f37e0 | 2019-01-04 12:24:33 +0530 | [diff] [blame] | 5576 | /* |
| 5577 | * During vdev destroy, if any STA is in connecting state the |
| 5578 | * roam command will be in active queue and thus vdev destroy is |
| 5579 | * queued in pending queue. In case STA tries to connect to |
| 5580 | * multiple BSSID and fails to connect, due to auth/assoc |
| 5581 | * timeouts it may take more than vdev destroy time to get |
| 5582 | * completed. On vdev destroy timeout vdev is moved to logically |
| 5583 | * deleted state. Once connection is completed, vdev destroy is |
| 5584 | * activated and to release the self-peer ref count it try to |
| 5585 | * get the ref of the vdev, which fails as vdev is logically |
| 5586 | * deleted and this leads to peer ref leak. So before vdev |
| 5587 | * destroy is queued abort any STA ongoing connection to avoid |
| 5588 | * vdev destroy timeout. |
| 5589 | */ |
| 5590 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5591 | hdd_abort_ongoing_sta_connection(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5592 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5593 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5594 | break; |
| 5595 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5596 | case QDF_MONITOR_MODE: |
| 5597 | wlan_hdd_scan_abort(adapter); |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5598 | hdd_deregister_hl_netdev_fc_timer(adapter); |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5599 | hdd_deregister_tx_flow_control(adapter); |
Jinwei Chen | bdd977f | 2019-06-14 15:09:30 +0800 | [diff] [blame] | 5600 | sme_delete_mon_session(mac_handle, adapter->vdev_id); |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5601 | hdd_vdev_destroy(adapter); |
| 5602 | break; |
| 5603 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5604 | case QDF_SAP_MODE: |
Will Huang | 7049bae | 2018-08-13 17:25:02 +0800 | [diff] [blame] | 5605 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5606 | cds_flush_delayed_work(&adapter->acs_pending_work); |
| 5607 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5608 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5609 | |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5610 | wlan_hdd_scan_abort(adapter); |
gaurank kathpalia | b7a9f70 | 2019-02-15 18:09:58 +0530 | [diff] [blame] | 5611 | /* Diassociate with all the peers before stop ap post */ |
| 5612 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) |
| 5613 | wlan_hdd_del_station(adapter); |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5614 | sap_config = &adapter->session.ap.sap_config; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5615 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 5616 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 5617 | ucfg_ipa_flush(hdd_ctx->pdev); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5618 | |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5619 | /* don't flush pre-cac destroy if we are destroying pre-cac */ |
| 5620 | sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(adapter); |
| 5621 | if (!wlan_sap_is_pre_cac_context(sap_ctx)) |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5622 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5623 | |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5624 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5625 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5626 | case QDF_P2P_GO_MODE: |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5627 | cds_flush_work(&adapter->sap_stop_bss_work); |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5628 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5629 | wlan_hdd_undo_acs(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5630 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5631 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5632 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5633 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5634 | hdd_deregister_hl_netdev_fc_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5635 | hdd_deregister_tx_flow_control(adapter); |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5636 | hdd_destroy_acs_timer(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5637 | |
Pragaspathi Thilagaraj | e6f37e0 | 2019-01-04 12:24:33 +0530 | [diff] [blame] | 5638 | /** |
| 5639 | * During vdev destroy, If any STA is in connecting state the |
| 5640 | * roam command will be in active queue and thus vdev destroy is |
| 5641 | * queued in pending queue. In case STA is tries to connected to |
| 5642 | * multiple BSSID and fails to connect, due to auth/assoc |
| 5643 | * timeouts it may take more than vdev destroy time to get |
| 5644 | * completes. If vdev destroy timeout vdev is moved to logically |
| 5645 | * deleted state. Once connection is completed, vdev destroy is |
| 5646 | * activated and to release the self-peer ref count it try to |
| 5647 | * get the ref of the vdev, which fails as vdev is logically |
| 5648 | * deleted and this leads to peer ref leak. So before vdev |
| 5649 | * destroy is queued abort any STA ongoing connection to avoid |
| 5650 | * vdev destroy timeout. |
| 5651 | */ |
| 5652 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5653 | hdd_abort_ongoing_sta_connection(hdd_ctx); |
| 5654 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5655 | mutex_lock(&hdd_ctx->sap_lock); |
| 5656 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5657 | status = wlansap_stop_bss( |
| 5658 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5659 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5660 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5661 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5662 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5663 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5664 | qdf_stop_bss_event); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5665 | status = qdf_wait_for_event_completion( |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5666 | &hostapd_state->qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 5667 | SME_CMD_STOP_BSS_TIMEOUT); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5668 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5669 | hdd_err("failure waiting for wlansap_stop_bss %d", |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5670 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5671 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5672 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5673 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5674 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5675 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5676 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5677 | adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5678 | adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5679 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5680 | adapter->device_mode, |
| 5681 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5682 | |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5683 | qdf_copy_macaddr(&update_ie.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5684 | &adapter->mac_addr); |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5685 | update_ie.smeSessionId = adapter->vdev_id; |
| 5686 | update_ie.ieBufferlength = 0; |
| 5687 | update_ie.pAdditionIEBuffer = NULL; |
| 5688 | update_ie.append = false; |
| 5689 | update_ie.notify = false; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5690 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5691 | /* Probe bcn reset */ |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5692 | status = sme_update_add_ie(mac_handle, &update_ie, |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5693 | eUPDATE_IE_PROBE_BCN); |
| 5694 | if (status == QDF_STATUS_E_FAILURE) |
| 5695 | hdd_err("Could not pass PROBE_RSP_BCN to PE"); |
| 5696 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5697 | /* Assoc resp reset */ |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5698 | status = sme_update_add_ie(mac_handle, &update_ie, |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5699 | eUPDATE_IE_ASSOC_RESP); |
| 5700 | if (status == QDF_STATUS_E_FAILURE) |
| 5701 | hdd_err("Could not pass ASSOC_RSP to PE"); |
| 5702 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5703 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5704 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5705 | } |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5706 | clear_bit(SOFTAP_INIT_DONE, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5707 | qdf_mem_free(adapter->session.ap.beacon); |
| 5708 | adapter->session.ap.beacon = NULL; |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5709 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5710 | /* |
| 5711 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5712 | */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5713 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5714 | if (vdev) { |
| 5715 | if (policy_mgr_is_dnsc_set(vdev)) |
| 5716 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5717 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5718 | } |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5719 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5720 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5721 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5722 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5723 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5724 | #endif |
| 5725 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5726 | |
| 5727 | hdd_vdev_destroy(adapter); |
| 5728 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5729 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5730 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5731 | case QDF_OCB_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5732 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5733 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5734 | cds_get_context(QDF_MODULE_ID_TXRX), |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 5735 | sta_ctx->conn_info.sta_id[0]); |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5736 | hdd_deregister_hl_netdev_fc_timer(adapter); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5737 | hdd_deregister_tx_flow_control(adapter); |
| 5738 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5739 | break; |
| 5740 | default: |
| 5741 | break; |
| 5742 | } |
| 5743 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5744 | if (adapter->scan_info.default_scan_ies) { |
| 5745 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5746 | adapter->scan_info.default_scan_ies = NULL; |
| 5747 | } |
| 5748 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5749 | hdd_exit(); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5750 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5751 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5752 | } |
| 5753 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5754 | /** |
| 5755 | * hdd_deinit_all_adapters - deinit all adapters |
| 5756 | * @hdd_ctx: HDD context |
| 5757 | * @rtnl_held: True if RTNL lock held |
| 5758 | * |
| 5759 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5760 | 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] | 5761 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5762 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5763 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5764 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5765 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5766 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5767 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5768 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5769 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5770 | } |
| 5771 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5772 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5773 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5774 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5775 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5776 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5777 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5778 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5779 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5780 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5781 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5782 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5783 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5784 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5785 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5786 | } |
| 5787 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5788 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5789 | struct hdd_adapter *adapter) |
| 5790 | { |
| 5791 | switch (adapter->device_mode) { |
| 5792 | case QDF_STA_MODE: |
| 5793 | case QDF_P2P_CLIENT_MODE: |
| 5794 | case QDF_IBSS_MODE: |
| 5795 | case QDF_P2P_DEVICE_MODE: |
| 5796 | case QDF_NDI_MODE: |
| 5797 | wlan_hdd_scan_abort(adapter); |
| 5798 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5799 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5800 | struct wlan_objmgr_vdev *vdev; |
| 5801 | |
| 5802 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5803 | if (vdev) { |
| 5804 | wlan_cfg80211_sched_scan_stop(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5805 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5806 | } |
| 5807 | } |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5808 | break; |
| 5809 | case QDF_P2P_GO_MODE: |
| 5810 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5811 | break; |
| 5812 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5813 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5814 | wlan_hdd_undo_acs(adapter); |
| 5815 | break; |
| 5816 | default: |
| 5817 | break; |
| 5818 | } |
| 5819 | } |
| 5820 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5821 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5822 | /** |
| 5823 | * hdd_adapter_abort_tx_flow() - Abort the tx flow control |
| 5824 | * @pAdapter: pointer to hdd_adapter_t |
| 5825 | * |
| 5826 | * Resume tx and stop the tx flow control timer if the tx is paused |
| 5827 | * and the flow control timer is running. This function is called by |
| 5828 | * SSR to avoid the inconsistency of tx status before and after SSR. |
| 5829 | * |
| 5830 | * Return: void |
| 5831 | */ |
| 5832 | static void hdd_adapter_abort_tx_flow(struct hdd_adapter *adapter) |
| 5833 | { |
| 5834 | if (adapter->hdd_stats.tx_rx_stats.is_txflow_paused && |
| 5835 | QDF_TIMER_STATE_RUNNING == |
| 5836 | qdf_mc_timer_get_current_state( |
| 5837 | &adapter->tx_flow_control_timer)) { |
| 5838 | hdd_tx_resume_timer_expired_handler(adapter); |
| 5839 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 5840 | } |
| 5841 | } |
| 5842 | #endif |
| 5843 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5844 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5845 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5846 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5847 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 2d04461 | 2019-02-26 20:08:43 -0800 | [diff] [blame] | 5848 | struct qdf_mac_addr peer_macaddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5849 | int sta_id; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5850 | bool value; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5851 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5852 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5853 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5854 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5855 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5856 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5857 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5858 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5859 | qdf_opmode_str(adapter->device_mode), |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5860 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5861 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5862 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5863 | hdd_adapter_abort_tx_flow(adapter); |
| 5864 | #endif |
| 5865 | |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5866 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5867 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5868 | /* Stop tdls timers */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5869 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5870 | if (vdev) { |
| 5871 | hdd_notify_tdls_reset_adapter(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5872 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5873 | } |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5874 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5875 | } |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 5876 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5877 | if (value && |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5878 | adapter->device_mode == QDF_SAP_MODE) { |
| 5879 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5880 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5881 | WLAN_CONTROL_PATH); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5882 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5883 | cds_flush_delayed_work( |
| 5884 | &adapter->acs_pending_work); |
| 5885 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5886 | } |
| 5887 | |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5888 | if (test_bit(SOFTAP_BSS_STARTED, |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5889 | &adapter->event_flags)) { |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5890 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5891 | clear_bit(SOFTAP_BSS_STARTED, |
| 5892 | &adapter->event_flags); |
| 5893 | } |
| 5894 | |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5895 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5896 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5897 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5898 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5899 | } |
Nijun Gong | 104ccc7 | 2018-08-07 10:43:56 +0800 | [diff] [blame] | 5900 | /* |
| 5901 | * Clear fc flag if it was set before SSR to avoid TX queues |
| 5902 | * permanently stopped after SSR. |
| 5903 | * Here WLAN_START_ALL_NETIF_QUEUE will actually not start any |
| 5904 | * queue since it's blocked by reason WLAN_CONTROL_PATH. |
| 5905 | */ |
| 5906 | if (adapter->pause_map & (1 << WLAN_DATA_FLOW_CONTROL)) |
| 5907 | wlan_hdd_netif_queue_control(adapter, |
| 5908 | WLAN_START_ALL_NETIF_QUEUE, |
| 5909 | WLAN_DATA_FLOW_CONTROL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5910 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5911 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5912 | |
| 5913 | hdd_deinit_tx_rx(adapter); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5914 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5915 | adapter->device_mode, adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5916 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5917 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5918 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5919 | hdd_wmm_adapter_close(adapter); |
| 5920 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5921 | } |
| 5922 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5923 | if (adapter->device_mode == QDF_STA_MODE) |
| 5924 | hdd_clear_fils_connection_info(adapter); |
| 5925 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5926 | if (adapter->device_mode == QDF_SAP_MODE) { |
Jingxiang Ge | ec11359 | 2018-08-09 15:40:39 +0800 | [diff] [blame] | 5927 | wlansap_cleanup_cac_timer( |
| 5928 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5929 | /* |
| 5930 | * If adapter is SAP, set session ID to invalid |
| 5931 | * since SAP session will be cleanup during SSR. |
| 5932 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5933 | wlansap_set_invalid_session( |
| 5934 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5935 | } |
| 5936 | |
Abhishek Singh | 8f4aa18 | 2019-03-06 10:29:24 +0530 | [diff] [blame] | 5937 | /* Release vdev ref count to avoid vdev object leak */ |
| 5938 | if (adapter->device_mode == QDF_P2P_GO_MODE || |
| 5939 | adapter->device_mode == QDF_SAP_MODE) |
| 5940 | wlansap_release_vdev_ref( |
| 5941 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5942 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5943 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5944 | if (adapter->device_mode == QDF_STA_MODE || |
| 5945 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5946 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 2d04461 | 2019-02-26 20:08:43 -0800 | [diff] [blame] | 5947 | qdf_copy_macaddr(&peer_macaddr, |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 5948 | &sta_ctx->conn_info.bssid); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5949 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5950 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
Wu Gao | 6b81fc5 | 2018-05-24 19:27:27 +0800 | [diff] [blame] | 5951 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5952 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5953 | if (adapter->sta_info[sta_id].in_use) { |
| 5954 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5955 | sta_id); |
| 5956 | hdd_softap_deregister_sta(adapter, |
| 5957 | sta_id); |
| 5958 | adapter->sta_info[sta_id].in_use = 0; |
| 5959 | } |
| 5960 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5961 | } |
| 5962 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5963 | hdd_nud_ignore_tracking(adapter, true); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5964 | hdd_nud_reset_tracking(adapter); |
| 5965 | hdd_nud_flush_work(adapter); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5966 | |
| 5967 | if (adapter->device_mode != QDF_SAP_MODE && |
| 5968 | adapter->device_mode != QDF_P2P_GO_MODE && |
| 5969 | adapter->device_mode != QDF_FTM_MODE) |
| 5970 | hdd_set_disconnect_status(adapter, false); |
| 5971 | |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5972 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5973 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5974 | hdd_softap_deinit_tx_rx(adapter); |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5975 | hdd_deregister_hl_netdev_fc_timer(adapter); |
Tiger Yu | 8c38770 | 2018-07-06 16:56:42 +0800 | [diff] [blame] | 5976 | hdd_deregister_tx_flow_control(adapter); |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5977 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5978 | /* Destroy vdev which will be recreated during reinit. */ |
| 5979 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5980 | } |
| 5981 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5982 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5983 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5984 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5985 | } |
| 5986 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5987 | bool hdd_is_any_interface_open(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5988 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5989 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5990 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5991 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5992 | hdd_info("FTM mode, don't close the module"); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5993 | return true; |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5994 | } |
| 5995 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5996 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5997 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5998 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5999 | return true; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 6000 | } |
| 6001 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 6002 | return false; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 6003 | } |
| 6004 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 6005 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6006 | { |
| 6007 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 6008 | return true; |
| 6009 | else |
| 6010 | return false; |
| 6011 | } |
| 6012 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6013 | #if defined CFG80211_CONNECT_BSS || \ |
| 6014 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6015 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6016 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6017 | /** |
| 6018 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 6019 | * @timeout_reason: reason for connect timeout |
| 6020 | * |
| 6021 | * This function is used to convert host timeout |
| 6022 | * reason enum to kernel specific enum. |
| 6023 | * |
| 6024 | * Return: nl timeout enum |
| 6025 | */ |
| 6026 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 6027 | tSirResultCodes timeout_reason) |
| 6028 | { |
| 6029 | switch (timeout_reason) { |
| 6030 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 6031 | return NL80211_TIMEOUT_SCAN; |
| 6032 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 6033 | return NL80211_TIMEOUT_AUTH; |
| 6034 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 6035 | return NL80211_TIMEOUT_ASSOC; |
| 6036 | default: |
| 6037 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 6038 | } |
| 6039 | } |
| 6040 | |
| 6041 | /** |
| 6042 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 6043 | * @dev: network device |
| 6044 | * @bssid: bssid to which we want to associate |
| 6045 | * @timeout_reason: reason for connect timeout |
| 6046 | * |
| 6047 | * This API is used to send connection timeout reason to supplicant |
| 6048 | * |
| 6049 | * Return: void |
| 6050 | */ |
| 6051 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 6052 | const u8 *bssid, |
| 6053 | tSirResultCodes timeout_reason) |
| 6054 | { |
| 6055 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6056 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6057 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 6058 | |
| 6059 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 6060 | nl_timeout_reason); |
| 6061 | } |
| 6062 | |
| 6063 | /** |
| 6064 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 6065 | * @dev: network device |
| 6066 | * @bssid: bssid to which we want to associate |
| 6067 | * @req_ie: Request Information Element |
| 6068 | * @req_ie_len: len of the req IE |
| 6069 | * @resp_ie: Response IE |
| 6070 | * @resp_ie_len: len of ht response IE |
| 6071 | * @status: status |
| 6072 | * @gfp: Kernel Flag |
| 6073 | * @timeout_reason: reason for connect timeout |
| 6074 | * |
| 6075 | * Return: void |
| 6076 | */ |
| 6077 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6078 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6079 | size_t req_ie_len, const u8 *resp_ie, |
| 6080 | size_t resp_ie_len, int status, gfp_t gfp, |
| 6081 | tSirResultCodes timeout_reason) |
| 6082 | { |
| 6083 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6084 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6085 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 6086 | |
| 6087 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 6088 | resp_ie, resp_ie_len, status, gfp, |
| 6089 | nl_timeout_reason); |
| 6090 | } |
| 6091 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6092 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 6093 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6094 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 6095 | const u8 *bssid, |
| 6096 | tSirResultCodes timeout_reason) |
| 6097 | { |
| 6098 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 6099 | } |
| 6100 | #endif |
| 6101 | |
| 6102 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6103 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6104 | size_t req_ie_len, const u8 *resp_ie, |
| 6105 | size_t resp_ie_len, int status, gfp_t gfp, |
| 6106 | tSirResultCodes timeout_reason) |
| 6107 | { |
| 6108 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 6109 | resp_ie, resp_ie_len, status, gfp); |
| 6110 | } |
| 6111 | #endif |
| 6112 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6113 | /** |
| 6114 | * hdd_connect_bss() - API to send connection status to supplicant |
| 6115 | * @dev: network device |
| 6116 | * @bssid: bssid to which we want to associate |
| 6117 | * @req_ie: Request Information Element |
| 6118 | * @req_ie_len: len of the req IE |
| 6119 | * @resp_ie: Response IE |
| 6120 | * @resp_ie_len: len of ht response IE |
| 6121 | * @status: status |
| 6122 | * @gfp: Kernel Flag |
| 6123 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6124 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6125 | * |
| 6126 | * The API is a wrapper to send connection status to supplicant |
| 6127 | * |
| 6128 | * Return: Void |
| 6129 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6130 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 6131 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6132 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6133 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6134 | size_t req_ie_len, const u8 *resp_ie, |
| 6135 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6136 | bool connect_timeout, |
| 6137 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6138 | { |
| 6139 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6140 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6141 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6142 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6143 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6144 | } |
| 6145 | #else |
| 6146 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6147 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6148 | size_t req_ie_len, const u8 *resp_ie, |
| 6149 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6150 | bool connect_timeout, |
| 6151 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6152 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6153 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6154 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6155 | } |
| 6156 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6157 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6158 | #if defined(WLAN_FEATURE_FILS_SK) |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6159 | #if (defined(CFG80211_CONNECT_DONE) || \ |
| 6160 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) && \ |
| 6161 | (LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0)) |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6162 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 6163 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6164 | /** |
| 6165 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 6166 | * @fils_params: connect response to supplicant |
| 6167 | * @fils_kek: FILS kek |
| 6168 | * @fils_kek_len: FILS kek length |
| 6169 | * @pmk: FILS PMK |
| 6170 | * @pmk_len: FILS PMK length |
| 6171 | * @pmkid: PMKID |
| 6172 | * @fils_seq_num: FILS Seq number |
| 6173 | * |
| 6174 | * Return: None |
| 6175 | */ |
| 6176 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6177 | *fils_params, const uint8_t *fils_kek, |
| 6178 | size_t fils_kek_len, const uint8_t *pmk, |
| 6179 | size_t pmk_len, const uint8_t *pmkid, |
| 6180 | uint16_t fils_seq_num) |
| 6181 | { |
| 6182 | /* Increament seq number to be used for next FILS */ |
| 6183 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 6184 | fils_params->update_erp_next_seq_num = true; |
| 6185 | fils_params->fils_kek = fils_kek; |
| 6186 | fils_params->fils_kek_len = fils_kek_len; |
| 6187 | fils_params->pmk = pmk; |
| 6188 | fils_params->pmk_len = pmk_len; |
| 6189 | fils_params->pmkid = pmkid; |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6190 | hdd_debug("FILS erp_next_seq_num:%d", |
| 6191 | fils_params->fils_erp_next_seq_num); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6192 | } |
| 6193 | #else |
| 6194 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6195 | *fils_params, const uint8_t |
| 6196 | *fils_kek, size_t fils_kek_len, |
| 6197 | const uint8_t *pmk, size_t pmk_len, |
| 6198 | const uint8_t *pmkid, |
| 6199 | uint16_t fils_seq_num) |
| 6200 | { } |
| 6201 | #endif |
| 6202 | |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6203 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) |
| 6204 | /** |
| 6205 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 6206 | * @fils_params: connect response to supplicant |
| 6207 | * @fils_kek: FILS kek |
| 6208 | * @fils_kek_len: FILS kek length |
| 6209 | * @pmk: FILS PMK |
| 6210 | * @pmk_len: FILS PMK length |
| 6211 | * @pmkid: PMKID |
| 6212 | * @fils_seq_num: FILS Seq number |
| 6213 | * |
| 6214 | * Return: None |
| 6215 | */ |
| 6216 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6217 | *fils_params, const uint8_t *fils_kek, |
| 6218 | size_t fils_kek_len, const uint8_t *pmk, |
| 6219 | size_t pmk_len, const uint8_t *pmkid, |
| 6220 | uint16_t fils_seq_num) |
| 6221 | { |
| 6222 | /* Increament seq number to be used for next FILS */ |
| 6223 | fils_params->fils.erp_next_seq_num = fils_seq_num + 1; |
| 6224 | fils_params->fils.update_erp_next_seq_num = true; |
| 6225 | fils_params->fils.kek = fils_kek; |
| 6226 | fils_params->fils.kek_len = fils_kek_len; |
| 6227 | fils_params->fils.pmk = pmk; |
| 6228 | fils_params->fils.pmk_len = pmk_len; |
| 6229 | fils_params->fils.pmkid = pmkid; |
| 6230 | hdd_debug("FILS erp_next_seq_num:%d", |
| 6231 | fils_params->fils.erp_next_seq_num); |
| 6232 | } |
| 6233 | #endif /* CFG80211_CONNECT_DONE */ |
| 6234 | |
| 6235 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 6236 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 6237 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6238 | void hdd_update_hlp_info(struct net_device *dev, |
| 6239 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6240 | { |
| 6241 | struct sk_buff *skb; |
| 6242 | uint16_t skb_len; |
| 6243 | struct llc_snap_hdr_t *llc_hdr; |
| 6244 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6245 | uint8_t *hlp_data; |
| 6246 | uint16_t hlp_data_len; |
| 6247 | struct fils_join_rsp_params *roam_fils_params |
| 6248 | = roam_info->fils_join_rsp; |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6249 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6250 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6251 | if (!roam_fils_params) { |
| 6252 | hdd_err("FILS Roam Param NULL"); |
| 6253 | return; |
| 6254 | } |
| 6255 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 6256 | if (!roam_fils_params->hlp_data_len) { |
Jianmin Zhu | cc6b3d0 | 2019-03-07 14:19:34 +0800 | [diff] [blame] | 6257 | hdd_debug("FILS HLP Data NULL, len %d", |
| 6258 | roam_fils_params->hlp_data_len); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6259 | return; |
| 6260 | } |
| 6261 | |
| 6262 | hlp_data = roam_fils_params->hlp_data; |
| 6263 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 6264 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6265 | /* Calculate skb length */ |
| 6266 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 6267 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 6268 | if (!skb) { |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6269 | hdd_err("HLP packet nbuf alloc fails"); |
| 6270 | return; |
| 6271 | } |
| 6272 | |
| 6273 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 6274 | QDF_MAC_ADDR_SIZE); |
| 6275 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 6276 | QDF_MAC_ADDR_SIZE); |
| 6277 | |
| 6278 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 6279 | if (IS_SNAP(llc_hdr)) { |
| 6280 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6281 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6282 | } |
| 6283 | |
| 6284 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 6285 | |
| 6286 | /* |
| 6287 | * This HLP packet is formed from HLP info encapsulated |
| 6288 | * in assoc response frame which is AEAD encrypted. |
| 6289 | * Hence, this checksum validation can be set unnecessary. |
| 6290 | * i.e. network layer need not worry about checksum. |
| 6291 | */ |
| 6292 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 6293 | |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6294 | status = hdd_rx_packet_cbk(adapter, skb); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6295 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6296 | hdd_err("Sending HLP packet fails"); |
| 6297 | return; |
| 6298 | } |
| 6299 | hdd_debug("send HLP packet to netif successfully"); |
| 6300 | } |
| 6301 | |
| 6302 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6303 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 6304 | * @dev: network device |
| 6305 | * @bssid: bssid to which we want to associate |
| 6306 | * @bss: cfg80211 bss info |
| 6307 | * @roam_info: information about connected bss |
| 6308 | * @req_ie: Request Information Element |
| 6309 | * @req_ie_len: len of the req IE |
| 6310 | * @resp_ie: Response IE |
| 6311 | * @resp_ie_len: len of ht response IE |
| 6312 | * @status: status |
| 6313 | * @gfp: allocation flags |
| 6314 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6315 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6316 | * |
| 6317 | * This API is used as wrapper to send FILS key/sequence number |
| 6318 | * params etc. to supplicant in case of FILS connection |
| 6319 | * |
| 6320 | * Return: None |
| 6321 | */ |
| 6322 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6323 | struct cfg80211_bss *bss, |
| 6324 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6325 | const u8 *req_ie, size_t req_ie_len, |
| 6326 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6327 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6328 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6329 | { |
| 6330 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6331 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6332 | struct fils_join_rsp_params *roam_fils_params = |
| 6333 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6334 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6335 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 6336 | |
| 6337 | if (!roam_fils_params) { |
| 6338 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 6339 | } else { |
| 6340 | fils_params.status = status; |
| 6341 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 6342 | fils_params.timeout_reason = |
| 6343 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6344 | fils_params.req_ie = req_ie; |
| 6345 | fils_params.req_ie_len = req_ie_len; |
| 6346 | fils_params.resp_ie = resp_ie; |
| 6347 | fils_params.resp_ie_len = resp_ie_len; |
| 6348 | fils_params.bss = bss; |
| 6349 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 6350 | roam_fils_params->kek_len, |
| 6351 | roam_fils_params->fils_pmk, |
| 6352 | roam_fils_params->fils_pmk_len, |
| 6353 | roam_fils_params->fils_pmkid, |
| 6354 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 6355 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6356 | } |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6357 | hdd_debug("FILS indicate connect status %d", fils_params.status); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6358 | |
| 6359 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 6360 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6361 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6362 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6363 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6364 | /* Clear all the FILS key info */ |
| 6365 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 6366 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 6367 | if (roam_fils_params) |
| 6368 | qdf_mem_free(roam_fils_params); |
| 6369 | roam_info->fils_join_rsp = NULL; |
| 6370 | } |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6371 | #else /* CFG80211_CONNECT_DONE */ |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6372 | static inline void |
| 6373 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6374 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6375 | const u8 *req_ie, size_t req_ie_len, |
| 6376 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 6377 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6378 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6379 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6380 | #endif |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6381 | #endif /* WLAN_FEATURE_FILS_SK */ |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6382 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6383 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 6384 | (defined(CFG80211_CONNECT_DONE) || \ |
| 6385 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6386 | /** |
| 6387 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 6388 | * supplicant. |
| 6389 | * @dev: network device |
| 6390 | * @bssid: bssid to which we want to associate |
| 6391 | * @bss: cfg80211 bss info |
| 6392 | * @roam_info: information about connected bss |
| 6393 | * @req_ie: Request Information Element |
| 6394 | * @req_ie_len: len of the req IE |
| 6395 | * @resp_ie: Response IE |
| 6396 | * @resp_ie_len: len of ht response IE |
| 6397 | * @status: status |
| 6398 | * @gfp: allocation flags |
| 6399 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6400 | * @timeout_reason: reason for connect timeout |
| 6401 | * |
| 6402 | * The API is a wrapper to send connection status to supplicant |
| 6403 | * |
| 6404 | * Return: 0 if success else failure |
| 6405 | */ |
| 6406 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 6407 | const u8 *bssid, |
| 6408 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6409 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6410 | size_t req_ie_len, const u8 *resp_ie, |
| 6411 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6412 | bool connect_timeout, |
| 6413 | tSirResultCodes timeout_reason) |
| 6414 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6415 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6416 | if (!roam_info || !roam_info->is_fils_connection) |
| 6417 | return -EINVAL; |
| 6418 | |
| 6419 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 6420 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6421 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6422 | return 0; |
| 6423 | } |
| 6424 | #else |
| 6425 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 6426 | const u8 *bssid, |
| 6427 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6428 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6429 | size_t req_ie_len, const u8 *resp_ie, |
| 6430 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6431 | bool connect_timeout, |
| 6432 | tSirResultCodes timeout_reason) |
| 6433 | { |
| 6434 | return -EINVAL; |
| 6435 | } |
| 6436 | #endif |
| 6437 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6438 | /** |
| 6439 | * hdd_connect_result() - API to send connection status to supplicant |
| 6440 | * @dev: network device |
| 6441 | * @bssid: bssid to which we want to associate |
| 6442 | * @roam_info: information about connected bss |
| 6443 | * @req_ie: Request Information Element |
| 6444 | * @req_ie_len: len of the req IE |
| 6445 | * @resp_ie: Response IE |
| 6446 | * @resp_ie_len: len of ht response IE |
| 6447 | * @status: status |
| 6448 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6449 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6450 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6451 | * |
| 6452 | * The API is a wrapper to send connection status to supplicant |
| 6453 | * and allow runtime suspend |
| 6454 | * |
| 6455 | * Return: Void |
| 6456 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6457 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6458 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6459 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6460 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6461 | bool connect_timeout, |
| 6462 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6463 | { |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6464 | struct hdd_adapter *adapter = netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6465 | struct cfg80211_bss *bss = NULL; |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6466 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6467 | |
| 6468 | if (WLAN_STATUS_SUCCESS == status) { |
| 6469 | struct ieee80211_channel *chan; |
| 6470 | int freq; |
Pragaspathi Thilagaraj | 96742ae | 2019-05-29 00:49:33 +0530 | [diff] [blame] | 6471 | int chan_no = roam_info->bss_desc->channelId; |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6472 | |
| 6473 | if (chan_no <= 14) |
| 6474 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6475 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6476 | else |
| 6477 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6478 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6479 | |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6480 | chan = ieee80211_get_channel(adapter->wdev.wiphy, freq); |
| 6481 | bss = wlan_cfg80211_get_bss(adapter->wdev.wiphy, chan, bssid, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6482 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 6483 | roam_info->u.pConnectedProfile->SSID.length); |
| 6484 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6485 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6486 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 6487 | roam_info, req_ie, req_ie_len, resp_ie, |
| 6488 | resp_ie_len, status, gfp, connect_timeout, |
| 6489 | timeout_reason) != 0) { |
| 6490 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 6491 | req_ie_len, resp_ie, resp_ie_len, |
| 6492 | status, gfp, connect_timeout, timeout_reason); |
| 6493 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6494 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6495 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6496 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6497 | } |
| 6498 | #else |
| 6499 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6500 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6501 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6502 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6503 | bool connect_timeout, |
| 6504 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6505 | { |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6506 | struct hdd_adapter *adapter = netdev_priv(dev); |
| 6507 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6508 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6509 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 6510 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 6511 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6512 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6513 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6514 | } |
| 6515 | #endif |
| 6516 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6517 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6518 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 6519 | uint32_t bandwidth) |
| 6520 | { |
| 6521 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6522 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 6523 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 6524 | QDF_STATUS status; |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6525 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6526 | struct qdf_mac_addr bssid; |
| 6527 | struct csr_roam_profile roam_profile; |
| 6528 | struct ch_params ch_params; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6529 | eConnectionState connstate; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6530 | |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6531 | if (hdd_get_conparam() != QDF_GLOBAL_MONITOR_MODE && |
| 6532 | adapter->device_mode != QDF_STA_MODE) { |
| 6533 | 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] | 6534 | return -EINVAL; |
| 6535 | } |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6536 | if (adapter->device_mode == QDF_STA_MODE && |
Pragaspathi Thilagaraj | a889375 | 2019-02-06 19:58:59 +0530 | [diff] [blame] | 6537 | ucfg_mlme_is_change_channel_bandwidth_enabled(hdd_ctx->psoc)) { |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6538 | connstate = sta_ctx->conn_info.conn_state; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6539 | if (eConnectionState_Associated == connstate || |
| 6540 | eConnectionState_Connecting == connstate) { |
| 6541 | return -EINVAL; |
| 6542 | } |
| 6543 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6544 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 6545 | /* Validate Channel */ |
| 6546 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6547 | hdd_err("Channel %d Not supported", chan); |
| 6548 | return -EINVAL; |
| 6549 | } |
| 6550 | |
| 6551 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 6552 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 6553 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 6554 | return -EINVAL; |
| 6555 | } |
| 6556 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 6557 | (bandwidth != CH_WIDTH_MAX)) { |
| 6558 | hdd_err("Only BW20 possible on channel 14"); |
| 6559 | return -EINVAL; |
| 6560 | } |
| 6561 | } |
| 6562 | |
| 6563 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6564 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 6565 | (bandwidth != CH_WIDTH_MAX)) { |
| 6566 | hdd_err("Only BW20 possible on channel 165"); |
| 6567 | return -EINVAL; |
| 6568 | } |
| 6569 | } |
| 6570 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6571 | hdd_debug("Set monitor mode Channel %d", chan); |
| 6572 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 6573 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 6574 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 6575 | roam_profile.phyMode = ch_info->phy_mode; |
| 6576 | roam_profile.ch_params.ch_width = bandwidth; |
| 6577 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
Pragaspathi Thilagaraj | a889375 | 2019-02-06 19:58:59 +0530 | [diff] [blame] | 6578 | if (ucfg_mlme_is_change_channel_bandwidth_enabled(hdd_ctx->psoc) && |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6579 | (!sme_find_session_by_bssid(mac_handle, adapter->mac_addr.bytes))) { |
| 6580 | status = sme_create_mon_session(mac_handle, |
Rajeev Kumar Sirasanagandla | e3b5991 | 2018-08-24 15:53:31 +0530 | [diff] [blame] | 6581 | adapter->mac_addr.bytes, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6582 | adapter->vdev_id); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6583 | if (status != QDF_STATUS_SUCCESS) { |
| 6584 | hdd_err("Status: %d Failed to create session.", |
| 6585 | status); |
| 6586 | return qdf_status_to_os_return(status); |
| 6587 | } |
| 6588 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6589 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 6590 | QDF_MAC_ADDR_SIZE); |
| 6591 | |
| 6592 | ch_params.ch_width = bandwidth; |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6593 | wlan_reg_set_channel_params(hdd_ctx->pdev, chan, 0, &ch_params); |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6594 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 6595 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 6596 | return -EINVAL; |
| 6597 | } |
| 6598 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 6599 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 6600 | hdd_err("Failed to change hw mode"); |
| 6601 | return -EINVAL; |
| 6602 | } |
| 6603 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 6604 | status = sme_roam_channel_change_req(hdd_ctx->mac_handle, |
| 6605 | bssid, &ch_params, |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6606 | &roam_profile); |
| 6607 | if (status) { |
| 6608 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 6609 | status); |
| 6610 | } |
| 6611 | |
| 6612 | adapter->mon_chan = chan; |
| 6613 | adapter->mon_bandwidth = bandwidth; |
| 6614 | return qdf_status_to_os_return(status); |
| 6615 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6616 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6617 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6618 | #ifdef MSM_PLATFORM |
| 6619 | /** |
| 6620 | * hdd_stop_p2p_go() - call cfg80211 API to stop P2P GO |
| 6621 | * @adapter: pointer to adapter |
| 6622 | * |
| 6623 | * This function calls cfg80211 API to stop P2P GO |
| 6624 | * |
| 6625 | * Return: None |
| 6626 | */ |
| 6627 | static void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6628 | { |
| 6629 | hdd_debug("[SSR] send stop ap to supplicant"); |
| 6630 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 6631 | } |
| 6632 | |
| 6633 | static inline void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6634 | { |
| 6635 | } |
| 6636 | #else |
| 6637 | static inline void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6638 | { |
| 6639 | } |
| 6640 | |
| 6641 | /** |
| 6642 | * hdd_delete_sta() - call cfg80211 API to delete STA |
| 6643 | * @adapter: pointer to adapter |
| 6644 | * |
| 6645 | * This function calls cfg80211 API to delete STA |
| 6646 | * |
| 6647 | * Return: None |
| 6648 | */ |
| 6649 | static void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6650 | { |
| 6651 | struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT; |
| 6652 | |
| 6653 | hdd_debug("[SSR] send restart supplicant"); |
| 6654 | /* event supplicant to restart */ |
| 6655 | cfg80211_del_sta(adapter->dev, |
| 6656 | (const u8 *)&bcast_mac.bytes[0], |
| 6657 | GFP_KERNEL); |
| 6658 | } |
| 6659 | #endif |
| 6660 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6661 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6662 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6663 | struct hdd_adapter *adapter; |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6664 | eConnectionState conn_state; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6665 | bool value; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6666 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6667 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6668 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6669 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6670 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6671 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6672 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6673 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 6674 | qdf_opmode_str(adapter->device_mode), |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6675 | adapter->device_mode); |
| 6676 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6677 | hdd_wmm_init(adapter); |
| 6678 | |
| 6679 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6680 | case QDF_STA_MODE: |
| 6681 | case QDF_P2P_CLIENT_MODE: |
| 6682 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6683 | |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6684 | conn_state = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 6685 | ->conn_info.conn_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6686 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6687 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6688 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 6689 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6690 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6691 | /* Indicate disconnect event to supplicant |
| 6692 | * if associated previously |
| 6693 | */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6694 | if (eConnectionState_Associated == conn_state || |
| 6695 | eConnectionState_IbssConnected == conn_state || |
| 6696 | eConnectionState_NotConnected == conn_state || |
| 6697 | eConnectionState_IbssDisconnected == conn_state || |
| 6698 | eConnectionState_Disconnecting == conn_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6699 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6700 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6701 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6702 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6703 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 6704 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 6705 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 6706 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 6707 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6708 | |
| 6709 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 6710 | wlan_hdd_cfg80211_indicate_disconnect( |
| 6711 | adapter->dev, false, |
| 6712 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6713 | } else if (eConnectionState_Connecting == conn_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6714 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6715 | * Indicate connect failure to supplicant if we |
| 6716 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6717 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6718 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6719 | NULL, 0, NULL, 0, |
| 6720 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6721 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6722 | } |
| 6723 | |
| 6724 | hdd_register_tx_flow_control(adapter, |
| 6725 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6726 | hdd_tx_resume_cb, |
| 6727 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6728 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 6729 | hdd_register_hl_netdev_fc_timer( |
| 6730 | adapter, |
| 6731 | hdd_tx_resume_timer_expired_handler); |
| 6732 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 6733 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6734 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6735 | break; |
| 6736 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6737 | case QDF_SAP_MODE: |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 6738 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6739 | &value); |
| 6740 | if (value) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6741 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6742 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6743 | break; |
| 6744 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6745 | case QDF_P2P_GO_MODE: |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6746 | hdd_delete_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6747 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6748 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6749 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6750 | hdd_set_mon_rx_cb(adapter->dev); |
| 6751 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6752 | adapter->mon_bandwidth); |
| 6753 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6754 | default: |
| 6755 | break; |
| 6756 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6757 | /* |
| 6758 | * Action frame registered in one adapter which will |
| 6759 | * applicable to all interfaces |
| 6760 | */ |
| 6761 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6762 | } |
| 6763 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6764 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6765 | if (!hdd_is_interface_up(adapter)) |
| 6766 | continue; |
| 6767 | |
| 6768 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 6769 | hdd_stop_p2p_go(adapter); |
| 6770 | } |
| 6771 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6772 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6773 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6774 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6775 | } |
| 6776 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6777 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6778 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6779 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6780 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6781 | qdf_list_node_t *node; |
| 6782 | |
| 6783 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6784 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6785 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6786 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6787 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6788 | |
| 6789 | if (QDF_IS_STATUS_ERROR(status)) |
| 6790 | return status; |
| 6791 | |
| 6792 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6793 | |
| 6794 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6795 | } |
| 6796 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6797 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6798 | struct hdd_adapter *current_adapter, |
| 6799 | struct hdd_adapter **out_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; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6802 | qdf_list_node_t *node; |
| 6803 | |
| 6804 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6805 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6806 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6807 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6808 | ¤t_adapter->node, |
| 6809 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6810 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6811 | |
| 6812 | if (QDF_IS_STATUS_ERROR(status)) |
| 6813 | return status; |
| 6814 | |
| 6815 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6816 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6817 | return status; |
| 6818 | } |
| 6819 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6820 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6821 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6822 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6823 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6824 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6825 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6826 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6827 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6828 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6829 | return status; |
| 6830 | } |
| 6831 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6832 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6833 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6834 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6835 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6836 | qdf_list_node_t *node; |
| 6837 | |
| 6838 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6839 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6840 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6841 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6842 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6843 | |
| 6844 | if (QDF_IS_STATUS_ERROR(status)) |
| 6845 | return status; |
| 6846 | |
| 6847 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6848 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6849 | return status; |
| 6850 | } |
| 6851 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6852 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6853 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6854 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6855 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6856 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6857 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6858 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6859 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6860 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6861 | return status; |
| 6862 | } |
| 6863 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6864 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6865 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6866 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6867 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6868 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6869 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6870 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6871 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6872 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6873 | return status; |
| 6874 | } |
| 6875 | |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 6876 | struct hdd_adapter *hdd_get_adapter_by_rand_macaddr( |
| 6877 | struct hdd_context *hdd_ctx, tSirMacAddr mac_addr) |
| 6878 | { |
| 6879 | struct hdd_adapter *adapter; |
| 6880 | |
| 6881 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6882 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6883 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6884 | adapter->device_mode == QDF_P2P_DEVICE_MODE) && |
| 6885 | ucfg_p2p_check_random_mac(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6886 | adapter->vdev_id, mac_addr)) |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 6887 | return adapter; |
| 6888 | } |
| 6889 | |
| 6890 | return NULL; |
| 6891 | } |
| 6892 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6893 | 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] | 6894 | tSirMacAddr mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6895 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6896 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6897 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6898 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6899 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 6900 | mac_addr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6901 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6902 | } |
| 6903 | |
| 6904 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6905 | } |
| 6906 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6907 | 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] | 6908 | uint32_t vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6909 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6910 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6911 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6912 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6913 | if (adapter->vdev_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6914 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6915 | } |
| 6916 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6917 | return NULL; |
| 6918 | } |
| 6919 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6920 | 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] | 6921 | const char *iface_name) |
| 6922 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6923 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6924 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6925 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6926 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6927 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6928 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6929 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6930 | return NULL; |
| 6931 | } |
| 6932 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6933 | /** |
| 6934 | * hdd_get_adapter() - to get adapter matching the mode |
| 6935 | * @hdd_ctx: hdd context |
| 6936 | * @mode: adapter mode |
| 6937 | * |
| 6938 | * This routine will return the pointer to adapter matching |
| 6939 | * with the passed mode. |
| 6940 | * |
| 6941 | * Return: pointer to adapter or null |
| 6942 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6943 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6944 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6945 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6946 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6947 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6948 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6949 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6950 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6951 | } |
| 6952 | |
| 6953 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6954 | } |
| 6955 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 6956 | enum QDF_OPMODE hdd_get_device_mode(uint32_t vdev_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6957 | { |
| 6958 | struct hdd_context *hdd_ctx; |
| 6959 | struct hdd_adapter *adapter; |
| 6960 | |
| 6961 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6962 | if (!hdd_ctx) { |
| 6963 | hdd_err("Invalid HDD context"); |
| 6964 | return QDF_MAX_NO_OF_MODE; |
| 6965 | } |
| 6966 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 6967 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6968 | if (!adapter) { |
| 6969 | hdd_err("Invalid HDD adapter"); |
| 6970 | return QDF_MAX_NO_OF_MODE; |
| 6971 | } |
| 6972 | |
| 6973 | return adapter->device_mode; |
| 6974 | } |
| 6975 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6976 | /** |
| 6977 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6978 | * @hdd_ctx: Pointer to the HDD context. |
| 6979 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6980 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6981 | * QDF_STA_MODE, |
| 6982 | * QDF_P2P_CLIENT_MODE, |
| 6983 | * QDF_SAP_MODE, |
| 6984 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6985 | * |
| 6986 | * This API returns the operating channel of the requested device mode |
| 6987 | * |
| 6988 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6989 | * not connected. |
| 6990 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6991 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6992 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6993 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6994 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6995 | uint8_t operatingChannel = 0; |
| 6996 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6997 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6998 | if (mode == adapter->device_mode) { |
| 6999 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7000 | case QDF_STA_MODE: |
| 7001 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7002 | if (hdd_conn_is_connected |
| 7003 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 7004 | (adapter))) { |
| 7005 | operatingChannel = |
| 7006 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 7007 | (adapter))->conn_info. |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 7008 | channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7009 | } |
| 7010 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7011 | case QDF_SAP_MODE: |
| 7012 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7013 | /* softap connection info */ |
| 7014 | if (test_bit |
| 7015 | (SOFTAP_BSS_STARTED, |
| 7016 | &adapter->event_flags)) |
| 7017 | operatingChannel = |
| 7018 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 7019 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7020 | break; |
| 7021 | default: |
| 7022 | break; |
| 7023 | } |
| 7024 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7025 | /* Found the device of interest. break the loop */ |
| 7026 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7027 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7028 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7029 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7030 | return operatingChannel; |
| 7031 | } |
| 7032 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7033 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7034 | hdd_ctx) |
| 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) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7047 | hdd_unregister_wext(adapter->dev); |
| 7048 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7049 | } |
| 7050 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7051 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7052 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7053 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7054 | } |
| 7055 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7056 | 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] | 7057 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7058 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7059 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7060 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7061 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7062 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7063 | if (adapter->device_mode == QDF_STA_MODE || |
| 7064 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 7065 | adapter->device_mode == QDF_IBSS_MODE || |
| 7066 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 7067 | adapter->device_mode == QDF_SAP_MODE || |
| 7068 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7069 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 7070 | adapter->vdev_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 7071 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7072 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7073 | } |
| 7074 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7075 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7076 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7077 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7078 | } |
| 7079 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7080 | /** |
| 7081 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 7082 | * adapters |
| 7083 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 7084 | * |
| 7085 | * return: QDF_STATUS_SUCCESS |
| 7086 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7087 | 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] | 7088 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7089 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7090 | int err; |
| 7091 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7092 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7093 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7094 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7095 | if (adapter->device_mode == QDF_STA_MODE || |
| 7096 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 7097 | adapter->device_mode == QDF_IBSS_MODE || |
| 7098 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 7099 | adapter->device_mode == QDF_SAP_MODE || |
| 7100 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7101 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 7102 | if (err) |
| 7103 | hdd_err("Unable to stop scheduled scan"); |
| 7104 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7105 | } |
| 7106 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7107 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7108 | |
| 7109 | return QDF_STATUS_SUCCESS; |
| 7110 | } |
| 7111 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7112 | #ifdef WLAN_NS_OFFLOAD |
| 7113 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7114 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7115 | * @hdd_ctx: Pointer to hdd context |
| 7116 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7117 | * Unregister for IPv6 address change notifications. |
| 7118 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7119 | * Return: None |
| 7120 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7121 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7122 | { |
| 7123 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7124 | } |
| 7125 | |
| 7126 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7127 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7128 | * @hdd_ctx: Pointer to hdd context |
| 7129 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7130 | * Register for IPv6 address change notifications. |
| 7131 | * |
| 7132 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7133 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7134 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7135 | { |
| 7136 | int ret; |
| 7137 | |
| 7138 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 7139 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7140 | if (ret) { |
| 7141 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 7142 | goto out; |
| 7143 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7144 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7145 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7146 | out: |
| 7147 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7148 | } |
| 7149 | #else |
| 7150 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7151 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7152 | * @hdd_ctx: Pointer to hdd context |
| 7153 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7154 | * Unregister for IPv6 address change notifications. |
| 7155 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7156 | * Return: None |
| 7157 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7158 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7159 | { |
| 7160 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 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_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7164 | * @hdd_ctx: Pointer to hdd context |
| 7165 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7166 | * Register for IPv6 address change notifications. |
| 7167 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7168 | * Return: None |
| 7169 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7170 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7171 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7172 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7173 | } |
| 7174 | #endif |
| 7175 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7176 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 7177 | { |
| 7178 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 7179 | adapter->disconnection_in_progress = status; |
| 7180 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 7181 | hdd_debug("setting disconnection status: %d", status); |
| 7182 | } |
| 7183 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7184 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7185 | * hdd_register_notifiers - Register netdev notifiers. |
| 7186 | * @hdd_ctx: HDD context |
| 7187 | * |
| 7188 | * Register netdev notifiers like IPv4 and IPv6. |
| 7189 | * |
| 7190 | * Return: 0 on success and errno on failure |
| 7191 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7192 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7193 | { |
| 7194 | int ret; |
| 7195 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7196 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 7197 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7198 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7199 | |
| 7200 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 7201 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 7202 | if (ret) { |
| 7203 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 7204 | goto unregister_ip6_notifier; |
| 7205 | } |
| 7206 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7207 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 7208 | if (ret) { |
| 7209 | hdd_err("Failed to register netevent notifier: %d", |
| 7210 | ret); |
| 7211 | goto unregister_inetaddr_notifier; |
| 7212 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7213 | return 0; |
| 7214 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7215 | unregister_inetaddr_notifier: |
| 7216 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7217 | unregister_ip6_notifier: |
| 7218 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7219 | out: |
| 7220 | return ret; |
| 7221 | |
| 7222 | } |
| 7223 | |
| 7224 | /** |
| 7225 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 7226 | * @hdd_ctx: HDD context |
| 7227 | * |
| 7228 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 7229 | * |
| 7230 | * Return: None. |
| 7231 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7232 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7233 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7234 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7235 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 7236 | |
| 7237 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7238 | } |
| 7239 | |
| 7240 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7241 | * hdd_exit_netlink_services - Exit netlink services |
| 7242 | * @hdd_ctx: HDD context |
| 7243 | * |
| 7244 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7245 | * nl service. |
| 7246 | * |
| 7247 | * Return: None. |
| 7248 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7249 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7250 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7251 | spectral_scan_deactivate_service(); |
| 7252 | cnss_diag_deactivate_service(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7253 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7254 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7255 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7256 | |
| 7257 | nl_srv_exit(); |
| 7258 | } |
| 7259 | |
| 7260 | /** |
| 7261 | * hdd_init_netlink_services- Init netlink services |
| 7262 | * @hdd_ctx: HDD context |
| 7263 | * |
| 7264 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7265 | * nl service. |
| 7266 | * |
| 7267 | * Return: 0 on success and errno on failure. |
| 7268 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7269 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7270 | { |
| 7271 | int ret; |
| 7272 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7273 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7274 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7275 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7276 | goto out; |
| 7277 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7278 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7279 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 7280 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7281 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7282 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7283 | goto err_nl_srv; |
| 7284 | } |
| 7285 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7286 | ptt_sock_activate_svc(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7287 | |
| 7288 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 7289 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7290 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7291 | |
| 7292 | ret = cnss_diag_activate_service(); |
| 7293 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7294 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7295 | goto err_close_cesium; |
| 7296 | } |
| 7297 | |
Dustin Brown | 0152085 | 2019-02-27 12:14:16 -0800 | [diff] [blame] | 7298 | spectral_scan_activate_service(hdd_ctx); |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 7299 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7300 | return 0; |
| 7301 | |
| 7302 | err_close_cesium: |
| 7303 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7304 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7305 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7306 | err_nl_srv: |
| 7307 | nl_srv_exit(); |
| 7308 | out: |
| 7309 | return ret; |
| 7310 | } |
| 7311 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7312 | /** |
| 7313 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 7314 | * @hdd_ctx: HDD context. |
| 7315 | * |
| 7316 | * Destroy RX wakelock. |
| 7317 | * |
| 7318 | * Return: None. |
| 7319 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7320 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7321 | { |
| 7322 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 7323 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7324 | |
| 7325 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7326 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 7327 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7328 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7329 | * Create RX wakelock. |
| 7330 | * |
| 7331 | * Return: None. |
| 7332 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7333 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7334 | { |
| 7335 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 7336 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7337 | |
| 7338 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7339 | * hdd_context_deinit() - Deinitialize HDD context |
| 7340 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7341 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7342 | * Deinitialize HDD context along with all the feature specific contexts but |
| 7343 | * do not free hdd context itself. Caller of this API is supposed to free |
| 7344 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7345 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7346 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7347 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7348 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7349 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7350 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 7351 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7352 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7353 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7354 | hdd_sap_context_destroy(hdd_ctx); |
| 7355 | |
| 7356 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 7357 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7358 | hdd_scan_context_destroy(hdd_ctx); |
| 7359 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 7360 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7361 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7362 | return 0; |
| 7363 | } |
| 7364 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7365 | void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7366 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 7367 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 7368 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7369 | hdd_exit_netlink_services(hdd_ctx); |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 7370 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 7371 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7372 | hdd_context_deinit(hdd_ctx); |
| 7373 | |
Dustin Brown | db2df2e | 2018-10-31 15:29:24 -0700 | [diff] [blame] | 7374 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 7375 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7376 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7377 | hdd_ctx->config = NULL; |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 7378 | cfg_release(); |
| 7379 | |
Min Liu | 4710404 | 2019-04-09 17:49:21 +0800 | [diff] [blame] | 7380 | qdf_delayed_work_destroy(&hdd_ctx->psoc_idle_timeout_work); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7381 | wiphy_free(hdd_ctx->wiphy); |
| 7382 | } |
| 7383 | |
| 7384 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7385 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 7386 | * |
| 7387 | * This function is used to destroy bug report lock |
| 7388 | * |
| 7389 | * Return: None |
| 7390 | */ |
| 7391 | static void wlan_destroy_bug_report_lock(void) |
| 7392 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 7393 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7394 | |
| 7395 | p_cds_context = cds_get_global_context(); |
| 7396 | if (!p_cds_context) { |
| 7397 | hdd_err("cds context is NULL"); |
| 7398 | return; |
| 7399 | } |
| 7400 | |
| 7401 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 7402 | } |
| 7403 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7404 | #ifdef DISABLE_CHANNEL_LIST |
| 7405 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7406 | { |
| 7407 | qdf_mutex_destroy(&hdd_ctx->cache_channel_lock); |
| 7408 | } |
| 7409 | #else |
| 7410 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7411 | { |
| 7412 | } |
| 7413 | #endif |
| 7414 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 7415 | void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7416 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7417 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7418 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7419 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7420 | |
Arun Kumar Khandavalli | deda5a8 | 2019-03-11 15:32:19 +0530 | [diff] [blame] | 7421 | hdd_debugfs_mws_coex_info_deinit(hdd_ctx); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 7422 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Dustin Brown | 6470aba | 2018-09-05 09:49:58 -0700 | [diff] [blame] | 7423 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7424 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7425 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7426 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7427 | if (QDF_TIMER_STATE_RUNNING == |
| 7428 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 7429 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7430 | } |
| 7431 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7432 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7433 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 7434 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7435 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7436 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7437 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7438 | hdd_ctx->last_acs_channel_list = NULL; |
| 7439 | hdd_ctx->num_of_channels = 0; |
| 7440 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7441 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7442 | |
| 7443 | /* |
| 7444 | * Powersave Offload Case |
| 7445 | * Disable Idle Power Save Mode |
| 7446 | */ |
| 7447 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 7448 | /* clear the scan queue in all the scenarios */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7449 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7450 | |
Dustin Brown | f688ea1 | 2019-03-19 17:02:32 -0700 | [diff] [blame] | 7451 | if (hdd_ctx->driver_status != DRIVER_MODULES_CLOSED) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7452 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 7453 | /* |
| 7454 | * Cancel any outstanding scan requests. We are about to close |
| 7455 | * all of our adapters, but an adapter structure is what SME |
| 7456 | * passes back to our callback function. Hence if there |
| 7457 | * are any outstanding scan requests then there is a |
| 7458 | * race condition between when the adapter is closed and |
| 7459 | * when the callback is invoked. We try to resolve that |
| 7460 | * race condition here by canceling any outstanding scans |
| 7461 | * before we close the adapters. |
| 7462 | * Note that the scans may be cancelled in an asynchronous |
| 7463 | * manner, so ideally there needs to be some kind of |
| 7464 | * synchronization. Rather than introduce a new |
| 7465 | * synchronization here, we will utilize the fact that we are |
| 7466 | * about to Request Full Power, and since that is synchronized, |
| 7467 | * the expectation is that by the time Request Full Power has |
| 7468 | * completed, all scans will be cancelled |
| 7469 | */ |
| 7470 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7471 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 7472 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 7473 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7474 | } |
| 7475 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7476 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 7477 | |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 7478 | qdf_dp_trace_deinit(); |
| 7479 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 7480 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 7481 | |
Visweswara Tanuku | c029a20 | 2018-11-27 10:42:10 +0530 | [diff] [blame] | 7482 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 7483 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 7484 | hdd_driver_memdump_deinit(); |
| 7485 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 7486 | qdf_nbuf_deinit_replenish_timer(); |
| 7487 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7488 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 7489 | hdd_info("Release wakelock for monitor mode!"); |
| 7490 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 7491 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 7492 | } |
| 7493 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7494 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7495 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7496 | wlan_hdd_cache_chann_mutex_destroy(hdd_ctx); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7497 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 7498 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7499 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 7500 | hdd_close_all_adapters(hdd_ctx, false); |
| 7501 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 7502 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7503 | /* |
| 7504 | * If there is re_init failure wiphy would have already de-registered |
| 7505 | * check the wiphy status before un-registering again |
| 7506 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 7507 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7508 | wiphy_unregister(wiphy); |
| 7509 | wlan_hdd_cfg80211_deinit(wiphy); |
| 7510 | hdd_lpass_notify_stop(hdd_ctx); |
| 7511 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 7512 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7513 | hdd_exit_netlink_services(hdd_ctx); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7514 | #ifdef FEATURE_WLAN_CH_AVOID |
| 7515 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 7516 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7517 | } |
| 7518 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7519 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7520 | /** |
| 7521 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7522 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7523 | * |
| 7524 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 7525 | * Then new ACS request will do a fresh scan without reusing the cached |
| 7526 | * scan information. |
| 7527 | * |
| 7528 | * Return: void |
| 7529 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 7530 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7531 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7532 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7533 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7534 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7535 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7536 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7537 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7538 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7539 | hdd_ctx->last_acs_channel_list = NULL; |
| 7540 | hdd_ctx->num_of_channels = 0; |
| 7541 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7542 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7543 | mac_handle = hdd_ctx->mac_handle; |
| 7544 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7545 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7546 | } |
| 7547 | #endif |
| 7548 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7549 | /** |
| 7550 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 7551 | * @state: state |
| 7552 | * |
| 7553 | * This function notifies FW with modem power status |
| 7554 | * |
| 7555 | * Return: 0 if successful, error number otherwise |
| 7556 | */ |
| 7557 | int hdd_wlan_notify_modem_power_state(int state) |
| 7558 | { |
| 7559 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7560 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7561 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7562 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7563 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7564 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7565 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7566 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7567 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7568 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7569 | mac_handle = hdd_ctx->mac_handle; |
| 7570 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7571 | return -EINVAL; |
| 7572 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7573 | qdf_status = sme_notify_modem_power_state(mac_handle, state); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7574 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7575 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7576 | state); |
| 7577 | return -EINVAL; |
| 7578 | } |
| 7579 | return 0; |
| 7580 | } |
| 7581 | |
| 7582 | /** |
| 7583 | * |
| 7584 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 7585 | * @adapter - Pointer to the HDD |
| 7586 | * |
| 7587 | * Return: None |
| 7588 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7589 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7590 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7591 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7592 | |
| 7593 | /* |
| 7594 | * Send ready indication to the HDD. This will kick off the MAC |
| 7595 | * into a 'running' state and should kick off an initial scan. |
| 7596 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7597 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->mac_handle); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7598 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7599 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 7600 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7601 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7602 | } |
| 7603 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7604 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7605 | } |
| 7606 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 7607 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 7608 | { |
| 7609 | struct hdd_adapter *adapter; |
| 7610 | |
| 7611 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7612 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 7613 | return adapter; |
| 7614 | } |
| 7615 | |
| 7616 | return NULL; |
| 7617 | } |
| 7618 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7619 | /* wake lock APIs for HDD */ |
| 7620 | void hdd_prevent_suspend(uint32_t reason) |
| 7621 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7622 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7623 | } |
| 7624 | |
| 7625 | void hdd_allow_suspend(uint32_t reason) |
| 7626 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7627 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7628 | } |
| 7629 | |
| 7630 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 7631 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 7632 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 7633 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7634 | } |
| 7635 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7636 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7637 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7638 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7639 | return sme_init_chan_list(hdd_ctx->mac_handle, |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 7640 | hdd_ctx->reg.alpha2, |
| 7641 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7642 | } |
| 7643 | |
| 7644 | /** |
| 7645 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 7646 | * @hdd_ctx: Pointer to the hdd context |
| 7647 | * |
| 7648 | * HDD function to know if hardware supports 5GHz |
| 7649 | * |
| 7650 | * Return: true if hardware supports 5GHz |
| 7651 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7652 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7653 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7654 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7655 | return true; |
| 7656 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7657 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7658 | return true; |
| 7659 | else |
| 7660 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7661 | } |
| 7662 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7663 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7664 | { |
| 7665 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7666 | int ret_val; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7667 | uint32_t channel_bonding_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7668 | |
| 7669 | wiphy = hdd_ctx->wiphy; |
| 7670 | |
| 7671 | /* |
| 7672 | * The channel information in |
| 7673 | * wiphy needs to be initialized before wiphy registration |
| 7674 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7675 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7676 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7677 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7678 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7679 | } |
| 7680 | |
| 7681 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7682 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7683 | #else |
| 7684 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7685 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7686 | WIPHY_WOWLAN_DISCONNECT | |
| 7687 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7688 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7689 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7690 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7691 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7692 | |
| 7693 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7694 | WOW_MAX_FILTERS_PER_LIST); |
| 7695 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7696 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7697 | #endif |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7698 | ucfg_mlme_get_channel_bonding_24ghz(hdd_ctx->psoc, |
| 7699 | &channel_bonding_mode); |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7700 | if (hdd_ctx->obss_scan_offload) { |
| 7701 | hdd_debug("wmi_service_obss_scan supported"); |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7702 | } else if (channel_bonding_mode) { |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7703 | hdd_debug("enable wpa_supp obss_scan"); |
| 7704 | wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; |
| 7705 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7706 | |
| 7707 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7708 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7709 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7710 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7711 | return ret_val; |
| 7712 | } |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7713 | |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7714 | /* Check the kernel version for upstream commit aced43ce780dc5 that |
| 7715 | * has support for processing user cell_base hints when wiphy is |
| 7716 | * self managed or check the backport flag for the same. |
| 7717 | */ |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7718 | #if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \ |
| 7719 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7720 | hdd_send_wiphy_regd_sync_event(hdd_ctx); |
| 7721 | #endif |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7722 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7723 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7724 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7725 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7726 | } |
| 7727 | |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 7728 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7729 | /** |
| 7730 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7731 | * @hdd_ctx - handle to hdd context |
| 7732 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7733 | * |
| 7734 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7735 | * Stats show up in wlan driver logs. |
| 7736 | * |
| 7737 | * Returns: None |
| 7738 | */ |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7739 | static void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7740 | bool data_in_interval) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7741 | { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7742 | static uint32_t counter; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7743 | static bool data_in_time_period; |
| 7744 | ol_txrx_pdev_handle pdev; |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7745 | ol_txrx_soc_handle soc; |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7746 | uint32_t periodic_stats_disp_time = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7747 | |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7748 | ucfg_mlme_stats_get_periodic_display_time(hdd_ctx->psoc, |
| 7749 | &periodic_stats_disp_time); |
| 7750 | if (!periodic_stats_disp_time) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7751 | return; |
| 7752 | |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7753 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 7754 | if (!soc) { |
| 7755 | hdd_err("soc is NULL"); |
| 7756 | return; |
| 7757 | } |
| 7758 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7759 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7760 | if (!pdev) { |
| 7761 | hdd_err("pdev is NULL"); |
| 7762 | return; |
| 7763 | } |
| 7764 | |
| 7765 | counter++; |
| 7766 | if (data_in_interval) |
| 7767 | data_in_time_period = data_in_interval; |
| 7768 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7769 | if (counter * hdd_ctx->config->bus_bw_compute_interval >= |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7770 | periodic_stats_disp_time * 1000) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7771 | if (data_in_time_period) { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7772 | wlan_hdd_display_txrx_stats(hdd_ctx); |
Mohit Khanna | c964965 | 2018-11-28 18:10:28 -0800 | [diff] [blame] | 7773 | dp_txrx_ext_dump_stats(soc, CDP_DP_RX_THREAD_STATS); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7774 | cdp_display_stats(soc, |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7775 | CDP_RX_RING_STATS, |
| 7776 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7777 | cdp_display_stats(soc, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7778 | CDP_TXRX_PATH_STATS, |
| 7779 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7780 | wlan_hdd_display_netif_queue_history |
| 7781 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7782 | qdf_dp_trace_dump_stats(); |
| 7783 | } |
| 7784 | counter = 0; |
| 7785 | data_in_time_period = false; |
| 7786 | } |
| 7787 | } |
| 7788 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7789 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7790 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7791 | * @hdd_ctx: pointer to struct hdd_context |
| 7792 | * |
| 7793 | * Return: none |
| 7794 | */ |
| 7795 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7796 | { |
| 7797 | struct hdd_adapter *adapter; |
| 7798 | |
| 7799 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7800 | hdd_send_rps_disable_ind(adapter); |
| 7801 | } |
| 7802 | |
| 7803 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7804 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7805 | * @hdd_ctx - handle to hdd context |
| 7806 | * @tx_packets - transmit packet count |
| 7807 | * @rx_packets - receive packet count |
| 7808 | * |
| 7809 | * The function controls the bus bandwidth and dynamic control of |
| 7810 | * tcp delayed ack configuration |
| 7811 | * |
| 7812 | * Returns: None |
| 7813 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7814 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7815 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7816 | const uint64_t tx_packets, |
| 7817 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7818 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7819 | u64 total_pkts = tx_packets + rx_packets; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7820 | uint64_t temp_tx = 0, avg_rx = 0; |
| 7821 | uint64_t no_rx_offload_pkts = 0, avg_no_rx_offload_pkts = 0; |
| 7822 | uint64_t rx_offload_pkts = 0, avg_rx_offload_pkts = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7823 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7824 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7825 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7826 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7827 | uint16_t index = 0; |
| 7828 | bool vote_level_change = false; |
| 7829 | bool rx_level_change = false; |
| 7830 | bool tx_level_change = false; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7831 | bool rxthread_high_tput_req = false; |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7832 | bool dptrace_high_tput_req; |
Srinivas Girigowda | 5033534 | 2018-09-07 15:21:01 -0700 | [diff] [blame] | 7833 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7834 | if (total_pkts > hdd_ctx->config->bus_bw_high_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7835 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7836 | else if (total_pkts > hdd_ctx->config->bus_bw_medium_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7837 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7838 | else if (total_pkts > hdd_ctx->config->bus_bw_low_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7839 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7840 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7841 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7842 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7843 | dptrace_high_tput_req = |
| 7844 | next_vote_level > PLD_BUS_WIDTH_NONE ? true : false; |
| 7845 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7846 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7847 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7848 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7849 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7850 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7851 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7852 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7853 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7854 | if (hdd_ctx->hbw_requested) { |
| 7855 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7856 | hdd_ctx->hbw_requested = false; |
| 7857 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7858 | if (hdd_ctx->dynamic_rps) |
| 7859 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7860 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7861 | if (!hdd_ctx->hbw_requested) { |
| 7862 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7863 | hdd_ctx->hbw_requested = true; |
| 7864 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7865 | if (hdd_ctx->dynamic_rps) |
| 7866 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7867 | } |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7868 | |
Manjunathappa Prakash | cb6df76 | 2018-05-29 18:54:58 -0700 | [diff] [blame] | 7869 | if (hdd_ctx->config->napi_cpu_affinity_mask) |
| 7870 | hdd_napi_apply_throughput_policy(hdd_ctx, |
| 7871 | tx_packets, |
| 7872 | rx_packets); |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7873 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7874 | if (rx_packets < hdd_ctx->config->bus_bw_low_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7875 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
| 7876 | else |
| 7877 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7878 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7879 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7880 | qdf_dp_trace_apply_tput_policy(dptrace_high_tput_req); |
| 7881 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7882 | /* |
| 7883 | * Includes tcp+udp, if perf core is required for tcp, then |
| 7884 | * perf core is also required for udp. |
| 7885 | */ |
| 7886 | no_rx_offload_pkts = hdd_ctx->no_rx_offload_pkt_cnt; |
| 7887 | hdd_ctx->no_rx_offload_pkt_cnt = 0; |
| 7888 | rx_offload_pkts = rx_packets - no_rx_offload_pkts; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7889 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7890 | avg_no_rx_offload_pkts = (no_rx_offload_pkts + |
| 7891 | hdd_ctx->prev_no_rx_offload_pkts) / 2; |
| 7892 | hdd_ctx->prev_no_rx_offload_pkts = no_rx_offload_pkts; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7893 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7894 | avg_rx_offload_pkts = (rx_offload_pkts + |
| 7895 | hdd_ctx->prev_rx_offload_pkts) / 2; |
| 7896 | hdd_ctx->prev_rx_offload_pkts = rx_offload_pkts; |
| 7897 | |
| 7898 | avg_rx = avg_no_rx_offload_pkts + avg_rx_offload_pkts; |
| 7899 | /* |
| 7900 | * Takes care to set Rx_thread affinity for below case |
| 7901 | * 1)LRO/GRO not supported ROME case |
| 7902 | * 2)when rx_ol is disabled in cases like concurrency etc |
| 7903 | * 3)For UDP cases |
| 7904 | */ |
| 7905 | if (avg_no_rx_offload_pkts > |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7906 | hdd_ctx->config->bus_bw_high_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7907 | rxthread_high_tput_req = true; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7908 | else |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7909 | rxthread_high_tput_req = false; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7910 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7911 | if (cds_sched_handle_throughput_req(rxthread_high_tput_req)) |
| 7912 | hdd_warn("Rx thread high_tput(%d) affinity request failed", |
| 7913 | rxthread_high_tput_req); |
| 7914 | |
| 7915 | /* fine-tuning parameters for RX Flows */ |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7916 | if (avg_rx > hdd_ctx->config->tcp_delack_thres_high) { |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7917 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7918 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7919 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7920 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7921 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7922 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7923 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7924 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7925 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7926 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7927 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7928 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7929 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Jeff Johnson | b9feee4 | 2018-07-08 10:34:48 -0700 | [diff] [blame] | 7930 | next_rx_level, avg_rx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7931 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7932 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7933 | /* Send throughput indication only if it is enabled. |
| 7934 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7935 | * to default delayed ack. Note that this will disable the |
| 7936 | * dynamic delayed ack mechanism across the system |
| 7937 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7938 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7939 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7940 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7941 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7942 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7943 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7944 | rx_tp_data.level = next_rx_level; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7945 | wlan_hdd_update_tcp_rx_param(hdd_ctx, &rx_tp_data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7946 | } |
| 7947 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7948 | /* fine-tuning parameters for TX Flows */ |
| 7949 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7950 | hdd_ctx->prev_tx = tx_packets; |
| 7951 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7952 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7953 | else |
| 7954 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7955 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7956 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7957 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7958 | struct wlan_tx_tp_data tx_tp_data = {0}; |
| 7959 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7960 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7961 | next_tx_level, temp_tx); |
| 7962 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7963 | tx_level_change = true; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7964 | tx_tp_data.level = next_tx_level; |
| 7965 | tx_tp_data.tcp_limit_output = true; |
| 7966 | wlan_hdd_update_tcp_tx_param(hdd_ctx, &tx_tp_data); |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7967 | } |
| 7968 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7969 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7970 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7971 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7972 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7973 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7974 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7975 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7976 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7977 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7978 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7979 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7980 | |
| 7981 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7982 | } |
| 7983 | |
Tiger Yu | e40e783 | 2019-04-25 10:46:53 +0800 | [diff] [blame^] | 7984 | #ifdef QCA_SUPPORT_TXRX_DRIVER_TCP_DEL_ACK |
| 7985 | /** |
| 7986 | * hdd_set_driver_del_ack_enable() - set driver delayed ack enabled flag |
| 7987 | * @vdev_id: vdev id |
| 7988 | * @hdd_ctx: handle to hdd context |
| 7989 | * @rx_packets: receive packet count |
| 7990 | * |
| 7991 | * Return: none |
| 7992 | */ |
| 7993 | static inline |
| 7994 | void hdd_set_driver_del_ack_enable(uint16_t vdev_id, |
| 7995 | struct hdd_context *hdd_ctx, |
| 7996 | uint64_t rx_packets) |
| 7997 | { |
| 7998 | struct hdd_config *cfg = hdd_ctx->config; |
| 7999 | |
| 8000 | cdp_vdev_set_driver_del_ack_enable(cds_get_context(QDF_MODULE_ID_SOC), |
| 8001 | vdev_id, rx_packets, |
| 8002 | cfg->bus_bw_compute_interval, |
| 8003 | cfg->del_ack_threshold_high, |
| 8004 | cfg->del_ack_threshold_low); |
| 8005 | } |
| 8006 | #else |
| 8007 | static inline |
| 8008 | void hdd_set_driver_del_ack_enable(uint16_t vdev_id, |
| 8009 | struct hdd_context *hdd_ctx, |
| 8010 | uint64_t rx_packets) |
| 8011 | { |
| 8012 | } |
| 8013 | #endif |
| 8014 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8015 | #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] | 8016 | static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8017 | { |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 8018 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 8019 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 8020 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 8021 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8022 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 8023 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8024 | bool connected = false; |
| 8025 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 8026 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8027 | if (wlan_hdd_validate_context(hdd_ctx)) |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8028 | goto stop_work; |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8029 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 8030 | if (hdd_ctx->is_wiphy_suspended) |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8031 | return; |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 8032 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8033 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 8034 | /* |
| 8035 | * Validate magic so we don't end up accessing |
| 8036 | * an invalid adapter. |
| 8037 | */ |
| 8038 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 8039 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8040 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8041 | if ((adapter->device_mode == QDF_STA_MODE || |
| 8042 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 8043 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.conn_state |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8044 | != eConnectionState_Associated) { |
| 8045 | |
| 8046 | continue; |
| 8047 | } |
| 8048 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8049 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 8050 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 8051 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8052 | |
| 8053 | continue; |
| 8054 | } |
| 8055 | |
| 8056 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 8057 | adapter->prev_tx_packets); |
| 8058 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 8059 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 8060 | |
| 8061 | if (adapter->device_mode == QDF_SAP_MODE || |
| 8062 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 8063 | adapter->device_mode == QDF_IBSS_MODE) { |
| 8064 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 8065 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 8066 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8067 | adapter->vdev_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 8068 | &fwd_tx_packets, &fwd_rx_packets); |
| 8069 | if (ret == A_OK) { |
| 8070 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 8071 | fwd_tx_packets, |
| 8072 | adapter->prev_fwd_tx_packets); |
| 8073 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 8074 | fwd_tx_packets, |
| 8075 | adapter->prev_fwd_rx_packets); |
| 8076 | } |
| 8077 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8078 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 8079 | if (adapter->device_mode == QDF_SAP_MODE) |
| 8080 | con_sap_adapter = adapter; |
| 8081 | |
Tiger Yu | e40e783 | 2019-04-25 10:46:53 +0800 | [diff] [blame^] | 8082 | hdd_set_driver_del_ack_enable(adapter->vdev_id, hdd_ctx, |
| 8083 | rx_packets); |
| 8084 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8085 | total_rx += adapter->stats.rx_packets; |
| 8086 | total_tx += adapter->stats.tx_packets; |
| 8087 | |
| 8088 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 8089 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 8090 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 8091 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 8092 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8093 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 8094 | connected = true; |
| 8095 | } |
| 8096 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8097 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 8098 | hdd_err("bus bandwidth timer running in disconnected state"); |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8099 | goto stop_work; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8100 | } |
| 8101 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 8102 | /* add intra bss forwarded tx and rx packets */ |
| 8103 | tx_packets += fwd_tx_packets_diff; |
| 8104 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8105 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8106 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->pdev)) { |
| 8107 | ucfg_ipa_uc_stat_query(hdd_ctx->pdev, &ipa_tx_packets, |
| 8108 | &ipa_rx_packets); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 8109 | tx_packets += (uint64_t)ipa_tx_packets; |
| 8110 | rx_packets += (uint64_t)ipa_rx_packets; |
| 8111 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 8112 | if (con_sap_adapter) { |
| 8113 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 8114 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 8115 | } |
| 8116 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8117 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, tx_packets, rx_packets); |
| 8118 | ucfg_ipa_uc_stat_request(hdd_ctx->pdev, 2); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 8119 | } |
| 8120 | |
| 8121 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8122 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8123 | return; |
| 8124 | |
| 8125 | stop_work: |
| 8126 | qdf_periodic_work_stop_async(&hdd_ctx->bus_bw_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8127 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8128 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8129 | static void hdd_bus_bw_work_handler(void *context) |
Rajeev Kumar | b2b5e69 | 2018-08-31 15:12:40 -0700 | [diff] [blame] | 8130 | { |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 8131 | struct hdd_context *hdd_ctx = context; |
| 8132 | struct qdf_op_sync *op_sync; |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8133 | |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 8134 | if (qdf_op_protect(&op_sync)) |
| 8135 | return; |
| 8136 | |
| 8137 | __hdd_bus_bw_work_handler(hdd_ctx); |
| 8138 | |
| 8139 | qdf_op_unprotect(op_sync); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 8140 | } |
| 8141 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8142 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8143 | { |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8144 | QDF_STATUS status; |
| 8145 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8146 | hdd_enter(); |
| 8147 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8148 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8149 | status = qdf_periodic_work_create(&hdd_ctx->bus_bw_work, |
| 8150 | hdd_bus_bw_work_handler, |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 8151 | hdd_ctx); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8152 | |
| 8153 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8154 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8155 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8156 | } |
| 8157 | |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 8158 | void hdd_bus_bandwidth_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8159 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8160 | hdd_enter(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8161 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8162 | QDF_BUG(!qdf_periodic_work_stop_sync(&hdd_ctx->bus_bw_work)); |
| 8163 | qdf_periodic_work_destroy(&hdd_ctx->bus_bw_work); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8164 | |
| 8165 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8166 | } |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 8167 | #endif /*WLAN_FEATURE_DP_BUS_BANDWIDTH*/ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8168 | |
| 8169 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8170 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 8171 | * @hdd_ctx: hdd context |
| 8172 | * |
| 8173 | * Return: 0 for success or error code |
| 8174 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8175 | 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] | 8176 | { |
| 8177 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 8178 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8179 | if (!hdd_ctx->hdd_txrx_hist) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8180 | return -ENOMEM; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8181 | return 0; |
| 8182 | } |
| 8183 | |
| 8184 | /** |
| 8185 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 8186 | * @hdd_ctx: hdd context |
| 8187 | * |
| 8188 | * Return: none |
| 8189 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8190 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8191 | { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 8192 | if (!hdd_ctx || !hdd_ctx->hdd_txrx_hist) |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 8193 | return; |
| 8194 | |
| 8195 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 8196 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8197 | } |
| 8198 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8199 | static uint8_t *convert_level_to_string(uint32_t level) |
| 8200 | { |
| 8201 | switch (level) { |
| 8202 | /* initialize the wlan sub system */ |
| 8203 | case WLAN_SVC_TP_NONE: |
| 8204 | return "NONE"; |
| 8205 | case WLAN_SVC_TP_LOW: |
| 8206 | return "LOW"; |
| 8207 | case WLAN_SVC_TP_MEDIUM: |
| 8208 | return "MED"; |
| 8209 | case WLAN_SVC_TP_HIGH: |
| 8210 | return "HIGH"; |
| 8211 | default: |
| 8212 | return "INVAL"; |
| 8213 | } |
| 8214 | } |
| 8215 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8216 | |
| 8217 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8218 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 8219 | * @hdd_ctx: hdd context |
| 8220 | * |
| 8221 | * Return: none |
| 8222 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8223 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8224 | { |
| 8225 | int i; |
| 8226 | |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 8227 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8228 | hdd_nofl_info("BW compute Interval: %dms", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8229 | hdd_ctx->config->bus_bw_compute_interval); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8230 | 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] | 8231 | hdd_ctx->config->bus_bw_high_threshold, |
| 8232 | hdd_ctx->config->bus_bw_medium_threshold, |
| 8233 | hdd_ctx->config->bus_bw_low_threshold); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8234 | hdd_nofl_info("Enable TCP DEL ACK: %d", |
| 8235 | hdd_ctx->en_tcp_delack_no_lro); |
| 8236 | hdd_nofl_info("TCP DEL High TH: %d TCP DEL Low TH: %d", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8237 | hdd_ctx->config->tcp_delack_thres_high, |
| 8238 | hdd_ctx->config->tcp_delack_thres_low); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8239 | hdd_nofl_info("TCP TX HIGH TP TH: %d (Use to set tcp_output_bytes_limit)", |
| 8240 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 8241 | #endif /*WLAN_FEATURE_DP_BUS_BANDWIDTH*/ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8242 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8243 | hdd_nofl_info("Total entries: %d Current index: %d", |
| 8244 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8245 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8246 | 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] | 8247 | |
| 8248 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8249 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 8250 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8251 | hdd_nofl_info("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 8252 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 8253 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 8254 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 8255 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8256 | hdd_ctx->hdd_txrx_hist[i]. |
| 8257 | next_vote_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8258 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8259 | hdd_ctx->hdd_txrx_hist[i]. |
| 8260 | next_rx_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8261 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8262 | hdd_ctx->hdd_txrx_hist[i]. |
| 8263 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8264 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8265 | } |
| 8266 | |
| 8267 | /** |
| 8268 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 8269 | * @hdd_ctx: hdd context |
| 8270 | * |
| 8271 | * Return: none |
| 8272 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8273 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8274 | { |
| 8275 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8276 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 8277 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8278 | } |
| 8279 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8280 | /* length of the netif queue log needed per adapter */ |
| 8281 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 8282 | |
| 8283 | /** |
| 8284 | * |
| 8285 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 8286 | * @hdd_ctx: hdd context |
| 8287 | * |
| 8288 | * Return: none |
| 8289 | */ |
| 8290 | static void |
| 8291 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 8292 | { |
| 8293 | int adapter_num = 0; |
| 8294 | int i; |
| 8295 | int bytes_written; |
| 8296 | u32 tbytes; |
| 8297 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8298 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8299 | char *comb_log_str; |
| 8300 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8301 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8302 | |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 8303 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * WLAN_MAX_VDEVS) + 1; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8304 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8305 | if (!comb_log_str) |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8306 | return; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8307 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8308 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8309 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8310 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8311 | curr_time = qdf_system_ticks(); |
| 8312 | total = curr_time - adapter->start_time; |
| 8313 | delta = curr_time - adapter->last_time; |
| 8314 | |
| 8315 | if (adapter->pause_map) { |
| 8316 | pause = adapter->total_pause_time + delta; |
| 8317 | unpause = adapter->total_unpause_time; |
| 8318 | } else { |
| 8319 | unpause = adapter->total_unpause_time + delta; |
| 8320 | pause = adapter->total_pause_time; |
| 8321 | } |
| 8322 | |
| 8323 | tbytes = 0; |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 8324 | qdf_mem_zero(temp_str, sizeof(temp_str)); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8325 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8326 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 8327 | continue; |
| 8328 | tbytes += |
| 8329 | snprintf( |
| 8330 | &temp_str[tbytes], |
| 8331 | (tbytes >= sizeof(temp_str) ? |
| 8332 | 0 : sizeof(temp_str) - tbytes), |
| 8333 | "%d(%d,%d) ", |
| 8334 | i, |
| 8335 | adapter->queue_oper_stats[i]. |
| 8336 | pause_count, |
| 8337 | adapter->queue_oper_stats[i]. |
| 8338 | unpause_count); |
| 8339 | } |
| 8340 | if (tbytes >= sizeof(temp_str)) |
| 8341 | hdd_warn("log truncated"); |
| 8342 | |
| 8343 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8344 | bytes_written >= comb_log_str_size ? 0 : |
| 8345 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8346 | "[%d %d] (%d) %u/%ums %s|", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8347 | adapter->vdev_id, adapter->device_mode, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8348 | adapter->pause_map, |
| 8349 | qdf_system_ticks_to_msecs(pause), |
| 8350 | qdf_system_ticks_to_msecs(total), |
| 8351 | temp_str); |
| 8352 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8353 | adapter_num++; |
| 8354 | } |
| 8355 | |
| 8356 | /* using QDF_TRACE to avoid printing function name */ |
| 8357 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 8358 | "STATS |%s", comb_log_str); |
| 8359 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8360 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8361 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8362 | |
| 8363 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8364 | } |
| 8365 | |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8366 | /* Max size of a single netdev tx queue state string. e.g. "1: 0x1" */ |
| 8367 | #define HDD_NETDEV_TX_Q_STATE_STRLEN 15 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8368 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 8369 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 8370 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8371 | * |
| 8372 | * Return: none |
| 8373 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8374 | void |
| 8375 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 8376 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8377 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8378 | int i; |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8379 | struct hdd_adapter *adapter = NULL; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8380 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8381 | struct hdd_netif_queue_history *q_hist_ptr; |
| 8382 | 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] | 8383 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8384 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 8385 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 8386 | return; |
| 8387 | } |
| 8388 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8389 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8390 | if (adapter->vdev_id == CDP_INVALID_VDEV_ID) |
| 8391 | continue; |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8392 | hdd_nofl_info("Netif queue operation statistics:"); |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 8393 | hdd_nofl_info("vdev_id %d device mode %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8394 | adapter->vdev_id, adapter->device_mode); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8395 | hdd_nofl_info("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8396 | curr_time = qdf_system_ticks(); |
| 8397 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8398 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8399 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8400 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8401 | unpause = adapter->total_unpause_time; |
| 8402 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8403 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8404 | pause = adapter->total_pause_time; |
| 8405 | } |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8406 | hdd_nofl_info("Total: %ums Pause: %ums Unpause: %ums", |
| 8407 | qdf_system_ticks_to_msecs(total), |
| 8408 | qdf_system_ticks_to_msecs(pause), |
| 8409 | qdf_system_ticks_to_msecs(unpause)); |
| 8410 | hdd_nofl_info("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8411 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8412 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8413 | qdf_time_t pause_delta = 0; |
| 8414 | |
| 8415 | if (adapter->pause_map & (1 << i)) |
| 8416 | pause_delta = delta; |
| 8417 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8418 | /* using hdd_log to avoid printing function name */ |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8419 | hdd_nofl_info("%s: %d: %d: %ums", |
| 8420 | hdd_reason_type_to_string(i), |
| 8421 | adapter->queue_oper_stats[i].pause_count, |
| 8422 | adapter->queue_oper_stats[i]. |
| 8423 | unpause_count, |
| 8424 | qdf_system_ticks_to_msecs( |
| 8425 | adapter->queue_oper_stats[i]. |
| 8426 | total_pause_time + pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8427 | } |
| 8428 | |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8429 | 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] | 8430 | WLAN_HDD_MAX_HISTORY_ENTRY, |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8431 | adapter->history_index, |
| 8432 | qdf_system_ticks_to_msecs(qdf_system_ticks())); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8433 | |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8434 | hdd_nofl_info("%2s%20s%50s%30s%10s %s", |
| 8435 | "#", "time(ms)", "action_type", "reason_type", |
| 8436 | "pause_map", "netdev-queue-status"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8437 | |
| 8438 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8439 | /* using hdd_log to avoid printing function name */ |
| 8440 | if (adapter->queue_oper_history[i].time == 0) |
| 8441 | continue; |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8442 | q_hist_ptr = &adapter->queue_oper_history[i]; |
| 8443 | wlan_hdd_dump_queue_history_state(q_hist_ptr, |
| 8444 | q_status_buf, |
| 8445 | sizeof(q_status_buf)); |
| 8446 | hdd_nofl_info("%2d%20u%50s%30s%10x %s", |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8447 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8448 | adapter->queue_oper_history[i].time), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8449 | hdd_action_type_to_string( |
| 8450 | adapter->queue_oper_history[i]. |
| 8451 | netif_action), |
| 8452 | hdd_reason_type_to_string( |
| 8453 | adapter->queue_oper_history[i]. |
| 8454 | netif_reason), |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8455 | adapter->queue_oper_history[i].pause_map, |
| 8456 | q_status_buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8457 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8458 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8459 | } |
| 8460 | |
| 8461 | /** |
| 8462 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 8463 | * @hdd_ctx: hdd context |
| 8464 | * |
| 8465 | * Return: none |
| 8466 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8467 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8468 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8469 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8470 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8471 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8472 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8473 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8474 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8475 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8476 | adapter->history_index = 0; |
| 8477 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 8478 | adapter->total_pause_time = 0; |
| 8479 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8480 | } |
| 8481 | } |
| 8482 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8483 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 8484 | /** |
| 8485 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 8486 | * @hdd_ctx: hdd global context |
| 8487 | * |
| 8488 | * Return: none |
| 8489 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8490 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8491 | { |
| 8492 | uint8_t i; |
| 8493 | |
| 8494 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 8495 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 8496 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 8497 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 8498 | } |
| 8499 | } |
| 8500 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8501 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8502 | { |
| 8503 | } |
| 8504 | #endif |
| 8505 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8506 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 8507 | /** |
| 8508 | * 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] | 8509 | * @hdd_ctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8510 | * @enable: enable or disable this behaviour |
| 8511 | * |
| 8512 | * Return: int |
| 8513 | */ |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8514 | 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] | 8515 | { |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8516 | struct wow_pulse_mode wow_pulse_set_info; |
| 8517 | QDF_STATUS status; |
| 8518 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8519 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8520 | |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8521 | if (!ucfg_pmo_is_wow_pulse_enabled(hdd_ctx->psoc)) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8522 | return 0; |
| 8523 | |
| 8524 | /* prepare the request to send to SME */ |
| 8525 | if (enable == true) { |
| 8526 | wow_pulse_set_info.wow_pulse_enable = true; |
| 8527 | wow_pulse_set_info.wow_pulse_pin = |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8528 | ucfg_pmo_get_wow_pulse_pin(hdd_ctx->psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8529 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8530 | wow_pulse_set_info.wow_pulse_interval_high = |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8531 | ucfg_pmo_get_wow_pulse_interval_high(hdd_ctx->psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8532 | |
| 8533 | wow_pulse_set_info.wow_pulse_interval_low = |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8534 | ucfg_pmo_get_wow_pulse_interval_low(hdd_ctx->psoc); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8535 | } else { |
| 8536 | wow_pulse_set_info.wow_pulse_enable = false; |
| 8537 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 8538 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 8539 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 8540 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8541 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8542 | wow_pulse_set_info.wow_pulse_enable, |
| 8543 | wow_pulse_set_info.wow_pulse_pin, |
| 8544 | wow_pulse_set_info.wow_pulse_interval_low, |
| 8545 | wow_pulse_set_info.wow_pulse_interval_high); |
| 8546 | |
| 8547 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 8548 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8549 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8550 | return -EIO; |
| 8551 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8552 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8553 | return 0; |
| 8554 | } |
| 8555 | #else |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8556 | 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] | 8557 | { |
| 8558 | return 0; |
| 8559 | } |
| 8560 | #endif |
| 8561 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8562 | #ifdef WLAN_FEATURE_FASTPATH |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8563 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8564 | /** |
| 8565 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 8566 | * @hdd_cfg: hdd config |
| 8567 | * @context: lower layer context |
| 8568 | * |
| 8569 | * Return: none |
| 8570 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8571 | void hdd_enable_fastpath(struct hdd_context *hdd_ctx, |
| 8572 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8573 | { |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8574 | if (cfg_get(hdd_ctx->psoc, CFG_DP_ENABLE_FASTPATH)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8575 | hif_enable_fastpath(context); |
| 8576 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8577 | #endif |
| 8578 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8579 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8580 | /** |
| 8581 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8582 | * @hdd_handle: opaque handle for the hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8583 | * @level: thermal level |
| 8584 | * |
| 8585 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8586 | * than 0, and restore the original data path when throttle level is 0 |
| 8587 | * |
| 8588 | * Return: none |
| 8589 | */ |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8590 | 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] | 8591 | { |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8592 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8593 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8594 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 8595 | if (level > THROTTLE_LEVEL_0) |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8596 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8597 | else |
| 8598 | /* restore original concurrency mode */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8599 | 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] | 8600 | } |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8601 | #else |
| 8602 | /** |
| 8603 | * hdd_set_thermal_level_cb() - set thermal level callback function |
| 8604 | * @hdd_handle: opaque handle for the hdd context |
| 8605 | * @level: thermal level |
| 8606 | * |
| 8607 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8608 | * than 0, and restore the original data path when throttle level is 0 |
| 8609 | * |
| 8610 | * Return: none |
| 8611 | */ |
| 8612 | static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level) |
| 8613 | { |
| 8614 | } |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8615 | #endif |
| 8616 | |
| 8617 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8618 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8619 | * @adapter: AP adapter |
| 8620 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8621 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8622 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8623 | * Moves the SAP interface by invoking the function which |
| 8624 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8625 | * |
| 8626 | * Return: None |
| 8627 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8628 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8629 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8630 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8631 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8632 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8633 | mac_handle_t mac_handle; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8634 | |
| 8635 | if (!adapter) { |
| 8636 | hdd_err("invalid adapter"); |
| 8637 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8638 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8639 | |
| 8640 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8641 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8642 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 8643 | if (!mac_handle) { |
| 8644 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8645 | return; |
| 8646 | } |
| 8647 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8648 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8649 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8650 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8651 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8652 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8653 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8654 | adapter->vdev_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8655 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8656 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8657 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8658 | 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] | 8659 | { |
| 8660 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8661 | int status; |
| 8662 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8663 | |
| 8664 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8665 | |
| 8666 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8667 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8668 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8669 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8670 | } |
| 8671 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8672 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8673 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8674 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8675 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8676 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8677 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8678 | hdd_err("failed to start external acs timer"); |
| 8679 | return -ENOSPC; |
| 8680 | } |
| 8681 | /* Update config to application */ |
| 8682 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8683 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8684 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8685 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8686 | } |
| 8687 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8688 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8689 | /** |
| 8690 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8691 | * @hdd_ctx: hdd context pointer |
| 8692 | * |
| 8693 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8694 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8695 | * sap. User space on LTE coex indication restart driver. |
| 8696 | * |
| 8697 | * Return - none |
| 8698 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8699 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8700 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8701 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8702 | uint32_t i; |
| 8703 | bool found = false; |
| 8704 | uint8_t restart_chan; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8705 | uint8_t scc_on_lte_coex = 0; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8706 | bool value; |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8707 | QDF_STATUS status; |
| 8708 | bool is_acs_support_for_dfs_ltecoex = cfg_default(CFG_USER_ACS_DFS_LTE); |
| 8709 | bool is_vendor_acs_support = |
| 8710 | cfg_default(CFG_USER_AUTO_CHANNEL_SELECTION); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8711 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8712 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8713 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8714 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8715 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8716 | adapter->device_mode, |
| 8717 | adapter->session.ap.sap_config. |
| 8718 | acs_cfg.acs_mode); |
| 8719 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8720 | } |
| 8721 | |
| 8722 | found = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8723 | status = |
| 8724 | ucfg_policy_mgr_get_sta_sap_scc_lte_coex_chnl(hdd_ctxt->psoc, |
| 8725 | &scc_on_lte_coex); |
| 8726 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8727 | hdd_err("can't get scc on lte coex chnl, use def"); |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8728 | /* |
| 8729 | * If STA+SAP is doing SCC & g_sta_sap_scc_on_lte_coex_chan |
| 8730 | * is set, no need to move SAP. |
| 8731 | */ |
Manikandan Mohan | 956b69e | 2019-02-14 13:08:14 -0800 | [diff] [blame] | 8732 | if ((policy_mgr_is_sta_sap_scc( |
| 8733 | hdd_ctxt->psoc, |
| 8734 | adapter->session.ap.operating_channel) && |
| 8735 | scc_on_lte_coex) || |
| 8736 | policy_mgr_nan_sap_scc_on_unsafe_ch_chk( |
| 8737 | hdd_ctxt->psoc, |
| 8738 | adapter->session.ap.operating_channel)) { |
| 8739 | hdd_debug("SAP allowed in unsafe SCC channel"); |
| 8740 | } else { |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8741 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
| 8742 | if (adapter->session.ap.operating_channel == |
| 8743 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8744 | found = true; |
| 8745 | hdd_debug("operating ch:%d is unsafe", |
| 8746 | adapter->session.ap.operating_channel); |
| 8747 | break; |
| 8748 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8749 | } |
| 8750 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8751 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8752 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8753 | adapter->session.ap.operating_channel); |
| 8754 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8755 | } |
| 8756 | |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8757 | status = ucfg_mlme_get_acs_support_for_dfs_ltecoex( |
| 8758 | hdd_ctxt->psoc, |
| 8759 | &is_acs_support_for_dfs_ltecoex); |
| 8760 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8761 | hdd_err("get_acs_support_for_dfs_ltecoex failed,set def"); |
| 8762 | |
| 8763 | status = ucfg_mlme_get_vendor_acs_support( |
| 8764 | hdd_ctxt->psoc, |
| 8765 | &is_vendor_acs_support); |
| 8766 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8767 | hdd_err("get_vendor_acs_support failed, set default"); |
| 8768 | |
| 8769 | if (is_vendor_acs_support && is_acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8770 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8771 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8772 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8773 | } else |
| 8774 | restart_chan = |
bings | 6c4672b | 2019-03-19 16:00:19 +0800 | [diff] [blame] | 8775 | wlansap_get_safe_channel_from_pcl_and_acs_range( |
| 8776 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8777 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8778 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8779 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8780 | /* |
| 8781 | * SAP restart due to unsafe channel. While |
| 8782 | * restarting the SAP, make sure to clear |
| 8783 | * acs_channel, channel to reset to |
| 8784 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8785 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8786 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8787 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 8788 | ucfg_mlme_get_sap_internal_restart(hdd_ctxt->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8789 | &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8790 | if (value) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8791 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8792 | true); |
hqu | 1d1b922 | 2019-06-11 20:00:55 +0800 | [diff] [blame] | 8793 | else { |
| 8794 | hdd_debug("sending coex indication"); |
| 8795 | wlan_hdd_send_svc_nlink_msg( |
| 8796 | hdd_ctxt->radio_index, |
| 8797 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8798 | return; |
hqu | 1d1b922 | 2019-06-11 20:00:55 +0800 | [diff] [blame] | 8799 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8800 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8801 | } |
| 8802 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8803 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8804 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8805 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8806 | * @hdd_ctx: HDD global context |
| 8807 | * |
| 8808 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8809 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8810 | * down to the lower layers. Then subscribe to subsequent channel |
| 8811 | * avoidance events. |
| 8812 | * |
| 8813 | * Return: None |
| 8814 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8815 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8816 | { |
| 8817 | uint16_t unsafe_channel_count; |
| 8818 | int index; |
| 8819 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8820 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8821 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8822 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8823 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8824 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8825 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8826 | hdd_ctx->unsafe_channel_count); |
| 8827 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8828 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8829 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8830 | |
| 8831 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8832 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8833 | hdd_ctx->unsafe_channel_list[index]); |
| 8834 | |
| 8835 | } |
| 8836 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8837 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8838 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8839 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8840 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8841 | { |
| 8842 | uint8_t restart_chan; |
| 8843 | |
bings | 6c4672b | 2019-03-19 16:00:19 +0800 | [diff] [blame] | 8844 | restart_chan = wlansap_get_safe_channel_from_pcl_and_acs_range( |
| 8845 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8846 | if (!restart_chan) { |
| 8847 | hdd_alert("fail to restart SAP"); |
| 8848 | return; |
| 8849 | } |
| 8850 | |
| 8851 | /* SAP restart due to unsafe channel. While restarting |
| 8852 | * the SAP, make sure to clear acs_channel, channel to |
| 8853 | * reset to 0. Otherwise these settings will override |
| 8854 | * the ACS while restart. |
| 8855 | */ |
| 8856 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8857 | |
| 8858 | hdd_debug("sending coex indication"); |
| 8859 | |
| 8860 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8861 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8862 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8863 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8864 | |
| 8865 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8866 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8867 | { |
| 8868 | uint32_t size; |
| 8869 | uint16_t *unsafe_list; |
| 8870 | uint16_t chan_count; |
| 8871 | |
| 8872 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8873 | return -EINVAL; |
| 8874 | |
| 8875 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8876 | NUM_CHANNELS); |
| 8877 | if (chan_count) { |
| 8878 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8879 | unsafe_list = qdf_mem_malloc(size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8880 | if (!unsafe_list) |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8881 | return -ENOMEM; |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8882 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8883 | } else { |
| 8884 | unsafe_list = NULL; |
| 8885 | } |
| 8886 | |
| 8887 | *local_unsafe_list = unsafe_list; |
| 8888 | *local_unsafe_list_count = chan_count; |
| 8889 | |
| 8890 | return 0; |
| 8891 | } |
| 8892 | |
| 8893 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8894 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8895 | { |
| 8896 | int i, j; |
| 8897 | |
| 8898 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8899 | return true; |
| 8900 | if (local_unsafe_list_count == 0) |
| 8901 | return false; |
| 8902 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8903 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8904 | if (local_unsafe_list[i] == |
| 8905 | hdd_ctx->unsafe_channel_list[j]) |
| 8906 | break; |
| 8907 | if (j >= local_unsafe_list_count) |
| 8908 | break; |
| 8909 | } |
| 8910 | if (i >= local_unsafe_list_count) { |
| 8911 | hdd_info("unsafe chan list same"); |
| 8912 | return false; |
| 8913 | } |
| 8914 | |
| 8915 | return true; |
| 8916 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8917 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8918 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8919 | { |
| 8920 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8921 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8922 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8923 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8924 | { |
| 8925 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8926 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8927 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8928 | |
| 8929 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8930 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8931 | * user space |
| 8932 | * @frame_ind: Management frame data to be informed. |
| 8933 | * |
| 8934 | * This function is used to indicate management frame to |
| 8935 | * user space |
| 8936 | * |
| 8937 | * Return: None |
| 8938 | * |
| 8939 | */ |
| 8940 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8941 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8942 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8943 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8944 | int i; |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8945 | struct ieee80211_mgmt *mgmt = |
| 8946 | (struct ieee80211_mgmt *)frame_ind->frameBuf; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8947 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 8948 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8949 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8950 | return; |
| 8951 | |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8952 | if (frame_ind->frame_len < ieee80211_hdrlen(mgmt->frame_control)) { |
| 8953 | hdd_err(" Invalid frame length"); |
| 8954 | return; |
| 8955 | } |
| 8956 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8957 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 8958 | for (i = 0; i < WLAN_MAX_VDEVS; i++) { |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8959 | adapter = |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 8960 | hdd_get_adapter_by_vdev(hdd_ctx, i); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8961 | if (adapter) |
| 8962 | break; |
| 8963 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8964 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8965 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 8966 | if ((adapter) && |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8967 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8968 | __hdd_indicate_mgmt_frame(adapter, |
| 8969 | frame_ind->frame_len, |
| 8970 | frame_ind->frameBuf, |
| 8971 | frame_ind->frameType, |
| 8972 | frame_ind->rxChan, |
Srinivas Dasari | ea1c133 | 2019-02-18 12:43:23 +0530 | [diff] [blame] | 8973 | frame_ind->rxRssi, |
| 8974 | frame_ind->rx_flags); |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8975 | } |
| 8976 | } |
| 8977 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8978 | } else { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 8979 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, |
| 8980 | frame_ind->sessionId); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8981 | } |
| 8982 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 8983 | if ((adapter) && |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8984 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8985 | __hdd_indicate_mgmt_frame(adapter, |
| 8986 | frame_ind->frame_len, |
| 8987 | frame_ind->frameBuf, |
| 8988 | frame_ind->frameType, |
| 8989 | frame_ind->rxChan, |
Srinivas Dasari | ea1c133 | 2019-02-18 12:43:23 +0530 | [diff] [blame] | 8990 | frame_ind->rxRssi, |
| 8991 | frame_ind->rx_flags); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8992 | } |
| 8993 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8994 | void hdd_acs_response_timeout_handler(void *context) |
| 8995 | { |
| 8996 | struct hdd_external_acs_timer_context *timer_context = |
| 8997 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8998 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8999 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9000 | uint8_t reason; |
| 9001 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9002 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9003 | if (!timer_context) { |
| 9004 | hdd_err("invlaid timer context"); |
| 9005 | return; |
| 9006 | } |
| 9007 | adapter = timer_context->adapter; |
| 9008 | reason = timer_context->reason; |
| 9009 | |
| 9010 | |
| 9011 | if ((!adapter) || |
| 9012 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 9013 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 9014 | return; |
| 9015 | } |
| 9016 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9017 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 9018 | return; |
| 9019 | |
| 9020 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 9021 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 9022 | else |
| 9023 | return; |
| 9024 | |
| 9025 | hdd_err("ACS timeout happened for %s reason %d", |
| 9026 | adapter->dev->name, reason); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9027 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9028 | switch (reason) { |
| 9029 | /* SAP init case */ |
| 9030 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 9031 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 9032 | false); |
| 9033 | wlan_hdd_cfg80211_start_acs(adapter); |
| 9034 | break; |
| 9035 | /* DFS detected on current channel */ |
| 9036 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 9037 | wlan_sap_update_next_channel( |
| 9038 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9039 | sme_update_new_channel_event(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9040 | adapter->vdev_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9041 | break; |
| 9042 | /* LTE coex event on current channel */ |
| 9043 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 9044 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 9045 | break; |
| 9046 | default: |
| 9047 | hdd_info("invalid reason for timer invoke"); |
| 9048 | |
| 9049 | } |
| 9050 | } |
| 9051 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9052 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9053 | * hdd_override_ini_config - Override INI config |
| 9054 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9055 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9056 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9057 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9058 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9059 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9060 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9061 | { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9062 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9063 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9064 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 9065 | ucfg_scan_cfg_set_dfs_chan_scan_allowed(hdd_ctx->psoc, |
| 9066 | enable_dfs_chan_scan); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9067 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9068 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9069 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9070 | if (0 == enable_11d || 1 == enable_11d) { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9071 | status = ucfg_mlme_set_11d_enabled(hdd_ctx->psoc, enable_11d); |
| 9072 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9073 | hdd_err("Failed to set 11d_enable flag"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9074 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 9075 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9076 | if (hdd_ctx->config->action_oui_enable && !ucfg_action_oui_enabled()) { |
| 9077 | hdd_ctx->config->action_oui_enable = 0; |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9078 | hdd_err("Ignore action oui ini, since no action_oui component"); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9079 | } |
Will Huang | 14b120f | 2019-01-14 17:26:14 +0800 | [diff] [blame] | 9080 | |
| 9081 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
| 9082 | hdd_override_all_ps(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9083 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9084 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9085 | #ifdef ENABLE_MTRACE_LOG |
| 9086 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9087 | { |
| 9088 | uint8_t module_id = 0; |
| 9089 | int qdf_print_idx = -1; |
| 9090 | |
| 9091 | qdf_print_idx = qdf_get_pidx(); |
| 9092 | for (module_id = 0; module_id < QDF_MODULE_ID_MAX; module_id++) |
| 9093 | qdf_print_set_category_verbose( |
| 9094 | qdf_print_idx, |
| 9095 | module_id, QDF_TRACE_LEVEL_TRACE, |
| 9096 | hdd_ctx->config->enable_mtrace); |
| 9097 | } |
| 9098 | #else |
| 9099 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9100 | { |
| 9101 | } |
| 9102 | |
| 9103 | #endif |
| 9104 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9105 | /** |
Wu Gao | 8dd9f50 | 2019-04-26 15:04:28 +0800 | [diff] [blame] | 9106 | * hdd_log_level_to_bitmask() - user space log level to host log bitmask |
| 9107 | * @user_log_level: user space log level |
| 9108 | * |
| 9109 | * Convert log level from user space to host log level bitmask. |
| 9110 | * |
| 9111 | * Return: Bitmask of log levels to be enabled |
| 9112 | */ |
| 9113 | static uint32_t hdd_log_level_to_bitmask(enum host_log_level user_log_level) |
| 9114 | { |
| 9115 | QDF_TRACE_LEVEL host_trace_level; |
| 9116 | uint32_t bitmask; |
| 9117 | |
| 9118 | switch (user_log_level) { |
| 9119 | case HOST_LOG_LEVEL_NONE: |
| 9120 | host_trace_level = QDF_TRACE_LEVEL_NONE; |
| 9121 | break; |
| 9122 | case HOST_LOG_LEVEL_FATAL: |
| 9123 | host_trace_level = QDF_TRACE_LEVEL_FATAL; |
| 9124 | break; |
| 9125 | case HOST_LOG_LEVEL_ERROR: |
| 9126 | host_trace_level = QDF_TRACE_LEVEL_ERROR; |
| 9127 | break; |
| 9128 | case HOST_LOG_LEVEL_WARN: |
| 9129 | host_trace_level = QDF_TRACE_LEVEL_WARN; |
| 9130 | break; |
| 9131 | case HOST_LOG_LEVEL_INFO: |
| 9132 | host_trace_level = QDF_TRACE_LEVEL_INFO_LOW; |
| 9133 | break; |
| 9134 | case HOST_LOG_LEVEL_DEBUG: |
| 9135 | host_trace_level = QDF_TRACE_LEVEL_DEBUG; |
| 9136 | break; |
| 9137 | case HOST_LOG_LEVEL_TRACE: |
| 9138 | host_trace_level = QDF_TRACE_LEVEL_TRACE; |
| 9139 | break; |
| 9140 | default: |
| 9141 | host_trace_level = QDF_TRACE_LEVEL_TRACE; |
| 9142 | break; |
| 9143 | } |
| 9144 | |
| 9145 | bitmask = (1 << (host_trace_level + 1)) - 1; |
| 9146 | |
| 9147 | return bitmask; |
| 9148 | } |
| 9149 | |
| 9150 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9151 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 9152 | * @hdd_ctx - HDD context |
| 9153 | * |
| 9154 | * Set trace level for each module based on INI config. |
| 9155 | * |
| 9156 | * Return: None |
| 9157 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9158 | 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] | 9159 | { |
Wu Gao | 8dd9f50 | 2019-04-26 15:04:28 +0800 | [diff] [blame] | 9160 | uint8_t host_module_log[QDF_MODULE_ID_MAX * 2]; |
| 9161 | qdf_size_t host_module_log_num = 0; |
| 9162 | QDF_MODULE_ID module_id; |
| 9163 | uint32_t bitmask; |
| 9164 | uint32_t i; |
| 9165 | |
Wu Gao | bc6eaa1 | 2018-11-30 14:17:45 +0800 | [diff] [blame] | 9166 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, 0x7f); |
Wu Gao | 8dd9f50 | 2019-04-26 15:04:28 +0800 | [diff] [blame] | 9167 | |
| 9168 | qdf_uint8_array_parse(cfg_get(hdd_ctx->psoc, |
| 9169 | CFG_ENABLE_HOST_MODULE_LOG_LEVEL), |
| 9170 | host_module_log, |
| 9171 | QDF_MODULE_ID_MAX * 2, |
| 9172 | &host_module_log_num); |
| 9173 | |
| 9174 | for (i = 0; i + 1 < host_module_log_num; i += 2) { |
| 9175 | module_id = host_module_log[i]; |
| 9176 | bitmask = hdd_log_level_to_bitmask(host_module_log[i + 1]); |
| 9177 | if (module_id < QDF_MODULE_ID_MAX && |
| 9178 | module_id >= QDF_MODULE_ID_MIN) |
| 9179 | hdd_qdf_trace_enable(module_id, bitmask); |
| 9180 | } |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 9181 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9182 | hdd_set_mtrace_for_each(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9183 | } |
| 9184 | |
| 9185 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9186 | * hdd_context_init() - Initialize HDD context |
| 9187 | * @hdd_ctx: HDD context. |
| 9188 | * |
| 9189 | * Initialize HDD context along with all the feature specific contexts. |
| 9190 | * |
| 9191 | * return: 0 on success and errno on failure. |
| 9192 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9193 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9194 | { |
| 9195 | int ret; |
| 9196 | |
| 9197 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 9198 | hdd_ctx->max_intf_count = WLAN_MAX_VDEVS; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9199 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9200 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 9201 | init_completion(&hdd_ctx->ready_to_suspend); |
| 9202 | |
| 9203 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9204 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 9205 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 9206 | qdf_list_create(&hdd_ctx->hdd_adapters, 0); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9207 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9208 | ret = hdd_scan_context_init(hdd_ctx); |
| 9209 | if (ret) |
| 9210 | goto list_destroy; |
| 9211 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9212 | hdd_rx_wake_lock_create(hdd_ctx); |
| 9213 | |
| 9214 | ret = hdd_sap_context_init(hdd_ctx); |
| 9215 | if (ret) |
| 9216 | goto scan_destroy; |
| 9217 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9218 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 9219 | |
| 9220 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 9221 | |
| 9222 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 9223 | hdd_ctx->config); |
| 9224 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 9225 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9226 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 9227 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 9228 | "monitor_mode_wakelock"); |
| 9229 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9230 | return 0; |
| 9231 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9232 | sap_destroy: |
| 9233 | hdd_sap_context_destroy(hdd_ctx); |
| 9234 | |
| 9235 | scan_destroy: |
| 9236 | hdd_scan_context_destroy(hdd_ctx); |
| 9237 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9238 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 9239 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 9240 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9241 | return ret; |
| 9242 | } |
| 9243 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9244 | void hdd_psoc_idle_timer_start(struct hdd_context *hdd_ctx) |
| 9245 | { |
| 9246 | uint32_t timeout_ms = hdd_ctx->config->iface_change_wait_time; |
| 9247 | enum wake_lock_reason reason = |
| 9248 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER; |
| 9249 | |
Rajeev Kumar | 7b7bb3f | 2018-12-20 12:09:54 -0800 | [diff] [blame] | 9250 | if (!timeout_ms) { |
| 9251 | hdd_info("psoc idle timer is disabled"); |
| 9252 | return; |
| 9253 | } |
| 9254 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9255 | hdd_debug("Starting psoc idle timer"); |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9256 | qdf_delayed_work_start(&hdd_ctx->psoc_idle_timeout_work, timeout_ms); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9257 | hdd_prevent_suspend_timeout(timeout_ms, reason); |
| 9258 | } |
| 9259 | |
| 9260 | void hdd_psoc_idle_timer_stop(struct hdd_context *hdd_ctx) |
| 9261 | { |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9262 | qdf_delayed_work_stop_sync(&hdd_ctx->psoc_idle_timeout_work); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9263 | hdd_debug("Stopped psoc idle timer"); |
| 9264 | } |
| 9265 | |
Sourav Mohapatra | 698d6f6 | 2019-01-29 14:49:52 +0530 | [diff] [blame] | 9266 | /* |
| 9267 | * enum hdd_block_shutdown - Control if driver allows modem shutdown |
| 9268 | * @HDD_UNBLOCK_MODEM_SHUTDOWN: Unblock shutdown |
| 9269 | * @HDD_BLOCK_MODEM_SHUTDOWN: Block shutdown |
| 9270 | * |
| 9271 | * On calling pld_block_shutdown API with the given values, modem |
| 9272 | * graceful shutdown is blocked/unblocked. |
| 9273 | */ |
| 9274 | enum hdd_block_shutdown { |
| 9275 | HDD_UNBLOCK_MODEM_SHUTDOWN, |
| 9276 | HDD_BLOCK_MODEM_SHUTDOWN, |
| 9277 | }; |
| 9278 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9279 | /** |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9280 | * __hdd_psoc_idle_shutdown() - perform an idle shutdown on the given psoc |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9281 | * @hdd_ctx: the hdd context which should be shutdown |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9282 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9283 | * When no interfaces are "up" on a psoc, an idle shutdown timer is started. |
| 9284 | * If no interfaces are brought up before the timer expires, we do an |
| 9285 | * "idle shutdown," cutting power to the physical SoC to save power. This is |
| 9286 | * done completely transparently from the perspective of userspace. |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9287 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9288 | * Return: None |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9289 | */ |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9290 | static int __hdd_psoc_idle_shutdown(struct hdd_context *hdd_ctx) |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9291 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9292 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9293 | int errno; |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9294 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9295 | hdd_enter(); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9296 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9297 | errno = osif_psoc_sync_trans_start(hdd_ctx->parent_dev, &psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9298 | if (errno) { |
| 9299 | hdd_info("psoc busy, abort idle shutdown; errno:%d", errno); |
| 9300 | goto exit; |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9301 | } |
Sourav Mohapatra | 698d6f6 | 2019-01-29 14:49:52 +0530 | [diff] [blame] | 9302 | /* Block the modem graceful shutdown till stop modules is completed */ |
| 9303 | pld_block_shutdown(hdd_ctx->parent_dev, HDD_BLOCK_MODEM_SHUTDOWN); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9304 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9305 | osif_psoc_sync_wait_for_ops(psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9306 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9307 | QDF_BUG(!hdd_wlan_stop_modules(hdd_ctx, false)); |
| 9308 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9309 | osif_psoc_sync_trans_stop(psoc_sync); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9310 | |
Sourav Mohapatra | 698d6f6 | 2019-01-29 14:49:52 +0530 | [diff] [blame] | 9311 | pld_block_shutdown(hdd_ctx->parent_dev, HDD_UNBLOCK_MODEM_SHUTDOWN); |
| 9312 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9313 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9314 | hdd_exit(); |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9315 | return errno; |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9316 | } |
| 9317 | |
Rajeev Kumar | 588a254 | 2019-04-08 10:57:19 -0700 | [diff] [blame] | 9318 | static int __hdd_mode_change_psoc_idle_shutdown(struct hdd_context *hdd_ctx) |
| 9319 | { |
| 9320 | is_mode_change_psoc_idle_shutdown = false; |
| 9321 | return hdd_wlan_stop_modules(hdd_ctx, true); |
| 9322 | } |
| 9323 | |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9324 | int hdd_psoc_idle_shutdown(struct device *dev) |
| 9325 | { |
| 9326 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9327 | |
Rajeev Kumar | d62104a | 2019-05-31 12:04:27 -0700 | [diff] [blame] | 9328 | if (!hdd_ctx) { |
| 9329 | hdd_err_rl("hdd ctx is null"); |
| 9330 | return -EINVAL; |
| 9331 | } |
| 9332 | |
Rajeev Kumar | 588a254 | 2019-04-08 10:57:19 -0700 | [diff] [blame] | 9333 | if (is_mode_change_psoc_idle_shutdown) |
| 9334 | return __hdd_mode_change_psoc_idle_shutdown(hdd_ctx); |
| 9335 | else |
| 9336 | return __hdd_psoc_idle_shutdown(hdd_ctx); |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9337 | } |
| 9338 | |
| 9339 | static int __hdd_psoc_idle_restart(struct hdd_context *hdd_ctx) |
| 9340 | { |
| 9341 | return hdd_wlan_start_modules(hdd_ctx, false); |
| 9342 | } |
| 9343 | |
| 9344 | int hdd_psoc_idle_restart(struct device *dev) |
| 9345 | { |
| 9346 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9347 | |
Rajeev Kumar | d62104a | 2019-05-31 12:04:27 -0700 | [diff] [blame] | 9348 | if (!hdd_ctx) { |
| 9349 | hdd_err_rl("hdd ctx is null"); |
| 9350 | return -EINVAL; |
| 9351 | } |
| 9352 | |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9353 | return __hdd_psoc_idle_restart(hdd_ctx); |
| 9354 | } |
| 9355 | |
| 9356 | int hdd_trigger_psoc_idle_restart(struct hdd_context *hdd_ctx) |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9357 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 9358 | QDF_BUG(rtnl_is_locked()); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9359 | |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9360 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 9361 | hdd_psoc_idle_timer_stop(hdd_ctx); |
| 9362 | hdd_info("Driver modules already Enabled"); |
| 9363 | return 0; |
| 9364 | } |
| 9365 | |
| 9366 | pld_idle_restart(hdd_ctx->parent_dev, hdd_psoc_idle_restart); |
| 9367 | |
| 9368 | return 0; |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9369 | } |
| 9370 | |
| 9371 | /** |
| 9372 | * hdd_psoc_idle_timeout_callback() - Handler for psoc idle timeout |
| 9373 | * @priv: pointer to hdd context |
| 9374 | * |
| 9375 | * Return: None |
| 9376 | */ |
| 9377 | static void hdd_psoc_idle_timeout_callback(void *priv) |
| 9378 | { |
| 9379 | struct hdd_context *hdd_ctx = priv; |
| 9380 | |
| 9381 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 9382 | return; |
| 9383 | |
Rajeev Kumar | 473f9af | 2019-04-05 14:25:56 -0700 | [diff] [blame] | 9384 | hdd_info("Psoc idle timeout elapsed; starting psoc shutdown"); |
| 9385 | |
| 9386 | pld_idle_shutdown(hdd_ctx->parent_dev, hdd_psoc_idle_shutdown); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9387 | } |
| 9388 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9389 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9390 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9391 | { |
| 9392 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 9393 | wlan_logging_to_console); |
| 9394 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 9395 | } |
| 9396 | #else |
| 9397 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9398 | { } |
| 9399 | #endif |
| 9400 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9401 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9402 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9403 | struct wlan_objmgr_psoc *psoc) |
| 9404 | { |
| 9405 | config->wlan_logging_enable = cfg_get(psoc, CFG_WLAN_LOGGING_SUPPORT); |
| 9406 | |
| 9407 | config->wlan_logging_to_console = |
| 9408 | cfg_get(psoc, CFG_WLAN_LOGGING_CONSOLE_SUPPORT); |
| 9409 | } |
| 9410 | #else |
| 9411 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9412 | struct wlan_objmgr_psoc *psoc) |
| 9413 | { |
| 9414 | } |
| 9415 | #endif |
| 9416 | |
| 9417 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9418 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9419 | struct wlan_objmgr_psoc *psoc) |
| 9420 | { |
| 9421 | config->wlan_auto_shutdown = cfg_get(psoc, CFG_WLAN_AUTO_SHUTDOWN); |
| 9422 | } |
| 9423 | #else |
| 9424 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9425 | struct wlan_objmgr_psoc *psoc) |
| 9426 | { |
| 9427 | } |
| 9428 | #endif |
| 9429 | |
| 9430 | #ifndef REMOVE_PKT_LOG |
| 9431 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9432 | struct wlan_objmgr_psoc *psoc) |
| 9433 | { |
| 9434 | config->enable_packet_log = cfg_get(psoc, CFG_ENABLE_PACKET_LOG); |
| 9435 | } |
| 9436 | #else |
| 9437 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9438 | struct wlan_objmgr_psoc *psoc) |
| 9439 | { |
| 9440 | } |
| 9441 | #endif |
| 9442 | |
Sandeep Puligilla | 43b6d1a | 2018-12-03 09:16:13 -0800 | [diff] [blame] | 9443 | #ifdef ENABLE_MTRACE_LOG |
| 9444 | static void hdd_init_mtrace_log(struct hdd_config *config, |
| 9445 | struct wlan_objmgr_psoc *psoc) |
| 9446 | { |
| 9447 | config->enable_mtrace = cfg_get(psoc, CFG_ENABLE_MTRACE); |
| 9448 | } |
| 9449 | #else |
| 9450 | static void hdd_init_mtrace_log(struct hdd_config *config, |
| 9451 | struct wlan_objmgr_psoc *psoc) |
| 9452 | { |
| 9453 | } |
| 9454 | #endif |
| 9455 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9456 | #ifdef FEATURE_RUNTIME_PM |
| 9457 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9458 | struct wlan_objmgr_psoc *psoc) |
| 9459 | { |
| 9460 | config->runtime_pm = cfg_get(psoc, CFG_ENABLE_RUNTIME_PM); |
| 9461 | } |
| 9462 | #else |
| 9463 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9464 | struct wlan_objmgr_psoc *psoc) |
| 9465 | |
| 9466 | { |
| 9467 | } |
| 9468 | #endif |
| 9469 | |
| 9470 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 9471 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9472 | struct wlan_objmgr_psoc *psoc) |
| 9473 | { |
| 9474 | config->vc_mode_cfg_bitmap = cfg_get(psoc, CFG_VC_MODE_BITMAP); |
| 9475 | } |
| 9476 | #else |
| 9477 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9478 | struct wlan_objmgr_psoc *psoc) |
| 9479 | { |
| 9480 | } |
| 9481 | #endif |
| 9482 | |
gaurank kathpalia | 566c81b | 2019-02-20 14:31:45 +0530 | [diff] [blame] | 9483 | #ifdef DHCP_SERVER_OFFLOAD |
| 9484 | static void |
| 9485 | hdd_init_dhcp_server_ip(struct hdd_context *hdd_ctx) |
| 9486 | { |
| 9487 | uint8_t num_entries; |
| 9488 | |
| 9489 | hdd_ctx->config->dhcp_server_ip.is_dhcp_server_ip_valid = true; |
| 9490 | hdd_string_to_u8_array(cfg_get(hdd_ctx->psoc, CFG_DHCP_SERVER_IP_NAME), |
| 9491 | hdd_ctx->config->dhcp_server_ip.dhcp_server_ip, |
| 9492 | &num_entries, IPADDR_NUM_ENTRIES); |
| 9493 | |
| 9494 | if (num_entries != IPADDR_NUM_ENTRIES) { |
| 9495 | hdd_err("Incorrect IP address (%s) assigned for DHCP server!", |
| 9496 | cfg_get(hdd_ctx->psoc, CFG_DHCP_SERVER_IP_NAME)); |
| 9497 | hdd_config->dhcp_server_ip.is_dhcp_server_ip_valid = false; |
| 9498 | } |
| 9499 | } |
| 9500 | #else |
| 9501 | static void |
| 9502 | hdd_init_dhcp_server_ip(struct hdd_context *hdd_ctx) |
| 9503 | { |
| 9504 | } |
| 9505 | #endif |
| 9506 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9507 | /** |
| 9508 | * hdd_cfg_params_init() - Initialize hdd params in hdd_config strucuture |
| 9509 | * @hdd_ctx - Pointer to HDD context |
| 9510 | * |
| 9511 | * Return: None |
| 9512 | */ |
| 9513 | static void hdd_cfg_params_init(struct hdd_context *hdd_ctx) |
| 9514 | { |
| 9515 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
| 9516 | struct hdd_config *config = hdd_ctx->config; |
| 9517 | |
| 9518 | if (!psoc) { |
| 9519 | hdd_err("Invalid psoc"); |
| 9520 | return; |
| 9521 | } |
| 9522 | |
| 9523 | if (!config) { |
| 9524 | hdd_err("Invalid hdd config"); |
| 9525 | return; |
| 9526 | } |
| 9527 | |
gaurank kathpalia | 43c5262 | 2019-02-11 12:30:05 +0530 | [diff] [blame] | 9528 | config->dot11Mode = cfg_get(psoc, CFG_HDD_DOT11_MODE); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9529 | config->bug_on_reinit_failure = cfg_get(psoc, |
| 9530 | CFG_BUG_ON_REINIT_FAILURE); |
| 9531 | |
| 9532 | config->is_ramdump_enabled = cfg_get(psoc, |
| 9533 | CFG_ENABLE_RAMDUMP_COLLECTION); |
| 9534 | |
| 9535 | config->iface_change_wait_time = cfg_get(psoc, |
| 9536 | CFG_INTERFACE_CHANGE_WAIT); |
| 9537 | |
| 9538 | config->multicast_host_fw_msgs = cfg_get(psoc, |
| 9539 | CFG_MULTICAST_HOST_FW_MSGS); |
| 9540 | |
| 9541 | config->private_wext_control = cfg_get(psoc, CFG_PRIVATE_WEXT_CONTROL); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9542 | config->enablefwprint = cfg_get(psoc, CFG_ENABLE_FW_UART_PRINT); |
| 9543 | config->enable_fw_log = cfg_get(psoc, CFG_ENABLE_FW_LOG); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9544 | config->operating_channel = cfg_get(psoc, CFG_OPERATING_CHANNEL); |
| 9545 | config->num_vdevs = cfg_get(psoc, CFG_NUM_VDEV_ENABLE); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9546 | qdf_str_lcopy(config->enable_concurrent_sta, |
| 9547 | cfg_get(psoc, CFG_ENABLE_CONCURRENT_STA), |
| 9548 | CFG_CONCURRENT_IFACE_MAX_LEN); |
| 9549 | qdf_str_lcopy(config->dbs_scan_selection, |
| 9550 | cfg_get(psoc, CFG_DBS_SCAN_SELECTION), |
| 9551 | CFG_DBS_SCAN_PARAM_LENGTH); |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9552 | 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] | 9553 | config->mac_provision = cfg_get(psoc, CFG_ENABLE_MAC_PROVISION); |
| 9554 | config->provisioned_intf_pool = |
| 9555 | cfg_get(psoc, CFG_PROVISION_INTERFACE_POOL); |
| 9556 | config->derived_intf_pool = cfg_get(psoc, CFG_DERIVED_INTERFACE_POOL); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9557 | config->action_oui_enable = cfg_get(psoc, CFG_ENABLE_ACTION_OUI); |
Jeff Johnson | 15a88ac | 2019-03-11 14:35:25 -0700 | [diff] [blame] | 9558 | config->advertise_concurrent_operation = |
Sandeep Puligilla | dc6d68a | 2019-01-04 16:57:12 -0800 | [diff] [blame] | 9559 | cfg_get(psoc, |
| 9560 | CFG_ADVERTISE_CONCURRENT_OPERATION); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9561 | qdf_str_lcopy(config->action_oui_str[0], |
| 9562 | cfg_get(psoc, CFG_ACTION_OUI_CONNECT_1X1), |
| 9563 | ACTION_OUI_MAX_STR_LEN); |
| 9564 | qdf_str_lcopy(config->action_oui_str[1], |
| 9565 | cfg_get(psoc, CFG_ACTION_OUI_ITO_EXTENSION), |
| 9566 | ACTION_OUI_MAX_STR_LEN); |
| 9567 | qdf_str_lcopy(config->action_oui_str[2], |
| 9568 | cfg_get(psoc, CFG_ACTION_OUI_CCKM_1X1), |
| 9569 | ACTION_OUI_MAX_STR_LEN); |
| 9570 | qdf_str_lcopy(config->action_oui_str[3], |
| 9571 | cfg_get(psoc, CFG_ACTION_OUI_ITO_ALTERNATE), |
| 9572 | ACTION_OUI_MAX_STR_LEN); |
| 9573 | qdf_str_lcopy(config->action_oui_str[4], |
| 9574 | cfg_get(psoc, CFG_ACTION_OUI_SWITCH_TO_11N_MODE), |
| 9575 | ACTION_OUI_MAX_STR_LEN); |
| 9576 | qdf_str_lcopy(config->action_oui_str[5], |
| 9577 | cfg_get(psoc, |
| 9578 | CFG_ACTION_OUI_CONNECT_1X1_WITH_1_CHAIN), |
| 9579 | ACTION_OUI_MAX_STR_LEN); |
Rajeev Kumar Sirasanagandla | d7987f1 | 2018-12-08 23:24:04 +0530 | [diff] [blame] | 9580 | qdf_str_lcopy(config->action_oui_str[6], |
| 9581 | cfg_get(psoc, |
| 9582 | CFG_ACTION_OUI_DISABLE_AGGRESSIVE_TX), |
| 9583 | ACTION_OUI_MAX_STR_LEN); |
Yeshwanth Sriram Guntuka | 22ed800 | 2019-05-07 15:08:09 +0530 | [diff] [blame] | 9584 | qdf_str_lcopy(config->action_oui_str[ACTION_OUI_FORCE_MAX_NSS], |
| 9585 | cfg_get(psoc, CFG_ACTION_OUI_FORCE_MAX_NSS), |
| 9586 | ACTION_OUI_MAX_STR_LEN); |
Sourav Mohapatra | 9e014cf | 2018-12-11 09:39:33 +0530 | [diff] [blame] | 9587 | config->enable_rtt_support = cfg_get(psoc, CFG_ENABLE_RTT_SUPPORT); |
Sandeep Puligilla | efeb4a9 | 2019-01-08 00:06:51 -0800 | [diff] [blame] | 9588 | config->is_unit_test_framework_enabled = |
| 9589 | cfg_get(psoc, CFG_ENABLE_UNIT_TEST_FRAMEWORK); |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 9590 | config->disable_channel = cfg_get(psoc, CFG_ENABLE_DISABLE_CHANNEL); |
Ashish Kumar Dhanotiya | 9549818 | 2019-04-29 13:59:20 +0530 | [diff] [blame] | 9591 | config->sar_version = cfg_get(psoc, CFG_SAR_VERSION); |
Rajeev Kumar | 3a7c340 | 2019-05-02 16:02:20 -0700 | [diff] [blame] | 9592 | config->is_wow_disabled = cfg_get(psoc, CFG_WOW_DISABLE); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9593 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9594 | hdd_init_vc_mode_cfg_bitmap(config, psoc); |
| 9595 | hdd_init_runtime_pm(config, psoc); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9596 | hdd_init_wlan_auto_shutdown(config, psoc); |
| 9597 | hdd_init_wlan_logging_params(config, psoc); |
| 9598 | hdd_init_packet_log(config, psoc); |
Sandeep Puligilla | 43b6d1a | 2018-12-03 09:16:13 -0800 | [diff] [blame] | 9599 | hdd_init_mtrace_log(config, psoc); |
gaurank kathpalia | 566c81b | 2019-02-20 14:31:45 +0530 | [diff] [blame] | 9600 | hdd_init_dhcp_server_ip(hdd_ctx); |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 9601 | hdd_dp_cfg_update(psoc, hdd_ctx); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9602 | } |
| 9603 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 9604 | struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9605 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9606 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9607 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9608 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9609 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9610 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9611 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 9612 | hdd_ctx = hdd_cfg80211_wiphy_alloc(); |
| 9613 | if (!hdd_ctx) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9614 | ret = -ENOMEM; |
| 9615 | goto err_out; |
| 9616 | } |
| 9617 | |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9618 | status = qdf_delayed_work_create(&hdd_ctx->psoc_idle_timeout_work, |
| 9619 | hdd_psoc_idle_timeout_callback, |
| 9620 | hdd_ctx); |
| 9621 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9622 | ret = qdf_status_to_os_return(status); |
| 9623 | goto wiphy_dealloc; |
| 9624 | } |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9625 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9626 | hdd_ctx->parent_dev = dev; |
Jeff Johnson | 995fd51 | 2019-03-06 08:45:10 -0800 | [diff] [blame] | 9627 | hdd_ctx->last_scan_reject_vdev_id = WLAN_UMAC_VDEV_ID_MAX; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9628 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9629 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9630 | if (!hdd_ctx->config) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9631 | ret = -ENOMEM; |
| 9632 | goto err_free_hdd_context; |
| 9633 | } |
| 9634 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 9635 | status = cfg_parse(WLAN_INI_FILE); |
| 9636 | if (QDF_IS_STATUS_ERROR(status)) |
| 9637 | hdd_err("Failed to parse cfg %s; status:%d\n", |
| 9638 | WLAN_INI_FILE, status); |
| 9639 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9640 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID); |
| 9641 | if (ret) { |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9642 | QDF_DEBUG_PANIC("Psoc creation fails!"); |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9643 | goto err_free_config; |
| 9644 | } |
| 9645 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9646 | hdd_cfg_params_init(hdd_ctx); |
| 9647 | |
Dustin Brown | 4bbd546 | 2019-03-22 11:18:13 -0700 | [diff] [blame] | 9648 | /* apply multiplier config, if not already set via module parameter */ |
| 9649 | if (qdf_timer_get_multiplier() == 1) |
| 9650 | qdf_timer_set_multiplier(cfg_get(hdd_ctx->psoc, |
| 9651 | CFG_TIMER_MULTIPLIER)); |
Dustin Brown | a9a8452 | 2019-02-04 12:25:40 -0800 | [diff] [blame] | 9652 | hdd_debug("set timer multiplier: %u", qdf_timer_get_multiplier()); |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 9653 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9654 | cds_set_fatal_event(cfg_get(hdd_ctx->psoc, |
| 9655 | CFG_ENABLE_FATAL_EVENT_TRIGGER)); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 9656 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9657 | hdd_override_ini_config(hdd_ctx); |
| 9658 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9659 | ret = hdd_context_init(hdd_ctx); |
| 9660 | |
| 9661 | if (ret) |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9662 | goto err_hdd_objmgr_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9663 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 9664 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE || |
| 9665 | hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9666 | goto skip_multicast_logging; |
| 9667 | |
| 9668 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 9669 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9670 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 9671 | if (ret) |
| 9672 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9673 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9674 | ret = hdd_init_netlink_services(hdd_ctx); |
| 9675 | if (ret) |
| 9676 | goto err_deinit_txrx_histogram; |
| 9677 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9678 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9679 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9680 | skip_multicast_logging: |
| 9681 | hdd_set_trace_level_for_each(hdd_ctx); |
| 9682 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 9683 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 9684 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9685 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 9686 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9687 | return hdd_ctx; |
| 9688 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9689 | err_deinit_txrx_histogram: |
| 9690 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 9691 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9692 | err_deinit_hdd_context: |
| 9693 | hdd_context_deinit(hdd_ctx); |
| 9694 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9695 | err_hdd_objmgr_destroy: |
| 9696 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 9697 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9698 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9699 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9700 | |
| 9701 | err_free_hdd_context: |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9702 | qdf_delayed_work_destroy(&hdd_ctx->psoc_idle_timeout_work); |
| 9703 | |
| 9704 | wiphy_dealloc: |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 9705 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9706 | |
| 9707 | err_out: |
| 9708 | return ERR_PTR(ret); |
| 9709 | } |
| 9710 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9711 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9712 | * hdd_start_station_adapter()- Start the Station Adapter |
| 9713 | * @adapter: HDD adapter |
| 9714 | * |
| 9715 | * This function initializes the adapter for the station mode. |
| 9716 | * |
| 9717 | * Return: 0 on success or errno on failure. |
| 9718 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9719 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9720 | { |
| 9721 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9722 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9723 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9724 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9725 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9726 | hdd_err("session is already opened, %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9727 | adapter->vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9728 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9729 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9730 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9731 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 9732 | if (ret) { |
| 9733 | hdd_err("failed to create vdev: %d", ret); |
| 9734 | return ret; |
| 9735 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9736 | status = hdd_init_station_mode(adapter); |
| 9737 | |
| 9738 | if (QDF_STATUS_SUCCESS != status) { |
| 9739 | hdd_err("Error Initializing station mode: %d", status); |
| 9740 | return qdf_status_to_os_return(status); |
| 9741 | } |
| 9742 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9743 | hdd_register_tx_flow_control(adapter, |
| 9744 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9745 | hdd_tx_resume_cb, |
| 9746 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9747 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 9748 | hdd_register_hl_netdev_fc_timer(adapter, |
| 9749 | hdd_tx_resume_timer_expired_handler); |
| 9750 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9751 | hdd_exit(); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 9752 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9753 | return 0; |
| 9754 | } |
| 9755 | |
| 9756 | /** |
| 9757 | * hdd_start_ap_adapter()- Start AP Adapter |
| 9758 | * @adapter: HDD adapter |
| 9759 | * |
| 9760 | * This function initializes the adapter for the AP mode. |
| 9761 | * |
| 9762 | * Return: 0 on success errno on failure. |
| 9763 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9764 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9765 | { |
| 9766 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9767 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9768 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9769 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9770 | uint32_t fine_time_meas_cap = 0; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9771 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9772 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9773 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9774 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9775 | hdd_err("session is already opened, %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9776 | adapter->vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9777 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9778 | } |
| 9779 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9780 | * In SSR case no need to create new sap context. |
| 9781 | * Otherwise create sap context first and then create |
| 9782 | * vdev as while creating the vdev, driver needs to |
| 9783 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9784 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9785 | if (adapter->session.ap.sap_context) { |
| 9786 | is_ssr = true; |
| 9787 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9788 | hdd_err("sap creation failed"); |
| 9789 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 9790 | } |
| 9791 | |
| 9792 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 9793 | adapter->session.ap.sap_context); |
| 9794 | if (ret) { |
| 9795 | hdd_err("failed to create vdev, status:%d", ret); |
| 9796 | hdd_sap_destroy_ctx(adapter); |
| 9797 | return ret; |
| 9798 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9799 | |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9800 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 9801 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 9802 | &fine_time_meas_cap); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9803 | sme_cli_set_command(adapter->vdev_id, |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9804 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9805 | (bool)(fine_time_meas_cap & WMI_FW_AP_RTT_RESPR), |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9806 | VDEV_CMD); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9807 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9808 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9809 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9810 | |
| 9811 | if (QDF_STATUS_SUCCESS != status) { |
| 9812 | hdd_err("Error Initializing the AP mode: %d", status); |
| 9813 | return qdf_status_to_os_return(status); |
| 9814 | } |
| 9815 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9816 | hdd_register_tx_flow_control(adapter, |
| 9817 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9818 | hdd_softap_tx_resume_cb, |
| 9819 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9820 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 9821 | hdd_register_hl_netdev_fc_timer(adapter, |
| 9822 | hdd_tx_resume_timer_expired_handler); |
| 9823 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9824 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9825 | return 0; |
| 9826 | } |
| 9827 | |
hangtian | b9c9136 | 2019-06-07 10:39:38 +0800 | [diff] [blame] | 9828 | #if defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(QCA_LL_PDEV_TX_FLOW_CONTROL) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9829 | /** |
| 9830 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9831 | * @cds_cfg: CDS Configuration |
| 9832 | * @hdd_ctx: Pointer to hdd context |
| 9833 | * |
| 9834 | * Return: none |
| 9835 | */ |
| 9836 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9837 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9838 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9839 | { |
| 9840 | cds_cfg->tx_flow_stop_queue_th = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9841 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9842 | cds_cfg->tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9843 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 9844 | /* configuration for DP RX Threads */ |
| 9845 | cds_cfg->enable_dp_rx_threads = hdd_ctx->enable_dp_rx_threads; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9846 | } |
hangtian | b9c9136 | 2019-06-07 10:39:38 +0800 | [diff] [blame] | 9847 | #else |
| 9848 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9849 | *cds_cfg, |
| 9850 | struct hdd_context *hdd_ctx) |
| 9851 | { |
| 9852 | } |
| 9853 | #endif |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9854 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9855 | /** |
| 9856 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9857 | * @hdd_ctx: HDD Context |
| 9858 | * |
| 9859 | * Return: 0 for Success, errno on failure |
| 9860 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9861 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9862 | { |
| 9863 | struct cds_config_info *cds_cfg; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9864 | int value; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9865 | uint8_t band_capability; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9866 | uint8_t ito_repeat_count; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9867 | bool crash_inject; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9868 | bool self_recovery; |
| 9869 | bool fw_timeout_crash; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9870 | QDF_STATUS status; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9871 | |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9872 | cds_cfg = qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9873 | if (!cds_cfg) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9874 | return -ENOMEM; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9875 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9876 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 9877 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 9878 | &cds_cfg->sta_maxlimod_dtim); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9879 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9880 | status = ucfg_mlme_get_crash_inject(hdd_ctx->psoc, &crash_inject); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9881 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9882 | hdd_err("Failed to get crash inject ini config"); |
| 9883 | goto exit; |
| 9884 | } |
| 9885 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9886 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 9887 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9888 | hdd_err("Failed to get self recovery ini config"); |
| 9889 | goto exit; |
| 9890 | } |
| 9891 | |
| 9892 | status = ucfg_mlme_get_fw_timeout_crash(hdd_ctx->psoc, |
| 9893 | &fw_timeout_crash); |
| 9894 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9895 | hdd_err("Failed to get fw timeout crash ini config"); |
| 9896 | goto exit; |
| 9897 | } |
| 9898 | |
| 9899 | status = ucfg_mlme_get_ito_repeat_count(hdd_ctx->psoc, |
| 9900 | &ito_repeat_count); |
| 9901 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9902 | hdd_err("Failed to get ITO repeat count ini config"); |
| 9903 | goto exit; |
| 9904 | } |
| 9905 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9906 | cds_cfg->force_target_assert_enabled = crash_inject; |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9907 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9908 | ucfg_mlme_get_sap_max_offload_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9909 | cds_cfg->ap_maxoffload_peers = value; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9910 | ucfg_mlme_get_sap_max_offload_reorder_buffs(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9911 | &value); |
| 9912 | cds_cfg->ap_maxoffload_reorderbuffs = value; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9913 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9914 | cds_cfg->reorder_offload = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9915 | cfg_get(hdd_ctx->psoc, CFG_DP_REORDER_OFFLOAD_SUPPORT); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9916 | |
| 9917 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9918 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9919 | |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9920 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9921 | ucfg_mlme_get_sap_max_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9922 | cds_cfg->max_station = value; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9923 | 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] | 9924 | cds_cfg->max_msdus_per_rxinorderind = |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 9925 | cfg_get(hdd_ctx->psoc, CFG_DP_MAX_MSDUS_PER_RXIND); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9926 | cds_cfg->self_recovery_enabled = self_recovery; |
| 9927 | cds_cfg->fw_timeout_crash = fw_timeout_crash; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9928 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9929 | cds_cfg->ito_repeat_count = ito_repeat_count; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9930 | |
| 9931 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9932 | if (QDF_IS_STATUS_ERROR(status)) |
| 9933 | goto exit; |
| 9934 | |
| 9935 | cds_cfg->bandcapability = band_capability; |
Rachit Kankane | 0106e38 | 2018-05-16 18:59:28 +0530 | [diff] [blame] | 9936 | cds_cfg->num_vdevs = hdd_ctx->config->num_vdevs; |
Jiani Liu | 6d3b6a1 | 2019-05-08 15:15:06 +0800 | [diff] [blame] | 9937 | cds_cfg->enable_tx_compl_tsf64 = |
| 9938 | hdd_tsf_is_tsf64_tx_set(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9939 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9940 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9941 | cds_init_ini_config(cds_cfg); |
| 9942 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9943 | |
| 9944 | exit: |
| 9945 | qdf_mem_free(cds_cfg); |
| 9946 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9947 | } |
| 9948 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9949 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9950 | * hdd_update_user_config() - API to update user configuration |
| 9951 | * parameters to obj mgr which are used by multiple components |
| 9952 | * @hdd_ctx: HDD Context |
| 9953 | * |
| 9954 | * Return: 0 for Success, errno on failure |
| 9955 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9956 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9957 | { |
| 9958 | struct wlan_objmgr_psoc_user_config *user_config; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9959 | uint8_t band_capability; |
| 9960 | QDF_STATUS status; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9961 | bool value = false; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9962 | |
| 9963 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9964 | if (QDF_IS_STATUS_ERROR(status)) |
| 9965 | return -EIO; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9966 | |
| 9967 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9968 | if (!user_config) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9969 | return -ENOMEM; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9970 | |
| 9971 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9972 | status = ucfg_mlme_is_11d_enabled(hdd_ctx->psoc, &value); |
| 9973 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9974 | hdd_err("Invalid 11d_enable flag"); |
| 9975 | user_config->is_11d_support_enabled = value; |
| 9976 | |
| 9977 | value = false; |
| 9978 | status = ucfg_mlme_is_11h_enabled(hdd_ctx->psoc, &value); |
| 9979 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9980 | hdd_err("Invalid 11h_enable flag"); |
| 9981 | user_config->is_11h_support_enabled = value; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9982 | user_config->band_capability = band_capability; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9983 | wlan_objmgr_psoc_set_user_config(hdd_ctx->psoc, user_config); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9984 | |
| 9985 | qdf_mem_free(user_config); |
| 9986 | return 0; |
| 9987 | } |
| 9988 | |
| 9989 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9990 | * hdd_init_thermal_info - Initialize thermal level |
| 9991 | * @hdd_ctx: HDD context |
| 9992 | * |
| 9993 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9994 | * which would be called when a configured thermal threshold is hit. |
| 9995 | * |
| 9996 | * Return: 0 on success and errno on failure |
| 9997 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9998 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9999 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10000 | QDF_STATUS status; |
Manikandan Mohan | 9045e2e | 2018-11-26 16:44:19 -0800 | [diff] [blame] | 10001 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 10002 | |
Manikandan Mohan | 9045e2e | 2018-11-26 16:44:19 -0800 | [diff] [blame] | 10003 | status = sme_init_thermal_info(mac_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 10004 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10005 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 10006 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 10007 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10008 | sme_add_set_thermal_level_callback(mac_handle, |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 10009 | hdd_set_thermal_level_cb); |
| 10010 | |
| 10011 | return 0; |
| 10012 | |
| 10013 | } |
| 10014 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10015 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 10016 | /** |
| 10017 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 10018 | * |
| 10019 | * Hold RTNL lock |
| 10020 | * |
| 10021 | * Return: True if held and false otherwise |
| 10022 | */ |
| 10023 | static inline bool hdd_hold_rtnl_lock(void) |
| 10024 | { |
| 10025 | rtnl_lock(); |
| 10026 | return true; |
| 10027 | } |
| 10028 | |
| 10029 | /** |
| 10030 | * hdd_release_rtnl_lock - Release RTNL lock |
| 10031 | * |
| 10032 | * Release RTNL lock |
| 10033 | * |
| 10034 | * Return: None |
| 10035 | */ |
| 10036 | static inline void hdd_release_rtnl_lock(void) |
| 10037 | { |
| 10038 | rtnl_unlock(); |
| 10039 | } |
| 10040 | #else |
| 10041 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 10042 | static inline void hdd_release_rtnl_lock(void) { } |
| 10043 | #endif |
| 10044 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10045 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10046 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10047 | /* MAX iwpriv command support */ |
| 10048 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10049 | #define PKTLOG_CLEAR_BUFF 4 |
Venkata Sharath Chandra Manchala | 27e4490 | 2019-01-28 11:29:18 -0800 | [diff] [blame] | 10050 | /* Set Maximum pktlog file size to 64MB */ |
| 10051 | #define MAX_PKTLOG_SIZE 64 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10052 | |
| 10053 | /** |
| 10054 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 10055 | * @hdd_ctx: hdd context |
| 10056 | * @set_value2: pktlog buffer size value |
| 10057 | * |
| 10058 | * |
| 10059 | * Return: 0 for success or error. |
| 10060 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10061 | 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] | 10062 | { |
| 10063 | struct sir_wifi_start_log start_log = { 0 }; |
| 10064 | QDF_STATUS status; |
| 10065 | |
| 10066 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10067 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 10068 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10069 | start_log.user_triggered = 1; |
| 10070 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10071 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10072 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10073 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10074 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10075 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10076 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10077 | return -EINVAL; |
| 10078 | } |
| 10079 | |
| 10080 | return 0; |
| 10081 | } |
| 10082 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10083 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10084 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 10085 | * @hdd_ctx: hdd context |
| 10086 | * |
| 10087 | * Return: 0 for success or error. |
| 10088 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10089 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10090 | { |
| 10091 | struct sir_wifi_start_log start_log; |
| 10092 | QDF_STATUS status; |
| 10093 | |
| 10094 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10095 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 10096 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10097 | start_log.user_triggered = 1; |
| 10098 | start_log.size = 0; |
| 10099 | start_log.is_pktlog_buff_clear = true; |
| 10100 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10101 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10102 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10103 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10104 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10105 | return -EINVAL; |
| 10106 | } |
| 10107 | |
| 10108 | return 0; |
| 10109 | } |
| 10110 | |
| 10111 | |
| 10112 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10113 | * hdd_process_pktlog_command() - process pktlog command |
| 10114 | * @hdd_ctx: hdd context |
| 10115 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10116 | * @set_value2: pktlog buffer size value |
| 10117 | * |
| 10118 | * This function process pktlog command. |
| 10119 | * set_value2 only matters when set_value is 3 (set buff size) |
| 10120 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10121 | * |
| 10122 | * Return: 0 for success or error. |
| 10123 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10124 | 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] | 10125 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10126 | { |
| 10127 | int ret; |
| 10128 | bool enable; |
| 10129 | uint8_t user_triggered = 0; |
| 10130 | |
| 10131 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10132 | if (0 != ret) |
| 10133 | return ret; |
| 10134 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10135 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10136 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10137 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10138 | hdd_err("invalid pktlog value %d", set_value); |
| 10139 | return -EINVAL; |
| 10140 | } |
| 10141 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10142 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 10143 | if (set_value2 <= 0) { |
| 10144 | hdd_err("invalid pktlog size %d", set_value2); |
| 10145 | return -EINVAL; |
| 10146 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
Venkata Sharath Chandra Manchala | 27e4490 | 2019-01-28 11:29:18 -0800 | [diff] [blame] | 10147 | hdd_err_rl("Pktlog size is large. max value is %uMB.", |
| 10148 | MAX_PKTLOG_SIZE); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10149 | return -EINVAL; |
| 10150 | } |
| 10151 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10152 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 10153 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10154 | } |
| 10155 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10156 | /* |
| 10157 | * set_value = 0 then disable packetlog |
| 10158 | * set_value = 1 enable packetlog forcefully |
| 10159 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 10160 | * enable packetlog with AUTO type. |
| 10161 | */ |
| 10162 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 10163 | true : false; |
| 10164 | |
| 10165 | if (1 == set_value) { |
| 10166 | enable = true; |
| 10167 | user_triggered = 1; |
| 10168 | } |
| 10169 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10170 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10171 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10172 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10173 | /** |
| 10174 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 10175 | * @hdd_ctx: HDD context |
| 10176 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10177 | * @user_triggered: triggered through iwpriv |
| 10178 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10179 | * |
| 10180 | * Return: 0 on success; error number otherwise |
| 10181 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10182 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10183 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10184 | { |
| 10185 | struct sir_wifi_start_log start_log; |
| 10186 | QDF_STATUS status; |
| 10187 | |
| 10188 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10189 | start_log.verbose_level = |
| 10190 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10191 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10192 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10193 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10194 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 10195 | /* |
| 10196 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 10197 | * commands. Host uses this flag to decide whether to send pktlog |
| 10198 | * disable command to fw without sending pktlog enable command |
| 10199 | * previously. For eg, If vendor sends pktlog disable command without |
| 10200 | * sending pktlog enable command, then host discards the packet |
| 10201 | * but for iwpriv command, host will send it to fw. |
| 10202 | */ |
| 10203 | start_log.is_iwpriv_command = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10204 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10205 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10206 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10207 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10208 | return -EINVAL; |
| 10209 | } |
| 10210 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10211 | if (enable == true) |
| 10212 | hdd_ctx->is_pktlog_enabled = 1; |
| 10213 | else |
| 10214 | hdd_ctx->is_pktlog_enabled = 0; |
| 10215 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10216 | return 0; |
| 10217 | } |
| 10218 | #endif /* REMOVE_PKT_LOG */ |
| 10219 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10220 | void hdd_free_mac_address_lists(struct hdd_context *hdd_ctx) |
| 10221 | { |
| 10222 | hdd_debug("Resetting MAC address lists"); |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 10223 | qdf_mem_zero(hdd_ctx->provisioned_mac_addr, |
| 10224 | sizeof(hdd_ctx->provisioned_mac_addr)); |
| 10225 | qdf_mem_zero(hdd_ctx->derived_mac_addr, |
| 10226 | sizeof(hdd_ctx->derived_mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10227 | hdd_ctx->num_provisioned_addr = 0; |
| 10228 | hdd_ctx->num_derived_addr = 0; |
| 10229 | hdd_ctx->provisioned_intf_addr_mask = 0; |
| 10230 | hdd_ctx->derived_intf_addr_mask = 0; |
| 10231 | } |
| 10232 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10233 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10234 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 10235 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10236 | * @dev: Device Pointer |
| 10237 | * @num: Number of Valid Mac address |
| 10238 | * |
| 10239 | * Return: Pointer to MAC address buffer |
| 10240 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10241 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 10242 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10243 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10244 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10245 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10246 | |
| 10247 | /** |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10248 | * hdd_get_platform_wlan_derived_mac_buff() - API to query platform driver |
| 10249 | * for derived MAC address |
| 10250 | * @dev: Device Pointer |
| 10251 | * @num: Number of Valid Mac address |
| 10252 | * |
| 10253 | * Return: Pointer to MAC address buffer |
| 10254 | */ |
| 10255 | static uint8_t *hdd_get_platform_wlan_derived_mac_buff(struct device *dev, |
| 10256 | uint32_t *num) |
| 10257 | { |
| 10258 | return pld_get_wlan_derived_mac_address(dev, num); |
| 10259 | } |
| 10260 | |
| 10261 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10262 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 10263 | * @hdd_ctx: HDD Context |
| 10264 | * @num: Number of random mac addresses needed |
| 10265 | * |
| 10266 | * Generate random addresses using bit manipulation on the base mac address |
| 10267 | * |
| 10268 | * Return: None |
| 10269 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10270 | 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] | 10271 | { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10272 | uint32_t idx = hdd_ctx->num_derived_addr; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10273 | uint32_t iter; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10274 | uint8_t *buf = NULL; |
| 10275 | uint8_t macaddr_b3, tmp_br3; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10276 | /* |
| 10277 | * Consider first provisioned mac address as source address to derive |
| 10278 | * remaining addresses |
| 10279 | */ |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10280 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10281 | uint8_t *src = hdd_ctx->provisioned_mac_addr[0].bytes; |
| 10282 | |
| 10283 | for (iter = 0; iter < num; ++iter, ++idx) { |
| 10284 | buf = hdd_ctx->derived_mac_addr[idx].bytes; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10285 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 10286 | macaddr_b3 = buf[3]; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10287 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + idx) & |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10288 | INTF_MACADDR_MASK; |
| 10289 | macaddr_b3 += tmp_br3; |
| 10290 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 10291 | buf[0] |= 0x02; |
| 10292 | buf[3] = macaddr_b3; |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 10293 | hdd_debug(QDF_MAC_ADDR_STR, QDF_MAC_ADDR_ARRAY(buf)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10294 | hdd_ctx->num_derived_addr++; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10295 | } |
| 10296 | } |
| 10297 | |
| 10298 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10299 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10300 | * @hdd_ctx: HDD Context |
| 10301 | * |
| 10302 | * API to get mac addresses from platform driver and update the driver |
| 10303 | * structures and configure FW with the base mac address. |
| 10304 | * Return: int |
| 10305 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10306 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10307 | { |
| 10308 | uint32_t no_of_mac_addr, iter; |
| 10309 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 10310 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 10311 | uint8_t *addr, *buf; |
| 10312 | struct device *dev = hdd_ctx->parent_dev; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10313 | tSirMacAddr mac_addr; |
| 10314 | QDF_STATUS status; |
| 10315 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10316 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10317 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10318 | if (no_of_mac_addr == 0 || !addr) { |
| 10319 | hdd_debug("No mac configured from platform driver"); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10320 | return -EINVAL; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10321 | } |
| 10322 | |
| 10323 | hdd_free_mac_address_lists(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10324 | |
| 10325 | if (no_of_mac_addr > max_mac_addr) |
| 10326 | no_of_mac_addr = max_mac_addr; |
| 10327 | |
| 10328 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 10329 | |
| 10330 | 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] | 10331 | buf = hdd_ctx->provisioned_mac_addr[iter].bytes; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10332 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 10333 | hdd_info("provisioned MAC Addr [%d]" QDF_MAC_ADDR_STR, iter, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 10334 | QDF_MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10335 | } |
| 10336 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10337 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10338 | hdd_ctx->num_provisioned_addr = no_of_mac_addr; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10339 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10340 | if (hdd_ctx->config->mac_provision) { |
| 10341 | addr = hdd_get_platform_wlan_derived_mac_buff(dev, |
| 10342 | &no_of_mac_addr); |
| 10343 | |
| 10344 | if (no_of_mac_addr == 0 || !addr) |
| 10345 | hdd_warn("No derived address from platform driver"); |
| 10346 | else if (no_of_mac_addr > |
| 10347 | (max_mac_addr - hdd_ctx->num_provisioned_addr)) |
| 10348 | no_of_mac_addr = (max_mac_addr - |
| 10349 | hdd_ctx->num_provisioned_addr); |
| 10350 | |
| 10351 | for (iter = 0; iter < no_of_mac_addr; ++iter, |
| 10352 | addr += mac_addr_size) { |
| 10353 | buf = hdd_ctx->derived_mac_addr[iter].bytes; |
| 10354 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 10355 | hdd_debug("derived MAC Addr [%d]" QDF_MAC_ADDR_STR, iter, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 10356 | QDF_MAC_ADDR_ARRAY(buf)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10357 | } |
| 10358 | hdd_ctx->num_derived_addr = no_of_mac_addr; |
| 10359 | } |
| 10360 | |
| 10361 | no_of_mac_addr = hdd_ctx->num_provisioned_addr + |
| 10362 | hdd_ctx->num_derived_addr; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10363 | if (no_of_mac_addr < max_mac_addr) |
| 10364 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 10365 | no_of_mac_addr); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10366 | |
| 10367 | status = sme_set_custom_mac_addr(mac_addr); |
| 10368 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10369 | return -EAGAIN; |
| 10370 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10371 | return 0; |
| 10372 | } |
| 10373 | |
| 10374 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10375 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 10376 | * @hdd_ctx: HDD Context |
| 10377 | * |
| 10378 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 10379 | * will generate its own MAC and update it to FW. |
| 10380 | * |
| 10381 | * Return: 0 for success |
| 10382 | * Non-zero error code for failure |
| 10383 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10384 | 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] | 10385 | { |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10386 | tSirMacAddr custom_mac_addr; |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10387 | QDF_STATUS status; |
| 10388 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10389 | if (hdd_ctx->num_provisioned_addr) |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10390 | qdf_mem_copy(&custom_mac_addr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10391 | &hdd_ctx->provisioned_mac_addr[0].bytes[0], |
| 10392 | sizeof(tSirMacAddr)); |
| 10393 | else |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10394 | qdf_mem_copy(&custom_mac_addr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10395 | &hdd_ctx->derived_mac_addr[0].bytes[0], |
| 10396 | sizeof(tSirMacAddr)); |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10397 | status = sme_set_custom_mac_addr(custom_mac_addr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10398 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10399 | return -EAGAIN; |
| 10400 | return 0; |
| 10401 | } |
| 10402 | |
| 10403 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10404 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 10405 | * @hdd_ctx: HDD Context |
| 10406 | * |
| 10407 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 10408 | * is provisioned with mac addresses, driver uses it, else it will use |
| 10409 | * wlan_mac.bin to update HW MAC addresses. |
| 10410 | * |
| 10411 | * Return: None |
| 10412 | */ |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10413 | static int hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10414 | { |
| 10415 | QDF_STATUS status; |
| 10416 | int ret; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10417 | bool update_mac_addr_to_fw = true; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10418 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10419 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10420 | if (hdd_ctx->config->mac_provision || !ret) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10421 | hdd_info("using MAC address from platform driver"); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10422 | return ret; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10423 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10424 | |
| 10425 | status = hdd_update_mac_config(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10426 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 10427 | hdd_info("using MAC address from wlan_mac.bin"); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10428 | return 0; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10429 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10430 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10431 | hdd_info("using default MAC address"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10432 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10433 | /* Use fw provided MAC */ |
| 10434 | if (!qdf_is_macaddr_zero(&hdd_ctx->hw_macaddr)) { |
| 10435 | hdd_update_macaddr(hdd_ctx, hdd_ctx->hw_macaddr, false); |
| 10436 | update_mac_addr_to_fw = false; |
| 10437 | return 0; |
| 10438 | } else if (hdd_generate_macaddr_auto(hdd_ctx) != 0) { |
| 10439 | struct qdf_mac_addr mac_addr; |
| 10440 | |
| 10441 | hdd_err("MAC failure from device serial no."); |
Jeff Johnson | 51a8052 | 2018-12-11 20:19:44 -0800 | [diff] [blame] | 10442 | qdf_get_random_bytes(&mac_addr, sizeof(mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10443 | /* |
| 10444 | * Reset multicast bit (bit-0) and set |
| 10445 | * locally-administered bit |
| 10446 | */ |
| 10447 | mac_addr.bytes[0] = 0x2; |
| 10448 | hdd_update_macaddr(hdd_ctx, mac_addr, true); |
| 10449 | } |
| 10450 | |
| 10451 | if (update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10452 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10453 | if (ret) |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 10454 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10455 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10456 | return ret; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10457 | } |
| 10458 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10459 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10460 | { |
| 10461 | int vdev_id = 0; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10462 | QDF_STATUS status; |
| 10463 | bool smart_chainmask_enabled; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10464 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10465 | int vpdev = PDEV_CMD; |
| 10466 | int ret; |
| 10467 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10468 | status = ucfg_get_smart_chainmask_enabled(hdd_ctx->psoc, |
| 10469 | &smart_chainmask_enabled); |
| 10470 | if (QDF_IS_STATUS_ERROR(status)) |
| 10471 | return -EINVAL; |
| 10472 | |
| 10473 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10474 | (int)smart_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10475 | if (ret) |
| 10476 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 10477 | |
| 10478 | return ret; |
| 10479 | } |
| 10480 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10481 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10482 | { |
| 10483 | int vdev_id = 0; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10484 | QDF_STATUS status; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10485 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10486 | bool alternative_chainmask_enabled; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10487 | int vpdev = PDEV_CMD; |
| 10488 | int ret; |
| 10489 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10490 | status = ucfg_get_alternative_chainmask_enabled( |
| 10491 | hdd_ctx->psoc, |
| 10492 | &alternative_chainmask_enabled); |
| 10493 | if (QDF_IS_STATUS_ERROR(status)) |
| 10494 | return -EINVAL; |
| 10495 | |
| 10496 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10497 | (int)alternative_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10498 | if (ret) |
| 10499 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 10500 | ret); |
| 10501 | |
| 10502 | return ret; |
| 10503 | } |
| 10504 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10505 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10506 | { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10507 | QDF_STATUS status; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10508 | int vdev_id = 0; |
| 10509 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10510 | bool value; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10511 | int vpdev = PDEV_CMD; |
| 10512 | int ret; |
| 10513 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10514 | status = ucfg_fwol_get_ani_enabled(hdd_ctx->psoc, &value); |
| 10515 | if (QDF_IS_STATUS_ERROR(status)) |
| 10516 | return -EINVAL; |
| 10517 | |
| 10518 | ret = sme_cli_set_command(vdev_id, param_id, (int)value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10519 | if (ret) |
| 10520 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 10521 | |
| 10522 | return ret; |
| 10523 | } |
| 10524 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 10525 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10526 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 10527 | * @hdd_ctx: HDD context |
| 10528 | * |
| 10529 | * Pre configurations to be done at lower layer before calling cds enable. |
| 10530 | * |
| 10531 | * Return: 0 on success and errno on failure. |
| 10532 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10533 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10534 | { |
| 10535 | int ret; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10536 | uint8_t val = 0; |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10537 | QDF_STATUS status; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10538 | uint32_t arp_ac_category; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10539 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10540 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10541 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Ajit Pal Singh | 5d26961 | 2018-04-19 16:29:12 +0530 | [diff] [blame] | 10542 | /* Register HL netdev flow control callback */ |
| 10543 | cdp_hl_fc_register(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10544 | |
| 10545 | /* |
| 10546 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 10547 | * The cfg download must occur before we update the SME config |
| 10548 | * since the SME config operation must access the cfg database |
| 10549 | */ |
| 10550 | status = hdd_set_sme_config(hdd_ctx); |
| 10551 | |
| 10552 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10553 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10554 | ret = qdf_status_to_os_return(status); |
| 10555 | goto out; |
| 10556 | } |
| 10557 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 10558 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 10559 | if (QDF_STATUS_SUCCESS != status) { |
| 10560 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 10561 | ret = qdf_status_to_os_return(status); |
| 10562 | goto out; |
| 10563 | } |
| 10564 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10565 | status = ucfg_mlme_get_tx_chainmask_1ss(hdd_ctx->psoc, &val); |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10566 | if (QDF_STATUS_SUCCESS != status) { |
| 10567 | hdd_err("Get tx_chainmask_1ss from mlme failed"); |
| 10568 | ret = qdf_status_to_os_return(status); |
| 10569 | goto out; |
| 10570 | } |
| 10571 | 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] | 10572 | PDEV_CMD); |
| 10573 | if (0 != ret) { |
| 10574 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 10575 | goto out; |
| 10576 | } |
| 10577 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10578 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 10579 | if (ret) |
| 10580 | goto out; |
| 10581 | |
| 10582 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 10583 | if (ret) |
| 10584 | goto out; |
| 10585 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10586 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 10587 | if (ret) |
| 10588 | goto out; |
| 10589 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10590 | status = ucfg_get_arp_ac_category(hdd_ctx->psoc, &arp_ac_category); |
| 10591 | |
| 10592 | if (QDF_IS_STATUS_ERROR(status)) |
| 10593 | return -EINVAL; |
| 10594 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10595 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10596 | arp_ac_category, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10597 | PDEV_CMD); |
| 10598 | if (0 != ret) { |
| 10599 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10600 | arp_ac_category, ret); |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10601 | goto out; |
| 10602 | } |
| 10603 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10604 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 10605 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10606 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10607 | ret = qdf_status_to_os_return(status); |
| 10608 | goto out; |
| 10609 | } |
| 10610 | |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 10611 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10612 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10613 | ret = -EINVAL; |
| 10614 | goto out; |
| 10615 | } |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10616 | hdd_init_channel_avoidance(hdd_ctx); |
| 10617 | |
| 10618 | out: |
| 10619 | return ret; |
| 10620 | } |
| 10621 | |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10622 | #ifdef FEATURE_P2P_LISTEN_OFFLOAD |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10623 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10624 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10625 | * @context: context registered with sme_register_p2p_lo_event(). HDD |
| 10626 | * always registers a hdd context pointer |
| 10627 | * @evt:event structure pointer |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10628 | * |
| 10629 | * This is the p2p listen offload stop event handler, it sends vendor |
| 10630 | * event back to supplicant to notify the stop reason. |
| 10631 | * |
| 10632 | * Return: None |
| 10633 | */ |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10634 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10635 | struct sir_p2p_lo_event *evt) |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10636 | { |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10637 | struct hdd_context *hdd_ctx = context; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10638 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10639 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10640 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10641 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10642 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 10643 | if (!hdd_ctx) { |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10644 | hdd_err("Invalid HDD context pointer"); |
| 10645 | return; |
| 10646 | } |
| 10647 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10648 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 10649 | if (!adapter) { |
| 10650 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 10651 | evt->vdev_id); |
| 10652 | return; |
| 10653 | } |
| 10654 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10655 | vendor_event = |
| 10656 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10657 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10658 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 10659 | GFP_KERNEL); |
| 10660 | |
| 10661 | if (!vendor_event) { |
| 10662 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 10663 | return; |
| 10664 | } |
| 10665 | |
| 10666 | if (nla_put_u32(vendor_event, |
| 10667 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 10668 | evt->reason_code)) { |
| 10669 | hdd_err("nla put failed"); |
| 10670 | kfree_skb(vendor_event); |
| 10671 | return; |
| 10672 | } |
| 10673 | |
| 10674 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10675 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 10676 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10677 | } |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10678 | #else |
| 10679 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10680 | struct sir_p2p_lo_event *evt) |
| 10681 | { |
| 10682 | } |
| 10683 | #endif |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10684 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10685 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 10686 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10687 | { |
| 10688 | return sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap); |
| 10689 | } |
| 10690 | #else |
| 10691 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10692 | { |
| 10693 | return QDF_STATUS_SUCCESS; |
| 10694 | } |
| 10695 | #endif |
| 10696 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10697 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10698 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 10699 | * @hdd_ctx: HDD context |
| 10700 | * |
| 10701 | * This function sends the adaptive dwell time config configuration to the |
| 10702 | * firmware via WMA |
| 10703 | * |
| 10704 | * Return: 0 - success, < 0 - failure |
| 10705 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10706 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10707 | { |
| 10708 | QDF_STATUS status; |
| 10709 | struct adaptive_dwelltime_params dwelltime_params; |
| 10710 | |
Harprit Chhabada | d59ae76 | 2019-01-08 16:40:43 -0800 | [diff] [blame] | 10711 | status = ucfg_fwol_get_all_adaptive_dwelltime_params(hdd_ctx->psoc, |
| 10712 | &dwelltime_params); |
| 10713 | status = ucfg_fwol_set_adaptive_dwelltime_config(&dwelltime_params); |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10714 | |
| 10715 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 10716 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10717 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 10718 | return -EAGAIN; |
| 10719 | } |
| 10720 | return 0; |
| 10721 | } |
| 10722 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10723 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10724 | { |
| 10725 | QDF_STATUS status; |
| 10726 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 10727 | uint32_t i = 0; |
| 10728 | uint8_t count = 0, numentries = 0; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10729 | uint8_t dual_mac_feature; |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10730 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10731 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 10732 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10733 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 10734 | &dual_mac_feature); |
| 10735 | |
| 10736 | if (status != QDF_STATUS_SUCCESS) { |
| 10737 | hdd_err("can't get dual mac feature flag"); |
| 10738 | return -EINVAL; |
| 10739 | } |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10740 | /* check if DBS is enabled or supported */ |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10741 | if ((dual_mac_feature == DISABLE_DBS_CXN_AND_SCAN) || |
| 10742 | (dual_mac_feature == ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10743 | return -EINVAL; |
| 10744 | |
| 10745 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 10746 | dbs_scan_config, &numentries, |
| 10747 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10748 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 10749 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10750 | if (!numentries) { |
Dustin Brown | 6a8d39b | 2018-08-14 15:27:26 -0700 | [diff] [blame] | 10751 | hdd_debug("Do not send scan_selection_config"); |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10752 | return 0; |
| 10753 | } |
| 10754 | |
| 10755 | /* hdd_set_fw_log_params */ |
| 10756 | dbs_scan_params.num_clients = 0; |
| 10757 | while (count < (numentries - 2)) { |
| 10758 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 10759 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 10760 | dbs_scan_params.num_non_dbs_scans[i] = |
| 10761 | dbs_scan_config[count + 2]; |
| 10762 | dbs_scan_params.num_clients++; |
| 10763 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 10764 | dbs_scan_params.module_id[i], |
| 10765 | dbs_scan_params.num_dbs_scans[i], |
| 10766 | dbs_scan_params.num_non_dbs_scans[i]); |
| 10767 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 10768 | i++; |
| 10769 | } |
| 10770 | |
| 10771 | dbs_scan_params.pdev_id = 0; |
| 10772 | |
| 10773 | hdd_debug("clients:%d pdev:%d", |
| 10774 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 10775 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10776 | status = sme_set_dbs_scan_selection_config(hdd_ctx->mac_handle, |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10777 | &dbs_scan_params); |
| 10778 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 10779 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10780 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 10781 | return -EAGAIN; |
| 10782 | } |
| 10783 | return 0; |
| 10784 | } |
| 10785 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10786 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10787 | /** |
| 10788 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 10789 | * @hdd_ctx: HDD context |
| 10790 | * |
| 10791 | * Set auto shutdown callback to get indications from firmware to indicate |
| 10792 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 10793 | * |
| 10794 | * Return: 0 on success and errno on failure. |
| 10795 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10796 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10797 | { |
| 10798 | QDF_STATUS status; |
| 10799 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 10800 | if (!hdd_ctx->config->wlan_auto_shutdown) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10801 | return 0; |
| 10802 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10803 | status = sme_set_auto_shutdown_cb(hdd_ctx->mac_handle, |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10804 | wlan_hdd_auto_shutdown_cb); |
| 10805 | if (status != QDF_STATUS_SUCCESS) |
| 10806 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 10807 | status); |
| 10808 | |
| 10809 | return qdf_status_to_os_return(status); |
| 10810 | } |
| 10811 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10812 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10813 | { |
| 10814 | return 0; |
| 10815 | } |
| 10816 | #endif |
| 10817 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10818 | #ifdef MWS_COEX |
| 10819 | /** |
| 10820 | * hdd_set_mws_coex() - Set MWS coex configurations |
| 10821 | * @hdd_ctx: HDD context |
| 10822 | * |
| 10823 | * This function sends MWS-COEX 4G quick FTDM and |
| 10824 | * MWS-COEX 5G-NR power limit to FW |
| 10825 | * |
| 10826 | * Return: 0 on success and errno on failure. |
| 10827 | */ |
| 10828 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10829 | { |
| 10830 | int ret = 0; |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10831 | uint32_t mws_coex_4g_quick_tdm = 0, mws_coex_5g_nr_pwr_limit = 0; |
| 10832 | |
| 10833 | ucfg_mlme_get_mws_coex_4g_quick_tdm(hdd_ctx->psoc, |
| 10834 | &mws_coex_4g_quick_tdm); |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10835 | |
| 10836 | 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] | 10837 | mws_coex_4g_quick_tdm, |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10838 | PDEV_CMD); |
| 10839 | if (ret) { |
| 10840 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10841 | return ret; |
| 10842 | } |
| 10843 | |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10844 | ucfg_mlme_get_mws_coex_5g_nr_pwr_limit(hdd_ctx->psoc, |
| 10845 | &mws_coex_5g_nr_pwr_limit); |
| 10846 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10847 | 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] | 10848 | mws_coex_5g_nr_pwr_limit, |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10849 | PDEV_CMD); |
| 10850 | if (ret) { |
| 10851 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10852 | return ret; |
| 10853 | } |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10854 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10855 | return ret; |
| 10856 | } |
| 10857 | #else |
| 10858 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10859 | { |
| 10860 | return 0; |
| 10861 | } |
| 10862 | #endif |
| 10863 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10864 | /** |
| 10865 | * hdd_features_init() - Init features |
| 10866 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10867 | * |
| 10868 | * Initialize features and their feature context after WLAN firmware is up. |
| 10869 | * |
| 10870 | * Return: 0 on success and errno on failure. |
| 10871 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10872 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10873 | { |
Jeff Johnson | 19ce8d0 | 2019-02-08 22:56:23 -0800 | [diff] [blame] | 10874 | struct tx_power_limit hddtxlimit; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10875 | QDF_STATUS status; |
| 10876 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10877 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10878 | struct hdd_config *cfg; |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 10879 | bool b_cts2self, is_imps_enabled; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10880 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10881 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10882 | |
Dustin Brown | ad698ae | 2018-09-05 17:19:30 -0700 | [diff] [blame] | 10883 | ret = hdd_update_country_code(hdd_ctx); |
| 10884 | if (ret) { |
| 10885 | hdd_err("Failed to update country code; errno:%d", ret); |
| 10886 | return -EINVAL; |
| 10887 | } |
| 10888 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10889 | ret = hdd_init_mws_coex(hdd_ctx); |
| 10890 | if (ret) |
| 10891 | hdd_warn("Error initializing mws-coex"); |
| 10892 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10893 | cfg = hdd_ctx->config; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10894 | /* FW capabilities received, Set the Dot11 mode */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10895 | mac_handle = hdd_ctx->mac_handle; |
| 10896 | sme_setdef_dot11mode(mac_handle); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10897 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 10898 | ucfg_mlme_is_imps_enabled(hdd_ctx->psoc, &is_imps_enabled); |
| 10899 | hdd_set_idle_ps_config(hdd_ctx, is_imps_enabled); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10900 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10901 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10902 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 10903 | cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 10904 | cfg_dp_enable_data_stall), PDEV_CMD); |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10905 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10906 | ucfg_mlme_get_go_cts2self_for_sta(hdd_ctx->psoc, &b_cts2self); |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 10907 | if (b_cts2self) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10908 | sme_set_cts2self_for_p2p_go(mac_handle); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10909 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10910 | if (hdd_set_vc_mode_config(hdd_ctx)) |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10911 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10912 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10913 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10914 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10915 | |
| 10916 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10917 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10918 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10919 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10920 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10921 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10922 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10923 | if (ret) { |
| 10924 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10925 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10926 | } |
| 10927 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10928 | /** |
| 10929 | * In case of SSR/PDR, if pktlog was enabled manually before |
Rakshith Suresh Patkar | 6d95526 | 2019-03-13 16:51:50 +0530 | [diff] [blame] | 10930 | * SSR/PDR, then enable it again automatically after Wlan |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10931 | * device up. |
Rakshith Suresh Patkar | 6d95526 | 2019-03-13 16:51:50 +0530 | [diff] [blame] | 10932 | * During SSR/PDR, pktlog will be disabled as part of |
| 10933 | * hdd_features_deinit if pktlog is enabled in ini. |
| 10934 | * Re-enable pktlog in SSR case, if pktlog is enabled in ini. |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10935 | */ |
Rakshith Suresh Patkar | 6d95526 | 2019-03-13 16:51:50 +0530 | [diff] [blame] | 10936 | if (cds_is_packet_log_enabled() || |
| 10937 | (cds_is_driver_recovering() && hdd_ctx->is_pktlog_enabled)) |
Alok Kumar | 5a75b9d | 2018-08-31 10:55:43 +0530 | [diff] [blame] | 10938 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10939 | |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 10940 | hddtxlimit.txPower2g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_2G); |
| 10941 | hddtxlimit.txPower5g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_5G); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10942 | status = sme_txpower_limit(mac_handle, &hddtxlimit); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10943 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10944 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10945 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10946 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10947 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 10948 | status = sme_enable_disable_chanavoidind_event(mac_handle, 0); |
| 10949 | if (QDF_IS_STATUS_ERROR(status) && (status != QDF_STATUS_E_NOSUPPORT)) { |
| 10950 | hdd_err("Failed to disable Chan Avoidance Indication"); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10951 | return -EINVAL; |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10952 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10953 | |
| 10954 | /* register P2P Listen Offload event callback */ |
| 10955 | if (wma_is_p2p_lo_capable()) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10956 | sme_register_p2p_lo_event(mac_handle, hdd_ctx, |
| 10957 | wlan_hdd_p2p_lo_event_callback); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10958 | |
| 10959 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10960 | |
| 10961 | if (ret) |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10962 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10963 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10964 | wlan_hdd_init_chan_info(hdd_ctx); |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10965 | wlan_hdd_twt_init(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10966 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10967 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10968 | return 0; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10969 | } |
| 10970 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10971 | /** |
| 10972 | * hdd_features_deinit() - Deinit features |
| 10973 | * @hdd_ctx: HDD context |
| 10974 | * |
| 10975 | * De-Initialize features and their feature context. |
| 10976 | * |
| 10977 | * Return: none. |
| 10978 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10979 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10980 | { |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10981 | wlan_hdd_twt_deinit(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10982 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10983 | wlan_hdd_tsf_deinit(hdd_ctx); |
jitiphil | 4e3bef4 | 2018-11-14 14:31:13 +0530 | [diff] [blame] | 10984 | if (cds_is_packet_log_enabled()) |
| 10985 | hdd_pktlog_enable_disable(hdd_ctx, false, 0, 0); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10986 | } |
| 10987 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10988 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10989 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10990 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10991 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10992 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10993 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10994 | 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] | 10995 | { |
| 10996 | QDF_STATUS status; |
| 10997 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10998 | status = ucfg_scan_register_bcn_cb(hdd_ctx->psoc, |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10999 | wlan_cfg80211_inform_bss_frame, |
| 11000 | SCAN_CB_TYPE_INFORM_BCN); |
| 11001 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Abhishek Singh | 5ffe9de | 2019-03-05 15:42:43 +0530 | [diff] [blame] | 11002 | hdd_err("failed to register SCAN_CB_TYPE_INFORM_BCN with status code %08d [x%08x]", |
| 11003 | status, status); |
| 11004 | return status; |
| 11005 | } |
| 11006 | |
| 11007 | status = ucfg_scan_register_bcn_cb(hdd_ctx->psoc, |
| 11008 | wlan_cfg80211_unlink_bss_list, |
| 11009 | SCAN_CB_TYPE_UNLINK_BSS); |
| 11010 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 11011 | 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] | 11012 | status, status); |
| 11013 | return status; |
| 11014 | } |
| 11015 | |
| 11016 | return QDF_STATUS_SUCCESS; |
| 11017 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 11018 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 11019 | /** |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 11020 | * hdd_v2_flow_pool_map() - Flow pool create callback when vdev is active |
| 11021 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 11022 | * |
| 11023 | * Return: none. |
| 11024 | */ |
| 11025 | static void hdd_v2_flow_pool_map(int vdev_id) |
| 11026 | { |
| 11027 | QDF_STATUS status; |
| 11028 | |
| 11029 | status = cdp_flow_pool_map(cds_get_context(QDF_MODULE_ID_SOC), |
| 11030 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 11031 | vdev_id); |
| 11032 | /* |
| 11033 | * For Adrastea flow control v2 is based on FW MAP events, |
| 11034 | * so this above callback is not implemented. |
| 11035 | * Hence this is not actual failure. Dont return failure |
| 11036 | */ |
| 11037 | if ((status != QDF_STATUS_SUCCESS) && |
| 11038 | (status != QDF_STATUS_E_INVAL)) { |
| 11039 | hdd_err("vdev_id: %d, failed to create flow pool status %d", |
| 11040 | vdev_id, status); |
| 11041 | } |
| 11042 | } |
| 11043 | |
| 11044 | /** |
| 11045 | * hdd_v2_flow_pool_unmap() - Flow pool create callback when vdev is not active |
| 11046 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 11047 | * |
| 11048 | * Return: none. |
| 11049 | */ |
| 11050 | static void hdd_v2_flow_pool_unmap(int vdev_id) |
| 11051 | { |
| 11052 | cdp_flow_pool_unmap(cds_get_context(QDF_MODULE_ID_SOC), |
| 11053 | cds_get_context(QDF_MODULE_ID_TXRX), vdev_id); |
| 11054 | } |
| 11055 | |
| 11056 | /** |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11057 | * hdd_action_oui_config() - Configure action_oui strings |
| 11058 | * @hdd_ctx: pointer to hdd context |
| 11059 | * |
| 11060 | * This is a HDD wrapper function which invokes ucfg api |
| 11061 | * of action_oui component to parse action oui strings. |
| 11062 | * |
| 11063 | * Return: None |
| 11064 | */ |
| 11065 | static void hdd_action_oui_config(struct hdd_context *hdd_ctx) |
| 11066 | { |
| 11067 | QDF_STATUS status; |
| 11068 | uint32_t id; |
| 11069 | uint8_t *str; |
| 11070 | |
| 11071 | if (!hdd_ctx->config->action_oui_enable) |
| 11072 | return; |
| 11073 | |
| 11074 | for (id = 0; id < ACTION_OUI_MAXIMUM_ID; id++) { |
| 11075 | str = hdd_ctx->config->action_oui_str[id]; |
| 11076 | if (!qdf_str_len(str)) |
| 11077 | continue; |
| 11078 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11079 | status = ucfg_action_oui_parse(hdd_ctx->psoc, str, id); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11080 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11081 | hdd_err("Failed to parse action_oui str: %u", id); |
| 11082 | } |
| 11083 | } |
| 11084 | |
| 11085 | /** |
| 11086 | * hdd_action_oui_send() - Send action_oui extensions to firmware |
| 11087 | * @hdd_ctx: pointer to hdd context |
| 11088 | * |
| 11089 | * This is a HDD wrapper function which invokes ucfg api |
| 11090 | * of action_oui component to send action oui extensions to firmware. |
| 11091 | * |
| 11092 | * Return: None |
| 11093 | */ |
| 11094 | static void hdd_action_oui_send(struct hdd_context *hdd_ctx) |
| 11095 | { |
| 11096 | QDF_STATUS status; |
| 11097 | |
| 11098 | if (!hdd_ctx->config->action_oui_enable) |
| 11099 | return; |
| 11100 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11101 | status = ucfg_action_oui_send(hdd_ctx->psoc); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11102 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11103 | hdd_err("Failed to send one or all action_ouis"); |
| 11104 | } |
| 11105 | |
Jeff Johnson | 0187c62 | 2019-01-04 06:39:44 -0800 | [diff] [blame] | 11106 | static void hdd_hastings_bt_war_initialize(struct hdd_context *hdd_ctx) |
| 11107 | { |
| 11108 | if (hdd_ctx->config->iface_change_wait_time) |
| 11109 | hdd_hastings_bt_war_disable_fw(hdd_ctx); |
| 11110 | else |
| 11111 | hdd_hastings_bt_war_enable_fw(hdd_ctx); |
| 11112 | } |
| 11113 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11114 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11115 | * hdd_configure_cds() - Configure cds modules |
| 11116 | * @hdd_ctx: HDD context |
| 11117 | * @adapter: Primary adapter context |
| 11118 | * |
| 11119 | * Enable Cds modules after WLAN firmware is up. |
| 11120 | * |
| 11121 | * Return: 0 on success and errno on failure. |
| 11122 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11123 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11124 | { |
| 11125 | int ret; |
| 11126 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11127 | int set_value; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11128 | mac_handle_t mac_handle; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11129 | bool enable_rts_sifsbursting; |
| 11130 | uint8_t enable_phy_reg_retention; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11131 | uint8_t max_mpdus_inampdu, is_force_1x1 = 0; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11132 | uint32_t num_abg_tx_chains = 0; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11133 | uint16_t num_11b_tx_chains = 0; |
| 11134 | uint16_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 11135 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11136 | bool value; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11137 | enum pmo_auto_pwr_detect_failure_mode auto_power_fail_mode; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11138 | bool bval = false; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11139 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11140 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11141 | |
| 11142 | hdd_action_oui_send(hdd_ctx); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11143 | status = ucfg_policy_mgr_get_force_1x1(hdd_ctx->psoc, &is_force_1x1); |
| 11144 | if (status != QDF_STATUS_SUCCESS) { |
| 11145 | hdd_err("Failed to get force 1x1 value"); |
| 11146 | goto out; |
| 11147 | } |
| 11148 | if (is_force_1x1) |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11149 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 11150 | 1, PDEV_CMD); |
| 11151 | /* set chip power save failure detected callback */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11152 | sme_set_chip_pwr_save_fail_cb(mac_handle, |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11153 | hdd_chip_pwr_save_fail_detected_cb); |
| 11154 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11155 | status = ucfg_get_max_mpdus_inampdu(hdd_ctx->psoc, |
| 11156 | &max_mpdus_inampdu); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11157 | if (status) { |
| 11158 | hdd_err("Failed to get max mpdus in ampdu value"); |
| 11159 | goto out; |
| 11160 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11161 | |
| 11162 | if (max_mpdus_inampdu) { |
| 11163 | set_value = max_mpdus_inampdu; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11164 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 11165 | set_value, PDEV_CMD); |
| 11166 | } |
| 11167 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11168 | status = ucfg_get_enable_rts_sifsbursting(hdd_ctx->psoc, |
| 11169 | &enable_rts_sifsbursting); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11170 | if (status) { |
| 11171 | hdd_err("Failed to get rts sifs bursting value"); |
| 11172 | goto out; |
| 11173 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11174 | |
| 11175 | if (enable_rts_sifsbursting) { |
| 11176 | set_value = enable_rts_sifsbursting; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11177 | sme_cli_set_command(0, |
| 11178 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 11179 | set_value, PDEV_CMD); |
| 11180 | } |
| 11181 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 11182 | ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11183 | if (value) { |
| 11184 | set_value = value; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11185 | sme_cli_set_command(0, |
| 11186 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 11187 | set_value, PDEV_CMD); |
| 11188 | } |
| 11189 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11190 | status = ucfg_mlme_get_num_11b_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11191 | &num_11b_tx_chains); |
| 11192 | if (status != QDF_STATUS_SUCCESS) { |
| 11193 | hdd_err("Failed to get num_11b_tx_chains"); |
| 11194 | goto out; |
| 11195 | } |
| 11196 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11197 | status = ucfg_mlme_get_num_11ag_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11198 | &num_11ag_tx_chains); |
| 11199 | if (status != QDF_STATUS_SUCCESS) { |
| 11200 | hdd_err("Failed to get num_11ag_tx_chains"); |
| 11201 | goto out; |
| 11202 | } |
| 11203 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11204 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 11205 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11206 | hdd_err("unable to get vht_enable2x2"); |
| 11207 | |
| 11208 | if (!bval) { |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11209 | if (num_11b_tx_chains > 1) |
| 11210 | num_11b_tx_chains = 1; |
| 11211 | if (num_11ag_tx_chains > 1) |
| 11212 | num_11ag_tx_chains = 1; |
| 11213 | } |
| 11214 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11215 | num_11b_tx_chains); |
| 11216 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11217 | num_11ag_tx_chains); |
| 11218 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 11219 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11220 | |
Paul Zhang | 02526cd | 2018-09-20 17:47:46 +0800 | [diff] [blame] | 11221 | if (!ucfg_reg_is_regdb_offloaded(hdd_ctx->psoc)) |
| 11222 | ucfg_reg_program_default_cc(hdd_ctx->pdev, |
| 11223 | hdd_ctx->reg.reg_domain); |
| 11224 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11225 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 11226 | if (ret) { |
| 11227 | hdd_err("Failed to pre-configure cds"); |
| 11228 | goto out; |
| 11229 | } |
| 11230 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11231 | /* Always get latest IPA resources allocated from cds_open and configure |
| 11232 | * IPA module before configuring them to FW. Sequence required as crash |
| 11233 | * observed otherwise. |
| 11234 | */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11235 | if (ucfg_ipa_uc_ol_init(hdd_ctx->pdev, |
| 11236 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 11237 | hdd_err("Failed to setup pipes"); |
| 11238 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11239 | } |
| 11240 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11241 | /* |
| 11242 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 11243 | * else |
| 11244 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11245 | status = cds_enable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11246 | |
| 11247 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11248 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11249 | goto out; |
| 11250 | } |
| 11251 | |
| 11252 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 11253 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11254 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11255 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11256 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11257 | status = hdd_register_bcn_cb(hdd_ctx); |
| 11258 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 11259 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11260 | goto cds_disable; |
| 11261 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11262 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11263 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11264 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11265 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11266 | |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 11267 | /* Donot disable rx offload on concurrency for lithium based targets */ |
| 11268 | if (!(hdd_ctx->target_type == TARGET_TYPE_QCA6290 || |
| 11269 | hdd_ctx->target_type == TARGET_TYPE_QCA6390)) |
| 11270 | if (hdd_ctx->ol_enable) |
| 11271 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 11272 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11273 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 11274 | 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] | 11275 | dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; |
| 11276 | dp_cbs.hdd_v2_flow_pool_unmap = hdd_v2_flow_pool_unmap; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11277 | status = policy_mgr_register_dp_cb(hdd_ctx->psoc, &dp_cbs); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11278 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11279 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11280 | goto cds_disable; |
| 11281 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11282 | status = policy_mgr_register_mode_change_cb(hdd_ctx->psoc, |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11283 | wlan_hdd_send_mode_change_event); |
| 11284 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 11285 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 11286 | goto cds_disable; |
| 11287 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11288 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 11289 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 11290 | hdd_debug("enhance green ap is not enabled"); |
| 11291 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 11292 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 11293 | hdd_debug("Failed to set wow pulse"); |
| 11294 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 11295 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
Manikandan Mohan | 66df7fc | 2019-01-08 17:57:05 -0800 | [diff] [blame] | 11296 | ucfg_fwol_get_gcmp_enable(hdd_ctx->psoc), PDEV_CMD); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11297 | |
| 11298 | auto_power_fail_mode = |
| 11299 | ucfg_pmo_get_auto_power_fail_mode(hdd_ctx->psoc); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11300 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11301 | auto_power_fail_mode, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11302 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11303 | status = ucfg_get_enable_phy_reg_retention(hdd_ctx->psoc, |
| 11304 | &enable_phy_reg_retention); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11305 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11306 | if (QDF_IS_STATUS_ERROR(status)) |
| 11307 | return -EINVAL; |
| 11308 | |
| 11309 | if (enable_phy_reg_retention) |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11310 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11311 | enable_phy_reg_retention, PDEV_CMD); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11312 | |
Jeff Johnson | 0187c62 | 2019-01-04 06:39:44 -0800 | [diff] [blame] | 11313 | hdd_hastings_bt_war_initialize(hdd_ctx); |
| 11314 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11315 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11316 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11317 | cds_disable: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11318 | cds_disable(hdd_ctx->psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11319 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11320 | out: |
| 11321 | return -EINVAL; |
| 11322 | } |
| 11323 | |
| 11324 | /** |
| 11325 | * hdd_deconfigure_cds() -De-Configure cds |
| 11326 | * @hdd_ctx: HDD context |
| 11327 | * |
| 11328 | * Deconfigure Cds modules before WLAN firmware is down. |
| 11329 | * |
| 11330 | * Return: 0 on success and errno on failure. |
| 11331 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11332 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11333 | { |
| 11334 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11335 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11336 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11337 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 11338 | |
| 11339 | /* De-init features */ |
| 11340 | hdd_features_deinit(hdd_ctx); |
| 11341 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11342 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->psoc); |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 11343 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11344 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11345 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11346 | qdf_status = cds_disable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11347 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11348 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 11349 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11350 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11351 | } |
| 11352 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11353 | 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] | 11354 | hdd_err("Failed to disconnect pipes"); |
| 11355 | ret = -EINVAL; |
| 11356 | } |
| 11357 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11358 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11359 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11360 | } |
| 11361 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11362 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 11363 | static void hdd_deregister_policy_manager_callback( |
| 11364 | struct wlan_objmgr_psoc *psoc) |
| 11365 | { |
| 11366 | if (QDF_STATUS_SUCCESS != |
| 11367 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 11368 | hdd_err("HDD callback deregister with policy manager failed"); |
| 11369 | } |
| 11370 | } |
| 11371 | #else |
| 11372 | static void hdd_deregister_policy_manager_callback( |
| 11373 | struct wlan_objmgr_psoc *psoc) |
| 11374 | { |
| 11375 | } |
| 11376 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11377 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11378 | 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] | 11379 | { |
| 11380 | void *hif_ctx; |
| 11381 | qdf_device_t qdf_ctx; |
| 11382 | QDF_STATUS qdf_status; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11383 | bool is_recovery_stop = cds_is_driver_recovering(); |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11384 | int ret = 0; |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11385 | int debugfs_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11386 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11387 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11388 | hdd_enter(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11389 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11390 | if (!qdf_ctx) { |
| 11391 | hdd_err("QDF device context NULL"); |
| 11392 | return -EINVAL; |
| 11393 | } |
| 11394 | |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11395 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11396 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11397 | debugfs_threads = hdd_return_debugfs_threads_count(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11398 | |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 11399 | if (debugfs_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
| 11400 | hdd_warn("Debugfs threads %d, wiphy suspend %d", |
| 11401 | debugfs_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11402 | |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11403 | if (IS_IDLE_STOP && !ftm_mode) { |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 11404 | hdd_psoc_idle_timer_start(hdd_ctx); |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11405 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11406 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11407 | return 0; |
| 11408 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 11409 | } |
| 11410 | |
Liangwei Dong | 857cb84 | 2019-04-28 04:55:17 -0400 | [diff] [blame] | 11411 | hdd_deregister_policy_manager_callback(hdd_ctx->psoc); |
| 11412 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 11413 | /* free user wowl patterns */ |
| 11414 | hdd_free_user_wowl_ptrns(); |
| 11415 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11416 | switch (hdd_ctx->driver_status) { |
| 11417 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11418 | hdd_debug("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11419 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11420 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11421 | hdd_debug("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11422 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11423 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 11424 | hdd_info("Wlan transitioning (CLOSED <- ENABLED)"); |
| 11425 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11426 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE || |
| 11427 | hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 11428 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11429 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 11430 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11431 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11432 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11433 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11434 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11435 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11436 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11437 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11438 | break; |
| 11439 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11440 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11441 | hdd_ctx->driver_status); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11442 | ret = -EINVAL; |
| 11443 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11444 | } |
| 11445 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11446 | hdd_sysfs_destroy_powerstats_interface(); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11447 | hdd_sysfs_destroy_version_interface(); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11448 | hdd_sysfs_destroy_driver_root_obj(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11449 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11450 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11451 | if (hdd_get_conparam() != QDF_GLOBAL_EPPING_MODE) { |
| 11452 | qdf_status = cds_post_disable(); |
| 11453 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11454 | hdd_err("Failed to process post CDS disable! :%d", |
| 11455 | qdf_status); |
| 11456 | ret = -EINVAL; |
| 11457 | QDF_ASSERT(0); |
| 11458 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11459 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11460 | /* De-register the SME callbacks */ |
| 11461 | hdd_deregister_cb(hdd_ctx); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 11462 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11463 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 11464 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11465 | qdf_status = cds_dp_close(hdd_ctx->psoc); |
| 11466 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11467 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 11468 | ret = -EINVAL; |
| 11469 | QDF_ASSERT(0); |
| 11470 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11471 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11472 | qdf_status = cds_close(hdd_ctx->psoc); |
| 11473 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11474 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
| 11475 | ret = -EINVAL; |
| 11476 | QDF_ASSERT(0); |
| 11477 | } |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11478 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11479 | qdf_status = wbuff_module_deinit(); |
| 11480 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 11481 | hdd_err("WBUFF de-init unsuccessful; status: %d", |
| 11482 | qdf_status); |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11483 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11484 | hdd_component_pdev_close(hdd_ctx->pdev); |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11485 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11486 | hdd_component_psoc_close(hdd_ctx->psoc); |
| 11487 | dispatcher_pdev_close(hdd_ctx->pdev); |
| 11488 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 11489 | if (ret) { |
| 11490 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 11491 | QDF_ASSERT(0); |
| 11492 | } |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11493 | } |
| 11494 | |
| 11495 | /* |
| 11496 | * Reset total mac phy during module stop such that during |
| 11497 | * next module start same psoc is used to populate new service |
| 11498 | * ready data |
| 11499 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11500 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11501 | if (tgt_hdl) |
| 11502 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 11503 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11504 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11505 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 11506 | if (!hif_ctx) { |
| 11507 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11508 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11509 | } |
| 11510 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 11511 | if (hdd_ctx->target_hw_name) { |
| 11512 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 11513 | hdd_ctx->target_hw_name = NULL; |
| 11514 | } |
| 11515 | |
Lin Bai | 7bae103 | 2019-04-30 12:29:36 +0800 | [diff] [blame] | 11516 | if (hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) { |
Visweswara Tanuku | c949ad2 | 2019-03-20 13:00:30 +0530 | [diff] [blame] | 11517 | epping_disable(); |
| 11518 | epping_close(); |
| 11519 | } |
| 11520 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 11521 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11522 | |
| 11523 | ol_cds_free(); |
| 11524 | |
Dustin Brown | c2a156e | 2018-10-25 16:56:27 -0700 | [diff] [blame] | 11525 | if (IS_IDLE_STOP) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11526 | ret = pld_power_off(qdf_ctx->dev); |
| 11527 | if (ret) |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11528 | hdd_err("Failed to power down device; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11529 | } |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11530 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11531 | /* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */ |
| 11532 | wlan_hdd_free_cache_channels(hdd_ctx); |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11533 | |
Sourav Mohapatra | 9036f65 | 2019-04-02 15:02:59 +0530 | [diff] [blame] | 11534 | /* Free the resources allocated while storing SAR config. These needs |
| 11535 | * to be freed only in the case when it is not SSR. As in the case of |
| 11536 | * SSR, the values needs to be intact so that it can be restored during |
| 11537 | * reinit path. |
| 11538 | */ |
| 11539 | if (!is_recovery_stop) |
| 11540 | wlan_hdd_free_sar_config(hdd_ctx); |
| 11541 | |
Jingxiang Ge | 3de0275 | 2019-01-29 15:47:03 +0800 | [diff] [blame] | 11542 | hdd_sap_destroy_ctx_all(hdd_ctx, is_recovery_stop); |
| 11543 | |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 11544 | hdd_check_for_leaks(hdd_ctx, is_recovery_stop); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 11545 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11546 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11547 | /* Once the firmware sequence is completed reset this flag */ |
| 11548 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11549 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11550 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11551 | |
Kai Liu | eabb1df | 2018-11-08 14:58:54 +0800 | [diff] [blame] | 11552 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, PLD_BUS_WIDTH_NONE); |
| 11553 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11554 | done: |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11555 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11556 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11557 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11558 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11559 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11560 | } |
| 11561 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11562 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11563 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11564 | * hdd_state_info_dump() - prints state information of hdd layer |
| 11565 | * @buf: buffer pointer |
| 11566 | * @size: size of buffer to be filled |
| 11567 | * |
| 11568 | * This function is used to dump state information of hdd layer |
| 11569 | * |
| 11570 | * Return: None |
| 11571 | */ |
| 11572 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 11573 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11574 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 11575 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11576 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11577 | uint16_t len = 0; |
| 11578 | char *buf = *buf_ptr; |
| 11579 | |
| 11580 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11581 | if (!hdd_ctx) { |
| 11582 | hdd_err("Failed to get hdd context "); |
| 11583 | return; |
| 11584 | } |
| 11585 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11586 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11587 | |
| 11588 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 11589 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11590 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 11591 | "\n is_scheduler_suspended %d", |
| 11592 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11593 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11594 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11595 | if (adapter->dev) |
| 11596 | len += scnprintf(buf + len, *size - len, |
| 11597 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 11598 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11599 | "\n device_mode: %d", adapter->device_mode); |
| 11600 | switch (adapter->device_mode) { |
| 11601 | case QDF_STA_MODE: |
| 11602 | case QDF_P2P_CLIENT_MODE: |
| 11603 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11604 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 11605 | "\n conn_state: %d", |
| 11606 | hdd_sta_ctx->conn_info.conn_state); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11607 | break; |
| 11608 | |
| 11609 | default: |
| 11610 | break; |
| 11611 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11612 | } |
| 11613 | |
| 11614 | *size -= len; |
| 11615 | *buf_ptr += len; |
| 11616 | } |
| 11617 | |
| 11618 | /** |
| 11619 | * hdd_register_debug_callback() - registration function for hdd layer |
| 11620 | * to print hdd state information |
| 11621 | * |
| 11622 | * Return: None |
| 11623 | */ |
| 11624 | static void hdd_register_debug_callback(void) |
| 11625 | { |
| 11626 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 11627 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11628 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 11629 | static void hdd_register_debug_callback(void) |
| 11630 | { |
| 11631 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11632 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11633 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11634 | /* |
| 11635 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 11636 | * |
| 11637 | * This function is used to create bug report lock |
| 11638 | * |
| 11639 | * Return: None |
| 11640 | */ |
| 11641 | static void wlan_init_bug_report_lock(void) |
| 11642 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 11643 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11644 | |
| 11645 | p_cds_context = cds_get_global_context(); |
| 11646 | if (!p_cds_context) { |
| 11647 | hdd_err("cds context is NULL"); |
| 11648 | return; |
| 11649 | } |
| 11650 | |
| 11651 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 11652 | } |
| 11653 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11654 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11655 | void hdd_dp_trace_init(struct hdd_config *config) |
| 11656 | { |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11657 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 11658 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 11659 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 11660 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 11661 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 11662 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 11663 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11664 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11665 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11666 | if (!config->enable_dp_trace) { |
| 11667 | hdd_err("dp trace is disabled from ini"); |
| 11668 | return; |
| 11669 | } |
| 11670 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11671 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 11672 | &num_entries, sizeof(config_params)); |
| 11673 | |
| 11674 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11675 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11676 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11677 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11678 | else if (bw_compute_interval > 1000) { |
| 11679 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 11680 | thresh_time_limit = 1; |
| 11681 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11682 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 11683 | |
| 11684 | switch (num_entries) { |
| 11685 | case 4: |
| 11686 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11687 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11688 | case 3: |
| 11689 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11690 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11691 | case 2: |
| 11692 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11693 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11694 | case 1: |
| 11695 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11696 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11697 | default: |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 11698 | hdd_debug("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 11699 | live_mode, thresh, thresh_time_limit, |
| 11700 | verbosity, proto_bitmap); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11701 | }; |
| 11702 | |
| 11703 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 11704 | verbosity, proto_bitmap); |
| 11705 | |
| 11706 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11707 | #endif |
| 11708 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11709 | #ifdef DISABLE_CHANNEL_LIST |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11710 | 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] | 11711 | { |
| 11712 | return qdf_mutex_create(&hdd_ctx->cache_channel_lock); |
| 11713 | } |
| 11714 | #else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11715 | 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] | 11716 | { |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11717 | return QDF_STATUS_SUCCESS; |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11718 | } |
| 11719 | #endif |
| 11720 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11721 | static QDF_STATUS hdd_open_adapter_no_trans(struct hdd_context *hdd_ctx, |
| 11722 | enum QDF_OPMODE op_mode, |
| 11723 | const char *iface_name, |
| 11724 | uint8_t *mac_addr_bytes) |
| 11725 | { |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11726 | struct osif_vdev_sync *vdev_sync; |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11727 | struct hdd_adapter *adapter; |
| 11728 | QDF_STATUS status; |
| 11729 | int errno; |
| 11730 | |
| 11731 | QDF_BUG(rtnl_is_locked()); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11732 | |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11733 | errno = osif_vdev_sync_create(hdd_ctx->parent_dev, &vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11734 | if (errno) |
| 11735 | return qdf_status_from_os_return(errno); |
| 11736 | |
| 11737 | adapter = hdd_open_adapter(hdd_ctx, op_mode, iface_name, |
| 11738 | mac_addr_bytes, NET_NAME_UNKNOWN, true); |
| 11739 | if (!adapter) { |
| 11740 | status = QDF_STATUS_E_INVAL; |
| 11741 | goto destroy_sync; |
| 11742 | } |
| 11743 | |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11744 | osif_vdev_sync_register(adapter->dev, vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11745 | |
| 11746 | return QDF_STATUS_SUCCESS; |
| 11747 | |
| 11748 | destroy_sync: |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11749 | osif_vdev_sync_destroy(vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11750 | |
| 11751 | return status; |
| 11752 | } |
| 11753 | |
| 11754 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 11755 | /** |
| 11756 | * hdd_open_p2p_interface - Open P2P interface |
| 11757 | * @hdd_ctx: HDD context |
| 11758 | * |
| 11759 | * Return: QDF_STATUS |
| 11760 | */ |
| 11761 | static QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
| 11762 | { |
| 11763 | QDF_STATUS status; |
| 11764 | bool p2p_dev_addr_admin; |
| 11765 | bool is_p2p_locally_administered = false; |
| 11766 | |
| 11767 | cfg_p2p_get_device_addr_admin(hdd_ctx->psoc, &p2p_dev_addr_admin); |
| 11768 | |
| 11769 | if (p2p_dev_addr_admin) { |
| 11770 | if (hdd_ctx->num_provisioned_addr && |
| 11771 | !(hdd_ctx->provisioned_mac_addr[0].bytes[0] & 0x02)) { |
| 11772 | hdd_ctx->p2p_device_address = |
| 11773 | hdd_ctx->provisioned_mac_addr[0]; |
| 11774 | |
| 11775 | /* |
| 11776 | * Generate the P2P Device Address. This consists of |
| 11777 | * the device's primary MAC address with the locally |
| 11778 | * administered bit set. |
| 11779 | */ |
| 11780 | |
| 11781 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
| 11782 | is_p2p_locally_administered = true; |
| 11783 | } else if (!(hdd_ctx->derived_mac_addr[0].bytes[0] & 0x02)) { |
| 11784 | hdd_ctx->p2p_device_address = |
| 11785 | hdd_ctx->derived_mac_addr[0]; |
| 11786 | /* |
| 11787 | * Generate the P2P Device Address. This consists of |
| 11788 | * the device's primary MAC address with the locally |
| 11789 | * administered bit set. |
| 11790 | */ |
| 11791 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
| 11792 | is_p2p_locally_administered = true; |
| 11793 | } |
| 11794 | } |
| 11795 | if (!is_p2p_locally_administered) { |
| 11796 | uint8_t *p2p_dev_addr; |
| 11797 | |
| 11798 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx, |
| 11799 | QDF_P2P_DEVICE_MODE); |
| 11800 | if (!p2p_dev_addr) { |
| 11801 | hdd_err("Failed to get MAC address for new p2p device"); |
| 11802 | return QDF_STATUS_E_INVAL; |
| 11803 | } |
| 11804 | |
| 11805 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
| 11806 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
| 11807 | } |
| 11808 | |
| 11809 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_P2P_DEVICE_MODE, |
| 11810 | "p2p%d", |
| 11811 | hdd_ctx->p2p_device_address.bytes); |
| 11812 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11813 | hdd_err("Failed to open p2p interface"); |
| 11814 | return QDF_STATUS_E_INVAL; |
| 11815 | } |
| 11816 | |
| 11817 | return QDF_STATUS_SUCCESS; |
| 11818 | } |
| 11819 | #else |
| 11820 | static inline QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
| 11821 | { |
| 11822 | return QDF_STATUS_SUCCESS; |
| 11823 | } |
| 11824 | #endif |
| 11825 | |
| 11826 | static QDF_STATUS hdd_open_ocb_interface(struct hdd_context *hdd_ctx) |
| 11827 | { |
| 11828 | QDF_STATUS status; |
| 11829 | uint8_t *mac_addr; |
| 11830 | |
| 11831 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_OCB_MODE); |
| 11832 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_OCB_MODE, |
| 11833 | "wlanocb%d", mac_addr); |
| 11834 | if (QDF_IS_STATUS_ERROR(status)) |
| 11835 | hdd_err("Failed to open 802.11p interface"); |
| 11836 | |
| 11837 | return status; |
| 11838 | } |
| 11839 | |
| 11840 | static QDF_STATUS hdd_open_concurrent_interface(struct hdd_context *hdd_ctx) |
| 11841 | { |
| 11842 | QDF_STATUS status; |
| 11843 | const char *iface_name; |
| 11844 | uint8_t *mac_addr; |
| 11845 | |
| 11846 | if (qdf_str_eq(hdd_ctx->config->enable_concurrent_sta, "")) |
| 11847 | return QDF_STATUS_SUCCESS; |
| 11848 | |
| 11849 | iface_name = hdd_ctx->config->enable_concurrent_sta; |
| 11850 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_STA_MODE); |
| 11851 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_STA_MODE, |
| 11852 | iface_name, mac_addr); |
| 11853 | if (QDF_IS_STATUS_ERROR(status)) |
| 11854 | hdd_err("Failed to open concurrent station interface"); |
| 11855 | |
| 11856 | return status; |
| 11857 | } |
| 11858 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11859 | static QDF_STATUS |
| 11860 | hdd_open_adapters_for_mission_mode(struct hdd_context *hdd_ctx) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11861 | { |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11862 | enum dot11p_mode dot11p_mode; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11863 | QDF_STATUS status; |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11864 | uint8_t *mac_addr; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11865 | |
| 11866 | ucfg_mlme_get_dot11p_mode(hdd_ctx->psoc, &dot11p_mode); |
| 11867 | |
| 11868 | /* Create only 802.11p interface? */ |
| 11869 | if (dot11p_mode == CFG_11P_STANDALONE) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11870 | return hdd_open_ocb_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11871 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11872 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_STA_MODE); |
| 11873 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_STA_MODE, |
| 11874 | "wlan%d", mac_addr); |
| 11875 | if (QDF_IS_STATUS_ERROR(status)) |
| 11876 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11877 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11878 | /* opening concurrent STA is best effort, continue on error */ |
| 11879 | hdd_open_concurrent_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11880 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11881 | status = hdd_open_p2p_interface(hdd_ctx); |
| 11882 | if (status) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11883 | goto err_close_adapters; |
| 11884 | |
| 11885 | /* Open 802.11p Interface */ |
| 11886 | if (dot11p_mode == CFG_11P_CONCURRENT) { |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11887 | status = hdd_open_ocb_interface(hdd_ctx); |
| 11888 | if (QDF_IS_STATUS_ERROR(status)) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11889 | goto err_close_adapters; |
| 11890 | } |
| 11891 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11892 | return QDF_STATUS_SUCCESS; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11893 | |
| 11894 | err_close_adapters: |
| 11895 | hdd_close_all_adapters(hdd_ctx, true); |
| 11896 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11897 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11898 | } |
| 11899 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11900 | 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] | 11901 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11902 | 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] | 11903 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11904 | return hdd_open_adapter_no_trans(hdd_ctx, QDF_FTM_MODE, |
| 11905 | "wlan%d", mac_addr); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11906 | } |
| 11907 | |
| 11908 | static QDF_STATUS |
| 11909 | hdd_open_adapters_for_monitor_mode(struct hdd_context *hdd_ctx) |
| 11910 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11911 | 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] | 11912 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11913 | return hdd_open_adapter_no_trans(hdd_ctx, QDF_MONITOR_MODE, |
| 11914 | "wlan%d", mac_addr); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11915 | } |
| 11916 | |
| 11917 | static QDF_STATUS hdd_open_adapters_for_epping_mode(struct hdd_context *hdd_ctx) |
| 11918 | { |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11919 | epping_enable_adapter(); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11920 | return QDF_STATUS_SUCCESS; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11921 | } |
| 11922 | |
| 11923 | typedef QDF_STATUS (*hdd_open_mode_handler)(struct hdd_context *hdd_ctx); |
| 11924 | |
| 11925 | static const hdd_open_mode_handler |
| 11926 | hdd_open_mode_handlers[QDF_GLOBAL_MAX_MODE] = { |
| 11927 | [QDF_GLOBAL_MISSION_MODE] = hdd_open_adapters_for_mission_mode, |
| 11928 | [QDF_GLOBAL_FTM_MODE] = hdd_open_adapters_for_ftm_mode, |
| 11929 | [QDF_GLOBAL_MONITOR_MODE] = hdd_open_adapters_for_monitor_mode, |
| 11930 | [QDF_GLOBAL_EPPING_MODE] = hdd_open_adapters_for_epping_mode, |
| 11931 | }; |
| 11932 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11933 | static QDF_STATUS hdd_open_adapters_for_mode(struct hdd_context *hdd_ctx, |
| 11934 | enum QDF_GLOBAL_MODE driver_mode) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11935 | { |
| 11936 | QDF_STATUS status; |
| 11937 | |
| 11938 | if (driver_mode < 0 || |
| 11939 | driver_mode >= QDF_GLOBAL_MAX_MODE || |
| 11940 | !hdd_open_mode_handlers[driver_mode]) { |
| 11941 | hdd_err("Driver mode %d not supported", driver_mode); |
| 11942 | return -ENOTSUPP; |
| 11943 | } |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11944 | |
| 11945 | hdd_hold_rtnl_lock(); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11946 | status = hdd_open_mode_handlers[driver_mode](hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11947 | hdd_release_rtnl_lock(); |
| 11948 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11949 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11950 | } |
| 11951 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11952 | int hdd_wlan_startup(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11953 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11954 | QDF_STATUS status; |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11955 | int errno; |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 11956 | bool is_imps_enabled; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11957 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11958 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11959 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11960 | hdd_action_oui_config(hdd_ctx); |
| 11961 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11962 | qdf_nbuf_init_replenish_timer(); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11963 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11964 | status = wlan_hdd_cache_chann_mutex_create(hdd_ctx); |
| 11965 | if (QDF_IS_STATUS_ERROR(status)) |
| 11966 | return qdf_status_to_os_return(status); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11967 | |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 11968 | #ifdef FEATURE_WLAN_CH_AVOID |
| 11969 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 11970 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11971 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11972 | osif_request_manager_init(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11973 | hdd_driver_memdump_init(); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11974 | hdd_bus_bandwidth_init(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11975 | |
Arunk Khandavalli | 5ff037547 | 2019-01-11 17:26:47 +0530 | [diff] [blame] | 11976 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 11977 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
| 11978 | QDF_TIMER_TYPE_SW, |
| 11979 | hdd_skip_acs_scan_timer_handler, |
| 11980 | hdd_ctx); |
| 11981 | if (QDF_IS_STATUS_ERROR(status)) |
| 11982 | hdd_err("Failed to init ACS Skip timer"); |
| 11983 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
| 11984 | #endif |
| 11985 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11986 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 11987 | if (errno) { |
| 11988 | hdd_err("Failed to start modules; errno:%d", errno); |
| 11989 | goto memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11990 | } |
| 11991 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11992 | if (hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) |
| 11993 | return 0; |
| 11994 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 11995 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11996 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11997 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 11998 | if (!hdd_ctx->mac_handle) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11999 | hdd_err("Mac Handle is null"); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12000 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12001 | } |
| 12002 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12003 | errno = hdd_wiphy_init(hdd_ctx); |
| 12004 | if (errno) { |
| 12005 | hdd_err("Failed to initialize wiphy; errno:%d", errno); |
| 12006 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12007 | } |
| 12008 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 12009 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 12010 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 12011 | errno = hdd_initialize_mac_address(hdd_ctx); |
| 12012 | if (errno) { |
| 12013 | hdd_err("MAC initializtion failed: %d", errno); |
| 12014 | goto unregister_wiphy; |
| 12015 | } |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 12016 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12017 | errno = register_netdevice_notifier(&hdd_netdev_notifier); |
| 12018 | if (errno) { |
| 12019 | hdd_err("register_netdevice_notifier failed; errno:%d", errno); |
| 12020 | goto unregister_wiphy; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 12021 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 12022 | |
Sandeep Puligilla | 3461878 | 2019-01-04 17:42:42 -0800 | [diff] [blame] | 12023 | wlan_hdd_update_11n_mode(hdd_ctx); |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 12024 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 12025 | hdd_lpass_notify_wlan_version(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12026 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12027 | errno = hdd_register_notifiers(hdd_ctx); |
| 12028 | if (errno) |
Arun Kumar Khandavalli | 4b6e218 | 2019-04-29 18:32:09 +0530 | [diff] [blame] | 12029 | goto unregister_netdev; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 12030 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 12031 | status = wlansap_global_init(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12032 | if (QDF_IS_STATUS_ERROR(status)) |
| 12033 | goto unregister_notifiers; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 12034 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 12035 | ucfg_mlme_is_imps_enabled(hdd_ctx->psoc, &is_imps_enabled); |
| 12036 | hdd_set_idle_ps_config(hdd_ctx, is_imps_enabled); |
Arun Kumar Khandavalli | deda5a8 | 2019-03-11 15:32:19 +0530 | [diff] [blame] | 12037 | hdd_debugfs_mws_coex_info_init(hdd_ctx); |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame] | 12038 | wlan_cfg80211_init_interop_issues_ap(hdd_ctx->pdev); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12039 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12040 | hdd_exit(); |
| 12041 | |
| 12042 | return 0; |
| 12043 | |
| 12044 | unregister_notifiers: |
| 12045 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12046 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12047 | unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 12048 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 12049 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12050 | unregister_wiphy: |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 12051 | qdf_dp_trace_deinit(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 12052 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12053 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12054 | stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12055 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12056 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12057 | memdump_deinit: |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 12058 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 12059 | hdd_driver_memdump_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 12060 | osif_request_manager_deinit(); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12061 | qdf_nbuf_deinit_replenish_timer(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 12062 | |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 12063 | if (cds_is_fw_down()) |
| 12064 | hdd_err("Not setting the complete event as fw is down"); |
| 12065 | else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12066 | hdd_start_complete(errno); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12067 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12068 | hdd_exit(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12069 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12070 | return errno; |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12071 | } |
| 12072 | |
| 12073 | QDF_STATUS hdd_psoc_create_vdevs(struct hdd_context *hdd_ctx) |
| 12074 | { |
| 12075 | enum QDF_GLOBAL_MODE driver_mode = hdd_get_conparam(); |
| 12076 | QDF_STATUS status; |
| 12077 | |
| 12078 | status = hdd_open_adapters_for_mode(hdd_ctx, driver_mode); |
| 12079 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12080 | hdd_err("Failed to create vdevs; status:%d", status); |
| 12081 | return status; |
| 12082 | } |
| 12083 | |
| 12084 | if (hdd_ctx->rps) |
| 12085 | hdd_set_rps_cpu_mask(hdd_ctx); |
| 12086 | |
Guisen Yang | 2780b92 | 2019-06-03 16:21:39 +0800 | [diff] [blame] | 12087 | if (driver_mode != QDF_GLOBAL_FTM_MODE && |
| 12088 | driver_mode != QDF_GLOBAL_EPPING_MODE) |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12089 | hdd_psoc_idle_timer_start(hdd_ctx); |
| 12090 | |
| 12091 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12092 | } |
| 12093 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12094 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12095 | * hdd_wlan_update_target_info() - update target type info |
| 12096 | * @hdd_ctx: HDD context |
| 12097 | * @context: hif context |
| 12098 | * |
| 12099 | * Update target info received from firmware in hdd context |
| 12100 | * Return:None |
| 12101 | */ |
| 12102 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12103 | 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] | 12104 | { |
| 12105 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 12106 | |
| 12107 | if (!tgt_info) { |
| 12108 | hdd_err("Target info is Null"); |
| 12109 | return; |
| 12110 | } |
| 12111 | |
| 12112 | hdd_ctx->target_type = tgt_info->target_type; |
| 12113 | } |
| 12114 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12115 | 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] | 12116 | { |
| 12117 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12118 | int status; |
| 12119 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12120 | struct osif_request *request = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12121 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12122 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12123 | |
| 12124 | if (!rsp) { |
| 12125 | hdd_err("data is null"); |
| 12126 | return; |
| 12127 | } |
| 12128 | |
| 12129 | status = wlan_hdd_validate_context(hdd_ctx); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12130 | if (status != 0) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12131 | return; |
| 12132 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12133 | request = osif_request_get(context); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12134 | if (!request) { |
| 12135 | hdd_err("obselete request"); |
| 12136 | return; |
| 12137 | } |
| 12138 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12139 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12140 | if ((!adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12141 | hdd_err("Invalid adapter or adapter has invalid magic"); |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12142 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12143 | return; |
| 12144 | } |
| 12145 | |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 12146 | hdd_debug("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 12147 | hdd_debug("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 12148 | hdd_debug("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 12149 | hdd_debug("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 12150 | hdd_debug("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 12151 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 12152 | hdd_debug("rsp->dad_detected :%x", rsp->dad_detected); |
| 12153 | hdd_debug("rsp->connect_status :%x", rsp->connect_status); |
| 12154 | hdd_debug("rsp->ba_session_establishment_status :%x", |
| 12155 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12156 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12157 | 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] | 12158 | adapter->dad |= rsp->dad_detected; |
| 12159 | adapter->con_status = rsp->connect_status; |
| 12160 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12161 | /* Flag true indicates connectivity check stats present. */ |
| 12162 | if (rsp->connect_stats_present) { |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 12163 | hdd_debug("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 12164 | hdd_debug("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12165 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 12166 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 12167 | rsp->icmpv4_rsp_recvd; |
| 12168 | } |
| 12169 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12170 | osif_request_complete(request); |
| 12171 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12172 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12173 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12174 | } |
| 12175 | |
Visweswara Tanuku | 633976b | 2019-01-07 16:13:12 +0530 | [diff] [blame] | 12176 | #ifdef WLAN_FEATURE_MOTION_DETECTION |
| 12177 | /** |
| 12178 | * hdd_md_host_evt_cb - Callback for Motion Detection Event |
| 12179 | * @ctx: HDD context |
| 12180 | * @event: motion detect event |
| 12181 | * |
| 12182 | * Callback for Motion Detection Event. Re-enables Motion |
| 12183 | * Detection again upon event |
| 12184 | * |
| 12185 | * Return: QDF_STATUS QDF_STATUS_SUCCESS on Success and |
| 12186 | * QDF_STATUS_E_FAILURE on failure |
| 12187 | */ |
| 12188 | QDF_STATUS hdd_md_host_evt_cb(void *ctx, struct sir_md_evt *event) |
| 12189 | { |
| 12190 | struct hdd_adapter *adapter = NULL; |
| 12191 | struct hdd_context *hdd_ctx; |
| 12192 | QDF_STATUS status; |
| 12193 | struct sme_motion_det_en motion_det; |
| 12194 | |
| 12195 | if (!ctx || !event) |
| 12196 | return QDF_STATUS_E_INVAL; |
| 12197 | |
| 12198 | hdd_ctx = (struct hdd_context *)ctx; |
| 12199 | status = wlan_hdd_validate_context(hdd_ctx); |
| 12200 | if (0 != status) |
| 12201 | return QDF_STATUS_E_INVAL; |
| 12202 | |
| 12203 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, event->vdev_id); |
| 12204 | if (!adapter || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 12205 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 12206 | return QDF_STATUS_E_INVAL; |
| 12207 | } |
| 12208 | |
| 12209 | hdd_debug("Motion Detection CB vdev_id=%u, status=%u", |
| 12210 | event->vdev_id, event->status); |
| 12211 | |
| 12212 | if (adapter->motion_detection_mode) { |
| 12213 | motion_det.vdev_id = event->vdev_id; |
| 12214 | motion_det.enable = 1; |
| 12215 | hdd_debug("Motion Detect CB -> Enable Motion Detection again"); |
| 12216 | sme_motion_det_enable(hdd_ctx->mac_handle, &motion_det); |
| 12217 | } |
| 12218 | |
| 12219 | return QDF_STATUS_SUCCESS; |
| 12220 | } |
| 12221 | #endif /* WLAN_FEATURE_MOTION_DETECTION */ |
| 12222 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12223 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12224 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12225 | * @hdd_ctx: HDD context |
| 12226 | * |
| 12227 | * Register the HDD callbacks to CDS/SME. |
| 12228 | * |
| 12229 | * Return: 0 for success or Error code for failure |
| 12230 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12231 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12232 | { |
| 12233 | QDF_STATUS status; |
| 12234 | int ret = 0; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12235 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12236 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12237 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12238 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12239 | hdd_err("in ftm mode, no need to register callbacks"); |
| 12240 | return ret; |
| 12241 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12242 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12243 | mac_handle = hdd_ctx->mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12244 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12245 | sme_register_oem_data_rsp_callback(mac_handle, |
| 12246 | hdd_send_oem_data_rsp_msg); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12247 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12248 | sme_register_mgmt_frame_ind_callback(mac_handle, |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 12249 | hdd_indicate_mgmt_frame); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12250 | sme_set_tsfcb(mac_handle, hdd_get_tsf_cb, hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12251 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12252 | wlan_hdd_cfg80211_stats_ext_callback); |
| 12253 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12254 | sme_ext_scan_register_callback(mac_handle, |
| 12255 | wlan_hdd_cfg80211_extscan_callback); |
| 12256 | sme_stats_ext2_register_callback(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 12257 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12258 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12259 | sme_set_rssi_threshold_breached_cb(mac_handle, |
| 12260 | hdd_rssi_threshold_breached); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12261 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12262 | sme_set_link_layer_stats_ind_cb(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12263 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 12264 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12265 | 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] | 12266 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12267 | sme_set_link_layer_ext_cb(mac_handle, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 12268 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
Abhinav Kumar | 338e57d | 2019-02-04 17:30:10 +0530 | [diff] [blame] | 12269 | sme_update_hidden_ssid_status_cb(mac_handle, |
| 12270 | hdd_hidden_ssid_enable_roaming); |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 12271 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12272 | status = sme_set_lost_link_info_cb(mac_handle, |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 12273 | hdd_lost_link_info_cb); |
| 12274 | /* print error and not block the startup process */ |
| 12275 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12276 | hdd_err("set lost link info callback failed"); |
| 12277 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12278 | ret = hdd_register_data_stall_detect_cb(); |
| 12279 | if (ret) { |
| 12280 | hdd_err("Register data stall detect detect callback failed."); |
| 12281 | return ret; |
| 12282 | } |
| 12283 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12284 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 12285 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12286 | sme_register_set_connection_info_cb(mac_handle, |
| 12287 | hdd_set_connection_in_progress, |
| 12288 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12289 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12290 | status = sme_congestion_register_callback(mac_handle, |
| 12291 | hdd_update_cca_info_cb); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12292 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12293 | hdd_err("set congestion callback failed"); |
| 12294 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12295 | status = sme_set_bt_activity_info_cb(mac_handle, |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 12296 | hdd_bt_activity_cb); |
| 12297 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12298 | hdd_err("set bt activity info callback failed"); |
| 12299 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12300 | status = sme_register_tx_queue_cb(mac_handle, |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 12301 | hdd_tx_queue_cb); |
| 12302 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12303 | hdd_err("Register tx queue callback failed"); |
| 12304 | |
Visweswara Tanuku | 633976b | 2019-01-07 16:13:12 +0530 | [diff] [blame] | 12305 | #ifdef WLAN_FEATURE_MOTION_DETECTION |
| 12306 | sme_set_md_host_evt_cb(mac_handle, hdd_md_host_evt_cb, (void *)hdd_ctx); |
| 12307 | #endif /* WLAN_FEATURE_MOTION_DETECTION */ |
| 12308 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12309 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12310 | |
| 12311 | return ret; |
| 12312 | } |
| 12313 | |
| 12314 | /** |
| 12315 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 12316 | * @hdd_ctx: HDD context |
| 12317 | * |
| 12318 | * De-Register the HDD callbacks to CDS/SME. |
| 12319 | * |
| 12320 | * Return: void |
| 12321 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12322 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12323 | { |
| 12324 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12325 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12326 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12327 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12328 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12329 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12330 | hdd_err("in ftm mode, no need to deregister callbacks"); |
| 12331 | return; |
| 12332 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12333 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12334 | mac_handle = hdd_ctx->mac_handle; |
| 12335 | sme_deregister_tx_queue_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12336 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12337 | sme_reset_link_layer_stats_ind_cb(mac_handle); |
| 12338 | sme_reset_rssi_threshold_breached_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12339 | |
Min Liu | d35ae31 | 2019-05-08 15:43:13 +0800 | [diff] [blame] | 12340 | sme_stats_ext_deregister_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12341 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12342 | status = sme_reset_tsfcb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12343 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12344 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 12345 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12346 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12347 | ret = hdd_deregister_data_stall_detect_cb(); |
| 12348 | if (ret) |
| 12349 | hdd_err("Failed to de-register data stall detect event callback"); |
| 12350 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12351 | sme_deregister_oem_data_rsp_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12352 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12353 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12354 | } |
| 12355 | |
| 12356 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12357 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12358 | * @adapter: Pointer to the HDD adapter |
| 12359 | * @param: Params to the operation |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12360 | * |
| 12361 | * This to take counter measure to handle deauth req from HDD |
| 12362 | * |
| 12363 | * Return: None |
| 12364 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12365 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12366 | struct csr_del_sta_params *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12367 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12368 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12369 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12370 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12371 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12372 | /* Ignore request to deauth bcmc station */ |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12373 | if (param->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12374 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12375 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12376 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12377 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12378 | param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12379 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12380 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12381 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12382 | } |
| 12383 | |
| 12384 | /** |
| 12385 | * 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] | 12386 | * @adapter: Pointer to the HDD |
| 12387 | * @param: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12388 | * |
| 12389 | * This to take counter measure to handle deauth req from HDD |
| 12390 | * |
| 12391 | * Return: None |
| 12392 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12393 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12394 | struct csr_del_sta_params *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12395 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12396 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12397 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12398 | /* Ignore request to disassoc bcmc station */ |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12399 | if (param->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12400 | return; |
| 12401 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12402 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12403 | param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12404 | } |
| 12405 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12406 | void wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12407 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12408 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12409 | struct hdd_adapter *adapter = NULL; |
| 12410 | struct csr_roam_profile *roam_profile; |
| 12411 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12412 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12413 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12414 | hdd_debug("No active sta session"); |
| 12415 | return; |
| 12416 | } |
| 12417 | |
| 12418 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12419 | roam_profile = hdd_roam_profile(adapter); |
| 12420 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12421 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12422 | if (cur_adapter->vdev_id != adapter->vdev_id && |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12423 | adapter->device_mode == QDF_STA_MODE && |
| 12424 | hdd_conn_is_connected(sta_ctx)) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12425 | hdd_debug("%d Disable roaming", adapter->vdev_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12426 | sme_stop_roaming(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12427 | adapter->vdev_id, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12428 | ecsr_driver_disabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12429 | } |
| 12430 | } |
| 12431 | } |
| 12432 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12433 | void wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12434 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12435 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12436 | struct hdd_adapter *adapter = NULL; |
| 12437 | struct csr_roam_profile *roam_profile; |
| 12438 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12439 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12440 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12441 | hdd_debug("No active sta session"); |
| 12442 | return; |
| 12443 | } |
| 12444 | |
| 12445 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12446 | roam_profile = hdd_roam_profile(adapter); |
| 12447 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12448 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12449 | if (cur_adapter->vdev_id != adapter->vdev_id && |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12450 | adapter->device_mode == QDF_STA_MODE && |
| 12451 | hdd_conn_is_connected(sta_ctx)) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12452 | hdd_debug("%d Enable roaming", adapter->vdev_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12453 | sme_start_roaming(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12454 | adapter->vdev_id, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12455 | REASON_DRIVER_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12456 | } |
| 12457 | } |
| 12458 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12459 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12460 | /** |
| 12461 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 12462 | * @skb: sk buffer pointer |
| 12463 | * |
| 12464 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 12465 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 12466 | * |
| 12467 | * Return: None |
| 12468 | */ |
| 12469 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 12470 | { |
| 12471 | #ifdef CNSS_GENL |
| 12472 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 12473 | #else |
| 12474 | nl_srv_bcast(skb); |
| 12475 | #endif |
| 12476 | } |
| 12477 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12478 | 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] | 12479 | { |
| 12480 | struct sk_buff *skb; |
| 12481 | struct nlmsghdr *nlh; |
| 12482 | tAniMsgHdr *ani_hdr; |
| 12483 | void *nl_data = NULL; |
| 12484 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12485 | struct radio_index_tlv *radio_info; |
| 12486 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12487 | |
| 12488 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 12489 | flags = GFP_ATOMIC; |
| 12490 | |
| 12491 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 12492 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12493 | if (!skb) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12494 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12495 | |
| 12496 | nlh = (struct nlmsghdr *)skb->data; |
| 12497 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 12498 | nlh->nlmsg_flags = 0; |
| 12499 | nlh->nlmsg_seq = 0; |
| 12500 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 12501 | |
| 12502 | ani_hdr = NLMSG_DATA(nlh); |
| 12503 | ani_hdr->type = type; |
| 12504 | |
| 12505 | switch (type) { |
| 12506 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 12507 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12508 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12509 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12510 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12511 | ani_hdr->length = 0; |
| 12512 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12513 | break; |
| 12514 | case WLAN_SVC_WLAN_STATUS_IND: |
| 12515 | case WLAN_SVC_WLAN_VERSION_IND: |
| 12516 | case WLAN_SVC_DFS_CAC_START_IND: |
| 12517 | case WLAN_SVC_DFS_CAC_END_IND: |
| 12518 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 12519 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 12520 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 12521 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 12522 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 12523 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12524 | ani_hdr->length = len; |
| 12525 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 12526 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 12527 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12528 | break; |
| 12529 | |
| 12530 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 12531 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12532 | type); |
| 12533 | kfree_skb(skb); |
| 12534 | return; |
| 12535 | } |
| 12536 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12537 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 12538 | * Add radio index at the end of the svc event in TLV format |
| 12539 | * to maintain the backward compatibility with userspace |
| 12540 | * applications. |
| 12541 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12542 | |
| 12543 | tlv_len = 0; |
| 12544 | |
| 12545 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 12546 | < WLAN_NL_MAX_PAYLOAD) { |
| 12547 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 12548 | sizeof(*ani_hdr) + len); |
| 12549 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 12550 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 12551 | radio_info->radio = radio; |
| 12552 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12553 | hdd_debug("Added radio index tlv - radio index %d", |
| 12554 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12555 | } |
| 12556 | |
| 12557 | nlh->nlmsg_len += tlv_len; |
| 12558 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 12559 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12560 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12561 | } |
| 12562 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12563 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 12564 | void wlan_hdd_auto_shutdown_cb(void) |
| 12565 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12566 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12567 | |
| 12568 | if (!hdd_ctx) |
| 12569 | return; |
| 12570 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12571 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12572 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 12573 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12574 | } |
| 12575 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12576 | 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] | 12577 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12578 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12579 | bool ap_connected = false, sta_connected = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12580 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12581 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12582 | mac_handle = hdd_ctx->mac_handle; |
| 12583 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12584 | return; |
| 12585 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12586 | if (hdd_ctx->config->wlan_auto_shutdown == 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12587 | return; |
| 12588 | |
| 12589 | if (enable == false) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12590 | if (sme_set_auto_shutdown_timer(mac_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12591 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12592 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12593 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12594 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12595 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12596 | return; |
| 12597 | } |
| 12598 | |
| 12599 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12600 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->psoc)) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12601 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12602 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12603 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 12604 | conn_info.conn_state == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12605 | eConnectionState_Associated) { |
| 12606 | sta_connected = true; |
| 12607 | break; |
| 12608 | } |
| 12609 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12610 | |
| 12611 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12612 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12613 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12614 | ap_connected = true; |
| 12615 | break; |
| 12616 | } |
| 12617 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12618 | } |
| 12619 | } |
| 12620 | |
| 12621 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12622 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12623 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12624 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12625 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12626 | if (sme_set_auto_shutdown_timer(mac_handle, |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12627 | hdd_ctx->config->wlan_auto_shutdown) |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12628 | != QDF_STATUS_SUCCESS) |
| 12629 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 12630 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 12631 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12632 | hdd_ctx->config->wlan_auto_shutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12633 | } |
| 12634 | #endif |
| 12635 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12636 | struct hdd_adapter * |
| 12637 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 12638 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12639 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12640 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12641 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12642 | |
| 12643 | con_sap_adapter = NULL; |
| 12644 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12645 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12646 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 12647 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12648 | adapter != this_sap_adapter) { |
| 12649 | if (check_start_bss) { |
| 12650 | if (test_bit(SOFTAP_BSS_STARTED, |
| 12651 | &adapter->event_flags)) { |
| 12652 | con_sap_adapter = adapter; |
| 12653 | break; |
| 12654 | } |
| 12655 | } else { |
| 12656 | con_sap_adapter = adapter; |
| 12657 | break; |
| 12658 | } |
| 12659 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12660 | } |
| 12661 | |
| 12662 | return con_sap_adapter; |
| 12663 | } |
| 12664 | |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 12665 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12666 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12667 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12668 | return adapter->device_mode == QDF_STA_MODE || |
| 12669 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12670 | } |
| 12671 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12672 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12673 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12674 | return adapter->device_mode == QDF_SAP_MODE || |
| 12675 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 12676 | } |
| 12677 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12678 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12679 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12680 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12681 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12682 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12683 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12684 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 12685 | conn_info.conn_state == eConnectionState_Associated) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12686 | return true; |
| 12687 | } |
| 12688 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12689 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12690 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12691 | return true; |
| 12692 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12693 | } |
| 12694 | |
| 12695 | return false; |
| 12696 | } |
| 12697 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12698 | 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] | 12699 | { |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 12700 | qdf_periodic_work_start(&hdd_ctx->bus_bw_work, |
| 12701 | hdd_ctx->config->bus_bw_compute_interval); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12702 | } |
| 12703 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12704 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12705 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12706 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12707 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12708 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12709 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12710 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12711 | } |
| 12712 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12713 | 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] | 12714 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12715 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12716 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12717 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12718 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12719 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12720 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12721 | } |
| 12722 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12723 | 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] | 12724 | { |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 12725 | if (!qdf_periodic_work_stop_sync(&hdd_ctx->bus_bw_work)) |
| 12726 | return; |
| 12727 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12728 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12729 | hdd_reset_tcp_delack(hdd_ctx); |
Tiger Yu | e40e783 | 2019-04-25 10:46:53 +0800 | [diff] [blame^] | 12730 | cdp_pdev_reset_driver_del_ack(cds_get_context(QDF_MODULE_ID_SOC), |
| 12731 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12732 | } |
| 12733 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12734 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12735 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12736 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12737 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12738 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12739 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12740 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12741 | } |
| 12742 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12743 | 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] | 12744 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12745 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12746 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12747 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12748 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12749 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12750 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12751 | } |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame] | 12752 | #endif /*WLAN_FEATURE_DP_BUS_BANDWIDTH*/ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12753 | |
| 12754 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12755 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 12756 | * @ap_adapter: SAP adapter |
| 12757 | * |
| 12758 | * This function will process the stopping of sap adapter. |
| 12759 | * |
| 12760 | * Return: None |
| 12761 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12762 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12763 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12764 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12765 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12766 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12767 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12768 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12769 | if (!ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12770 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12771 | return; |
| 12772 | } |
| 12773 | |
| 12774 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12775 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12776 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12777 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12778 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12779 | mutex_lock(&hdd_ctx->sap_lock); |
| 12780 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 12781 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12782 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12783 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12784 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12785 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12786 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12787 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 12788 | qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 12789 | SME_CMD_STOP_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12790 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12791 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12792 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12793 | return; |
| 12794 | } |
| 12795 | } |
| 12796 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12797 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12798 | ap_adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12799 | ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12800 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12801 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12802 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12803 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12804 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12805 | } |
| 12806 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12807 | } |
| 12808 | |
| 12809 | /** |
| 12810 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 12811 | * @ap_adapter: SAP adapter |
| 12812 | * |
| 12813 | * This function will process the starting of sap adapter. |
| 12814 | * |
| 12815 | * Return: None |
| 12816 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12817 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12818 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12819 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12820 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12821 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12822 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 8f8ceb9 | 2019-03-24 08:16:55 -0700 | [diff] [blame] | 12823 | struct sap_config *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12824 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12825 | if (!ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12826 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12827 | return; |
| 12828 | } |
| 12829 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12830 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 12831 | hdd_err("SoftAp role has not been enabled"); |
| 12832 | return; |
| 12833 | } |
| 12834 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12835 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 12836 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12837 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 12838 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12839 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12840 | mutex_lock(&hdd_ctx->sap_lock); |
| 12841 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 12842 | goto end; |
| 12843 | |
| 12844 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12845 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12846 | goto end; |
| 12847 | } |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12848 | wlan_reg_set_channel_params(hdd_ctx->pdev, |
Abhinav Kumar | 6f69448 | 2018-09-04 16:07:39 +0530 | [diff] [blame] | 12849 | hdd_ap_ctx->sap_config.channel, 0, |
| 12850 | &hdd_ap_ctx->sap_config.ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12851 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 12852 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12853 | 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] | 12854 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12855 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12856 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12857 | goto end; |
| 12858 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12859 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12860 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 12861 | SME_CMD_START_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12862 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12863 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12864 | goto end; |
| 12865 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12866 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12867 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12868 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12869 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12870 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12871 | ap_adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12872 | ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12873 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12874 | true); |
| 12875 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 12876 | mutex_unlock(&hdd_ctx->sap_lock); |
| 12877 | |
| 12878 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12879 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12880 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12881 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 12882 | /* SAP context and beacon cleanup will happen during driver unload |
| 12883 | * in hdd_stop_adapter |
| 12884 | */ |
| 12885 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 12886 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12887 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12888 | |
| 12889 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12890 | * hdd_get_fw_version() - Get FW version |
| 12891 | * @hdd_ctx: pointer to HDD context. |
| 12892 | * @major_spid: FW version - major spid. |
| 12893 | * @minor_spid: FW version - minor spid |
| 12894 | * @ssid: FW version - ssid |
| 12895 | * @crmid: FW version - crmid |
| 12896 | * |
| 12897 | * This function is called to get the firmware build version stored |
| 12898 | * as part of the HDD context |
| 12899 | * |
| 12900 | * Return: None |
| 12901 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12902 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12903 | uint32_t *major_spid, uint32_t *minor_spid, |
| 12904 | uint32_t *siid, uint32_t *crmid) |
| 12905 | { |
| 12906 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 12907 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 12908 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 12909 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 12910 | } |
| 12911 | |
| 12912 | #ifdef QCA_CONFIG_SMP |
| 12913 | /** |
| 12914 | * wlan_hdd_get_cpu() - get cpu_index |
| 12915 | * |
| 12916 | * Return: cpu_index |
| 12917 | */ |
| 12918 | int wlan_hdd_get_cpu(void) |
| 12919 | { |
| 12920 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12921 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12922 | put_cpu(); |
| 12923 | return cpu_index; |
| 12924 | } |
| 12925 | #endif |
| 12926 | |
| 12927 | /** |
| 12928 | * hdd_get_fwpath() - get framework path |
| 12929 | * |
| 12930 | * This function is used to get the string written by |
| 12931 | * userspace to start the wlan driver |
| 12932 | * |
| 12933 | * Return: string |
| 12934 | */ |
| 12935 | const char *hdd_get_fwpath(void) |
| 12936 | { |
| 12937 | return fwpath.string; |
| 12938 | } |
| 12939 | |
Dustin Brown | 94ce20f | 2018-09-04 13:11:38 -0700 | [diff] [blame] | 12940 | static inline int hdd_state_query_cb(void) |
| 12941 | { |
| 12942 | return !!wlan_hdd_validate_context(cds_get_context(QDF_MODULE_ID_HDD)); |
| 12943 | } |
| 12944 | |
Dustin Brown | 265e82b | 2019-03-18 11:07:32 -0700 | [diff] [blame] | 12945 | static int __hdd_op_protect_cb(void **out_sync, const char *func) |
| 12946 | { |
| 12947 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12948 | |
| 12949 | if (!hdd_ctx) |
| 12950 | return -EAGAIN; |
| 12951 | |
| 12952 | return __osif_psoc_sync_op_start(hdd_ctx->parent_dev, |
| 12953 | (struct osif_psoc_sync **)out_sync, |
| 12954 | func); |
| 12955 | } |
| 12956 | |
| 12957 | static void __hdd_op_unprotect_cb(void *sync, const char *func) |
| 12958 | { |
| 12959 | __osif_psoc_sync_op_stop(sync, func); |
| 12960 | } |
| 12961 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12962 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12963 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12964 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12965 | * This function initilizes CDS global context with the help of cds_init. This |
| 12966 | * has to be the first function called after probe to get a valid global |
| 12967 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12968 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12969 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12970 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12971 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12972 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12973 | QDF_STATUS status; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12974 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12975 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12976 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12977 | hdd_err("Failed to allocate CDS context"); |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 12978 | return -ENOMEM; |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12979 | } |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 12980 | |
Dustin Brown | 265e82b | 2019-03-18 11:07:32 -0700 | [diff] [blame] | 12981 | 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] | 12982 | |
| 12983 | wlan_init_bug_report_lock(); |
| 12984 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12985 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12986 | wlan_logging_sock_init_svc(); |
| 12987 | #endif |
| 12988 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12989 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 12990 | hdd_register_debug_callback(); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12991 | wlan_roam_debug_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12992 | |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 12993 | return 0; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12994 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12995 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12996 | /** |
| 12997 | * hdd_deinit() - Deinitialize Driver |
| 12998 | * |
| 12999 | * This function frees CDS global context with the help of cds_deinit. This |
| 13000 | * has to be the last function call in remove callback to free the global |
| 13001 | * context. |
| 13002 | */ |
| 13003 | void hdd_deinit(void) |
| 13004 | { |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 13005 | wlan_roam_debug_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13006 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13007 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 13008 | wlan_logging_sock_deinit_svc(); |
| 13009 | #endif |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 13010 | |
| 13011 | wlan_destroy_bug_report_lock(); |
Dustin Brown | 265e82b | 2019-03-18 11:07:32 -0700 | [diff] [blame] | 13012 | qdf_op_callbacks_register(NULL, NULL); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 13013 | cds_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13014 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13015 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 13016 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 13017 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 13018 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13019 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 13020 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13021 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13022 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 13023 | struct file *file) |
| 13024 | { |
| 13025 | return 0; |
| 13026 | } |
| 13027 | |
| 13028 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 13029 | const char __user *user_buf, |
| 13030 | size_t count, |
| 13031 | loff_t *f_pos) |
| 13032 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 13033 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13034 | static const char wlan_off_str[] = "OFF"; |
| 13035 | static const char wlan_on_str[] = "ON"; |
| 13036 | int ret; |
| 13037 | unsigned long rc; |
| 13038 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 13039 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13040 | pr_err("Failed to read buffer\n"); |
| 13041 | return -EINVAL; |
| 13042 | } |
| 13043 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 13044 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13045 | pr_debug("Wifi turning off from UI\n"); |
| 13046 | goto exit; |
| 13047 | } |
| 13048 | |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 13049 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13050 | pr_info("Wifi Turning On from UI\n"); |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13051 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 13052 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13053 | pr_err("Invalid value received from framework"); |
| 13054 | goto exit; |
| 13055 | } |
| 13056 | |
| 13057 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 13058 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13059 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 13060 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 13061 | if (!rc) { |
Srinivas Girigowda | 09625b0 | 2018-09-10 15:28:09 -0700 | [diff] [blame] | 13062 | hdd_alert("Timed-out!!"); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13063 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13064 | return ret; |
| 13065 | } |
| 13066 | |
| 13067 | hdd_start_complete(0); |
| 13068 | } |
| 13069 | |
| 13070 | exit: |
| 13071 | return count; |
| 13072 | } |
| 13073 | |
| 13074 | |
| 13075 | const struct file_operations wlan_hdd_state_fops = { |
| 13076 | .owner = THIS_MODULE, |
| 13077 | .open = wlan_hdd_state_ctrl_param_open, |
| 13078 | .write = wlan_hdd_state_ctrl_param_write, |
| 13079 | }; |
| 13080 | |
| 13081 | static int wlan_hdd_state_ctrl_param_create(void) |
| 13082 | { |
| 13083 | unsigned int wlan_hdd_state_major = 0; |
| 13084 | int ret; |
| 13085 | struct device *dev; |
| 13086 | |
| 13087 | device = MKDEV(wlan_hdd_state_major, 0); |
| 13088 | |
| 13089 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 13090 | if (ret) { |
| 13091 | pr_err("Failed to register qcwlanstate"); |
| 13092 | goto dev_alloc_err; |
| 13093 | } |
| 13094 | wlan_hdd_state_major = MAJOR(device); |
| 13095 | |
| 13096 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 13097 | if (IS_ERR(class)) { |
| 13098 | pr_err("wlan_hdd_state class_create error"); |
| 13099 | goto class_err; |
| 13100 | } |
| 13101 | |
| 13102 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 13103 | if (IS_ERR(dev)) { |
| 13104 | pr_err("wlan_hdd_statedevice_create error"); |
| 13105 | goto err_class_destroy; |
| 13106 | } |
| 13107 | |
| 13108 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 13109 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 13110 | if (ret) { |
| 13111 | pr_err("Failed to add cdev error"); |
| 13112 | goto cdev_add_err; |
| 13113 | } |
| 13114 | |
| 13115 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 13116 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 13117 | |
| 13118 | return 0; |
| 13119 | |
| 13120 | cdev_add_err: |
| 13121 | device_destroy(class, device); |
| 13122 | err_class_destroy: |
| 13123 | class_destroy(class); |
| 13124 | class_err: |
| 13125 | unregister_chrdev_region(device, dev_num); |
| 13126 | dev_alloc_err: |
| 13127 | return -ENODEV; |
| 13128 | } |
| 13129 | |
| 13130 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 13131 | { |
| 13132 | cdev_del(&wlan_hdd_state_cdev); |
| 13133 | device_destroy(class, device); |
| 13134 | class_destroy(class); |
| 13135 | unregister_chrdev_region(device, dev_num); |
| 13136 | |
| 13137 | pr_info("Device node unregistered"); |
| 13138 | } |
| 13139 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13140 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13141 | * hdd_component_init() - Initialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13142 | * |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13143 | * Return: QDF_STATUS |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13144 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13145 | static QDF_STATUS hdd_component_init(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13146 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13147 | QDF_STATUS status; |
| 13148 | |
| 13149 | /* initialize converged components */ |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13150 | status = target_if_init(wma_get_psoc_from_scn_handle); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13151 | if (QDF_IS_STATUS_ERROR(status)) |
| 13152 | return status; |
| 13153 | |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13154 | status = ucfg_mlme_global_init(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13155 | if (QDF_IS_STATUS_ERROR(status)) |
| 13156 | goto target_if_deinit; |
| 13157 | |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13158 | status = dispatcher_init(); |
| 13159 | if (QDF_IS_STATUS_ERROR(status)) |
| 13160 | goto mlme_global_deinit; |
| 13161 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13162 | /* initialize non-converged components */ |
| 13163 | status = ucfg_mlme_init(); |
| 13164 | if (QDF_IS_STATUS_ERROR(status)) |
| 13165 | goto dispatcher_deinit; |
| 13166 | |
| 13167 | status = ucfg_fwol_init(); |
| 13168 | if (QDF_IS_STATUS_ERROR(status)) |
| 13169 | goto mlme_deinit; |
| 13170 | |
| 13171 | status = disa_init(); |
| 13172 | if (QDF_IS_STATUS_ERROR(status)) |
| 13173 | goto fwol_deinit; |
| 13174 | |
| 13175 | status = pmo_init(); |
| 13176 | if (QDF_IS_STATUS_ERROR(status)) |
| 13177 | goto disa_deinit; |
| 13178 | |
| 13179 | status = ucfg_ocb_init(); |
| 13180 | if (QDF_IS_STATUS_ERROR(status)) |
| 13181 | goto pmo_deinit; |
| 13182 | |
| 13183 | status = ipa_init(); |
| 13184 | if (QDF_IS_STATUS_ERROR(status)) |
| 13185 | goto ocb_deinit; |
| 13186 | |
| 13187 | status = ucfg_action_oui_init(); |
| 13188 | if (QDF_IS_STATUS_ERROR(status)) |
| 13189 | goto ipa_deinit; |
| 13190 | |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13191 | status = nan_init(); |
| 13192 | if (QDF_IS_STATUS_ERROR(status)) |
| 13193 | goto action_oui_deinit; |
| 13194 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13195 | status = ucfg_p2p_init(); |
| 13196 | if (QDF_IS_STATUS_ERROR(status)) |
| 13197 | goto nan_deinit; |
| 13198 | |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame] | 13199 | status = ucfg_interop_issues_ap_init(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13200 | if (QDF_IS_STATUS_ERROR(status)) |
| 13201 | goto p2p_deinit; |
| 13202 | |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame] | 13203 | status = policy_mgr_init(); |
| 13204 | if (QDF_IS_STATUS_ERROR(status)) |
| 13205 | goto interop_issues_ap_deinit; |
| 13206 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13207 | status = ucfg_tdls_init(); |
| 13208 | if (QDF_IS_STATUS_ERROR(status)) |
| 13209 | goto policy_deinit; |
| 13210 | |
gaurank kathpalia | 3ebc17b | 2019-05-29 10:25:09 +0530 | [diff] [blame] | 13211 | status = ucfg_blm_init(); |
| 13212 | if (QDF_IS_STATUS_ERROR(status)) |
| 13213 | goto tdls_deinit; |
| 13214 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13215 | return QDF_STATUS_SUCCESS; |
| 13216 | |
gaurank kathpalia | 3ebc17b | 2019-05-29 10:25:09 +0530 | [diff] [blame] | 13217 | tdls_deinit: |
| 13218 | ucfg_tdls_deinit(); |
| 13219 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13220 | policy_deinit: |
| 13221 | policy_mgr_deinit(); |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame] | 13222 | interop_issues_ap_deinit: |
| 13223 | ucfg_interop_issues_ap_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13224 | p2p_deinit: |
| 13225 | ucfg_p2p_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13226 | nan_deinit: |
| 13227 | nan_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13228 | action_oui_deinit: |
| 13229 | ucfg_action_oui_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13230 | ipa_deinit: |
| 13231 | ipa_deinit(); |
| 13232 | ocb_deinit: |
| 13233 | ucfg_ocb_deinit(); |
| 13234 | pmo_deinit: |
| 13235 | pmo_deinit(); |
| 13236 | disa_deinit: |
| 13237 | disa_deinit(); |
| 13238 | fwol_deinit: |
| 13239 | ucfg_fwol_deinit(); |
| 13240 | mlme_deinit: |
| 13241 | ucfg_mlme_deinit(); |
| 13242 | dispatcher_deinit: |
| 13243 | dispatcher_deinit(); |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13244 | mlme_global_deinit: |
| 13245 | ucfg_mlme_global_deinit(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13246 | target_if_deinit: |
| 13247 | target_if_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13248 | |
| 13249 | return status; |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13250 | } |
| 13251 | |
| 13252 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13253 | * hdd_component_deinit() - Deinitialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13254 | * |
| 13255 | * Return: None |
| 13256 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13257 | static void hdd_component_deinit(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13258 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13259 | /* deinitialize non-converged components */ |
gaurank kathpalia | 3ebc17b | 2019-05-29 10:25:09 +0530 | [diff] [blame] | 13260 | ucfg_blm_deinit(); |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13261 | ucfg_tdls_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13262 | policy_mgr_deinit(); |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame] | 13263 | ucfg_interop_issues_ap_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13264 | ucfg_p2p_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13265 | nan_deinit(); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 13266 | ucfg_action_oui_deinit(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 13267 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13268 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13269 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13270 | disa_deinit(); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13271 | ucfg_fwol_deinit(); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13272 | ucfg_mlme_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13273 | |
| 13274 | /* deinitialize converged components */ |
| 13275 | dispatcher_deinit(); |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13276 | ucfg_mlme_global_deinit(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13277 | target_if_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13278 | } |
| 13279 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13280 | QDF_STATUS hdd_component_psoc_open(struct wlan_objmgr_psoc *psoc) |
| 13281 | { |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13282 | QDF_STATUS status; |
| 13283 | |
| 13284 | status = ucfg_mlme_psoc_open(psoc); |
| 13285 | if (QDF_IS_STATUS_ERROR(status)) |
| 13286 | return status; |
| 13287 | |
gaurank kathpalia | 3ebc17b | 2019-05-29 10:25:09 +0530 | [diff] [blame] | 13288 | status = ucfg_blm_psoc_open(psoc); |
| 13289 | if (QDF_IS_STATUS_ERROR(status)) |
| 13290 | goto err_blm; |
| 13291 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13292 | status = ucfg_fwol_psoc_open(psoc); |
| 13293 | if (QDF_IS_STATUS_ERROR(status)) |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13294 | goto err_fwol; |
| 13295 | |
| 13296 | status = ucfg_pmo_psoc_open(psoc); |
| 13297 | if (QDF_IS_STATUS_ERROR(status)) |
| 13298 | goto err_pmo; |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13299 | |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13300 | status = ucfg_policy_mgr_psoc_open(psoc); |
| 13301 | if (QDF_IS_STATUS_ERROR(status)) |
| 13302 | goto err_plcy_mgr; |
| 13303 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13304 | status = ucfg_p2p_psoc_open(psoc); |
| 13305 | if (QDF_IS_STATUS_ERROR(status)) |
| 13306 | goto err_p2p; |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13307 | |
| 13308 | status = ucfg_tdls_psoc_open(psoc); |
| 13309 | if (QDF_IS_STATUS_ERROR(status)) |
| 13310 | goto err_tdls; |
| 13311 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13312 | return status; |
| 13313 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13314 | err_tdls: |
| 13315 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13316 | err_p2p: |
| 13317 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13318 | err_plcy_mgr: |
| 13319 | ucfg_pmo_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13320 | err_pmo: |
| 13321 | ucfg_fwol_psoc_close(psoc); |
| 13322 | err_fwol: |
gaurank kathpalia | 3ebc17b | 2019-05-29 10:25:09 +0530 | [diff] [blame] | 13323 | ucfg_blm_psoc_close(psoc); |
| 13324 | err_blm: |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13325 | ucfg_mlme_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13326 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13327 | return status; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13328 | } |
| 13329 | |
| 13330 | void hdd_component_psoc_close(struct wlan_objmgr_psoc *psoc) |
| 13331 | { |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13332 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13333 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13334 | ucfg_policy_mgr_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13335 | ucfg_pmo_psoc_close(psoc); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13336 | ucfg_fwol_psoc_close(psoc); |
gaurank kathpalia | 3ebc17b | 2019-05-29 10:25:09 +0530 | [diff] [blame] | 13337 | ucfg_blm_psoc_close(psoc); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13338 | ucfg_mlme_psoc_close(psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13339 | } |
| 13340 | |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13341 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 13342 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13343 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13344 | disa_psoc_enable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13345 | nan_psoc_enable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13346 | p2p_psoc_enable(psoc); |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame] | 13347 | ucfg_interop_issues_ap_psoc_enable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13348 | policy_mgr_psoc_enable(psoc); |
Wu Gao | a67c380 | 2018-12-27 12:07:52 +0800 | [diff] [blame] | 13349 | ucfg_tdls_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13350 | } |
| 13351 | |
| 13352 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 13353 | { |
Wu Gao | a67c380 | 2018-12-27 12:07:52 +0800 | [diff] [blame] | 13354 | ucfg_tdls_psoc_disable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13355 | policy_mgr_psoc_disable(psoc); |
Paul Zhang | 3718567 | 2019-05-14 11:20:14 +0800 | [diff] [blame] | 13356 | ucfg_interop_issues_ap_psoc_disable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13357 | p2p_psoc_disable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13358 | nan_psoc_disable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13359 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13360 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13361 | } |
| 13362 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 13363 | QDF_STATUS hdd_component_pdev_open(struct wlan_objmgr_pdev *pdev) |
| 13364 | { |
| 13365 | return ucfg_mlme_pdev_open(pdev); |
| 13366 | } |
| 13367 | |
| 13368 | void hdd_component_pdev_close(struct wlan_objmgr_pdev *pdev) |
| 13369 | { |
| 13370 | ucfg_mlme_pdev_close(pdev); |
| 13371 | } |
| 13372 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13373 | static QDF_STATUS hdd_qdf_print_init(void) |
| 13374 | { |
| 13375 | QDF_STATUS status; |
| 13376 | int qdf_print_idx; |
| 13377 | |
| 13378 | status = qdf_print_setup(); |
| 13379 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13380 | pr_err("Failed qdf_print_setup; status:%u\n", status); |
| 13381 | return status; |
| 13382 | } |
| 13383 | |
| 13384 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 13385 | if (qdf_print_idx < 0) { |
| 13386 | pr_err("Failed to register for qdf_print_ctrl\n"); |
| 13387 | return QDF_STATUS_E_FAILURE; |
| 13388 | } |
| 13389 | |
| 13390 | qdf_set_pidx(qdf_print_idx); |
| 13391 | |
| 13392 | return QDF_STATUS_SUCCESS; |
| 13393 | } |
| 13394 | |
| 13395 | static void hdd_qdf_print_deinit(void) |
| 13396 | { |
| 13397 | int qdf_pidx = qdf_get_pidx(); |
| 13398 | |
| 13399 | qdf_set_pidx(-1); |
| 13400 | qdf_print_ctrl_cleanup(qdf_pidx); |
| 13401 | |
| 13402 | /* currently, no qdf print 'un-setup'*/ |
| 13403 | } |
| 13404 | |
| 13405 | static QDF_STATUS hdd_qdf_init(void) |
| 13406 | { |
| 13407 | QDF_STATUS status; |
| 13408 | |
| 13409 | status = hdd_qdf_print_init(); |
| 13410 | if (QDF_IS_STATUS_ERROR(status)) |
| 13411 | goto exit; |
| 13412 | |
| 13413 | status = qdf_debugfs_init(); |
| 13414 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13415 | hdd_err("Failed to init debugfs; status:%u", status); |
| 13416 | goto print_deinit; |
| 13417 | } |
| 13418 | |
| 13419 | qdf_lock_stats_init(); |
| 13420 | qdf_mem_init(); |
Dustin Brown | c279631 | 2019-03-13 16:43:36 -0700 | [diff] [blame] | 13421 | qdf_delayed_work_feature_init(); |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 13422 | qdf_periodic_work_feature_init(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13423 | qdf_mc_timer_manager_init(); |
| 13424 | qdf_event_list_init(); |
| 13425 | |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13426 | status = qdf_talloc_feature_init(); |
| 13427 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13428 | hdd_err("Failed to init talloc; status:%u", status); |
| 13429 | goto event_deinit; |
| 13430 | } |
| 13431 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13432 | status = qdf_cpuhp_init(); |
| 13433 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13434 | hdd_err("Failed to init cpuhp; status:%u", status); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13435 | goto talloc_deinit; |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13436 | } |
| 13437 | |
| 13438 | status = qdf_trace_spin_lock_init(); |
| 13439 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13440 | hdd_err("Failed to init spinlock; status:%u", status); |
| 13441 | goto cpuhp_deinit; |
| 13442 | } |
| 13443 | |
| 13444 | qdf_trace_init(); |
| 13445 | qdf_register_debugcb_init(); |
| 13446 | |
| 13447 | return QDF_STATUS_SUCCESS; |
| 13448 | |
| 13449 | cpuhp_deinit: |
| 13450 | qdf_cpuhp_deinit(); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13451 | talloc_deinit: |
| 13452 | qdf_talloc_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13453 | event_deinit: |
| 13454 | qdf_event_list_destroy(); |
| 13455 | qdf_mc_timer_manager_exit(); |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 13456 | qdf_periodic_work_feature_deinit(); |
Dustin Brown | c279631 | 2019-03-13 16:43:36 -0700 | [diff] [blame] | 13457 | qdf_delayed_work_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13458 | qdf_mem_exit(); |
| 13459 | qdf_lock_stats_deinit(); |
| 13460 | qdf_debugfs_exit(); |
| 13461 | print_deinit: |
| 13462 | hdd_qdf_print_deinit(); |
| 13463 | |
| 13464 | exit: |
| 13465 | return status; |
| 13466 | } |
| 13467 | |
| 13468 | static void hdd_qdf_deinit(void) |
| 13469 | { |
| 13470 | /* currently, no debugcb deinit */ |
| 13471 | |
| 13472 | qdf_trace_deinit(); |
| 13473 | |
| 13474 | /* currently, no trace spinlock deinit */ |
| 13475 | |
| 13476 | qdf_cpuhp_deinit(); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13477 | qdf_talloc_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13478 | qdf_event_list_destroy(); |
| 13479 | qdf_mc_timer_manager_exit(); |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 13480 | qdf_periodic_work_feature_deinit(); |
Dustin Brown | c279631 | 2019-03-13 16:43:36 -0700 | [diff] [blame] | 13481 | qdf_delayed_work_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13482 | qdf_mem_exit(); |
| 13483 | qdf_lock_stats_deinit(); |
| 13484 | qdf_debugfs_exit(); |
| 13485 | hdd_qdf_print_deinit(); |
| 13486 | } |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13487 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13488 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
| 13489 | static bool is_monitor_mode_supported(void) |
| 13490 | { |
| 13491 | return true; |
| 13492 | } |
| 13493 | #else |
| 13494 | static bool is_monitor_mode_supported(void) |
| 13495 | { |
| 13496 | pr_err("Monitor mode not supported!"); |
| 13497 | return false; |
| 13498 | } |
| 13499 | #endif |
| 13500 | |
| 13501 | #ifdef WLAN_FEATURE_EPPING |
| 13502 | static bool is_epping_mode_supported(void) |
| 13503 | { |
| 13504 | return true; |
| 13505 | } |
| 13506 | #else |
| 13507 | static bool is_epping_mode_supported(void) |
| 13508 | { |
| 13509 | pr_err("Epping mode not supported!"); |
| 13510 | return false; |
| 13511 | } |
| 13512 | #endif |
| 13513 | |
| 13514 | #ifdef QCA_WIFI_FTM |
| 13515 | static bool is_ftm_mode_supported(void) |
| 13516 | { |
| 13517 | return true; |
| 13518 | } |
| 13519 | #else |
| 13520 | static bool is_ftm_mode_supported(void) |
| 13521 | { |
| 13522 | pr_err("FTM mode not supported!"); |
| 13523 | return false; |
| 13524 | } |
| 13525 | #endif |
| 13526 | |
| 13527 | /** |
| 13528 | * is_con_mode_valid() check con mode is valid or not |
| 13529 | * @mode: global con mode |
| 13530 | * |
| 13531 | * Return: TRUE on success FALSE on failure |
| 13532 | */ |
| 13533 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
| 13534 | { |
| 13535 | switch (mode) { |
| 13536 | case QDF_GLOBAL_MONITOR_MODE: |
| 13537 | return is_monitor_mode_supported(); |
| 13538 | case QDF_GLOBAL_EPPING_MODE: |
| 13539 | return is_epping_mode_supported(); |
| 13540 | case QDF_GLOBAL_FTM_MODE: |
| 13541 | return is_ftm_mode_supported(); |
| 13542 | case QDF_GLOBAL_MISSION_MODE: |
| 13543 | return true; |
| 13544 | default: |
| 13545 | return false; |
| 13546 | } |
| 13547 | } |
| 13548 | |
| 13549 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
| 13550 | enum QDF_GLOBAL_MODE curr_mode) |
| 13551 | { |
| 13552 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 13553 | return; |
| 13554 | |
| 13555 | switch (curr_mode) { |
| 13556 | case QDF_GLOBAL_MONITOR_MODE: |
| 13557 | hdd_info("Release wakelock for monitor mode!"); |
| 13558 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 13559 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 13560 | /* fallthrough */ |
| 13561 | case QDF_GLOBAL_MISSION_MODE: |
| 13562 | case QDF_GLOBAL_FTM_MODE: |
| 13563 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 13564 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
| 13565 | hdd_stop_all_adapters(hdd_ctx); |
| 13566 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 13567 | |
| 13568 | break; |
| 13569 | default: |
| 13570 | break; |
| 13571 | } |
| 13572 | } |
| 13573 | |
| 13574 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
| 13575 | enum QDF_GLOBAL_MODE curr_mode) |
| 13576 | { |
| 13577 | int driver_status; |
| 13578 | |
| 13579 | driver_status = hdd_ctx->driver_status; |
| 13580 | |
| 13581 | switch (curr_mode) { |
| 13582 | case QDF_GLOBAL_MISSION_MODE: |
| 13583 | case QDF_GLOBAL_MONITOR_MODE: |
| 13584 | case QDF_GLOBAL_FTM_MODE: |
| 13585 | hdd_close_all_adapters(hdd_ctx, false); |
| 13586 | break; |
| 13587 | case QDF_GLOBAL_EPPING_MODE: |
| 13588 | epping_disable(); |
| 13589 | epping_close(); |
| 13590 | break; |
| 13591 | default: |
| 13592 | return; |
| 13593 | } |
| 13594 | } |
| 13595 | |
| 13596 | static int |
| 13597 | hdd_parse_driver_mode(const char *mode_str, enum QDF_GLOBAL_MODE *out_mode) |
| 13598 | { |
| 13599 | QDF_STATUS status; |
| 13600 | uint32_t mode; |
| 13601 | |
| 13602 | *out_mode = QDF_GLOBAL_MAX_MODE; |
| 13603 | |
| 13604 | status = qdf_uint32_parse(mode_str, &mode); |
| 13605 | if (QDF_IS_STATUS_ERROR(status)) |
| 13606 | return qdf_status_to_os_return(status); |
| 13607 | |
| 13608 | if (mode >= QDF_GLOBAL_MAX_MODE) |
| 13609 | return -ERANGE; |
| 13610 | |
| 13611 | *out_mode = (enum QDF_GLOBAL_MODE)mode; |
| 13612 | |
| 13613 | return 0; |
| 13614 | } |
| 13615 | |
Rajeev Kumar | 588a254 | 2019-04-08 10:57:19 -0700 | [diff] [blame] | 13616 | static int hdd_mode_change_psoc_idle_shutdown(struct device *dev) |
| 13617 | { |
| 13618 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13619 | |
| 13620 | return hdd_wlan_stop_modules(hdd_ctx, true); |
| 13621 | } |
| 13622 | |
| 13623 | static int hdd_mode_change_psoc_idle_restart(struct device *dev) |
| 13624 | { |
| 13625 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13626 | |
| 13627 | return hdd_wlan_start_modules(hdd_ctx, false); |
| 13628 | } |
| 13629 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13630 | /** |
| 13631 | * __hdd_driver_mode_change() - Handles a driver mode change |
| 13632 | * @hdd_ctx: Pointer to the global HDD context |
| 13633 | * @next_mode: the driver mode to transition to |
| 13634 | * |
| 13635 | * This function is invoked when user updates con_mode using sys entry, |
| 13636 | * to initialize and bring-up driver in that specific mode. |
| 13637 | * |
| 13638 | * Return: Errno |
| 13639 | */ |
| 13640 | static int __hdd_driver_mode_change(struct hdd_context *hdd_ctx, |
| 13641 | enum QDF_GLOBAL_MODE next_mode) |
| 13642 | { |
| 13643 | enum QDF_GLOBAL_MODE curr_mode; |
| 13644 | int errno; |
| 13645 | |
| 13646 | hdd_info("Driver mode changing to %d", next_mode); |
| 13647 | |
| 13648 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13649 | if (errno) |
| 13650 | return errno; |
| 13651 | |
| 13652 | if (!is_con_mode_valid(next_mode)) { |
| 13653 | hdd_err_rl("Requested driver mode is invalid"); |
| 13654 | return -EINVAL; |
| 13655 | } |
| 13656 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13657 | curr_mode = hdd_get_conparam(); |
| 13658 | if (curr_mode == next_mode) { |
| 13659 | hdd_err_rl("Driver is already in the requested mode"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13660 | return 0; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13661 | } |
| 13662 | |
| 13663 | /* ensure adapters are stopped */ |
| 13664 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 13665 | |
Rajeev Kumar | 588a254 | 2019-04-08 10:57:19 -0700 | [diff] [blame] | 13666 | is_mode_change_psoc_idle_shutdown = true; |
| 13667 | errno = pld_idle_shutdown(hdd_ctx->parent_dev, |
| 13668 | hdd_mode_change_psoc_idle_shutdown); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13669 | if (errno) { |
Rajeev Kumar | 588a254 | 2019-04-08 10:57:19 -0700 | [diff] [blame] | 13670 | is_mode_change_psoc_idle_shutdown = false; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13671 | hdd_err("Stop wlan modules failed"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13672 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13673 | } |
| 13674 | |
| 13675 | /* Cleanup present mode before switching to new mode */ |
| 13676 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 13677 | |
| 13678 | hdd_set_conparam(next_mode); |
| 13679 | |
Rajeev Kumar | 588a254 | 2019-04-08 10:57:19 -0700 | [diff] [blame] | 13680 | errno = pld_idle_restart(hdd_ctx->parent_dev, |
| 13681 | hdd_mode_change_psoc_idle_restart); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13682 | if (errno) { |
| 13683 | hdd_err("Start wlan modules failed: %d", errno); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13684 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13685 | } |
| 13686 | |
| 13687 | errno = hdd_open_adapters_for_mode(hdd_ctx, next_mode); |
| 13688 | if (errno) { |
| 13689 | hdd_err("Failed to open adapters"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13690 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13691 | } |
| 13692 | |
| 13693 | if (next_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 13694 | struct hdd_adapter *adapter = |
| 13695 | hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE); |
| 13696 | |
| 13697 | QDF_BUG(adapter); |
| 13698 | if (!adapter) { |
| 13699 | hdd_err("Failed to get monitor adapter"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13700 | return -EINVAL; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13701 | } |
| 13702 | |
| 13703 | errno = hdd_start_adapter(adapter); |
| 13704 | if (errno) { |
| 13705 | hdd_err("Failed to start monitor adapter"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13706 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13707 | } |
| 13708 | |
| 13709 | hdd_info("Acquire wakelock for monitor mode"); |
| 13710 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 13711 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 13712 | } |
| 13713 | |
| 13714 | /* con_mode is a global module parameter */ |
| 13715 | con_mode = next_mode; |
| 13716 | hdd_info("Driver mode successfully changed to %d", next_mode); |
| 13717 | |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13718 | return 0; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13719 | } |
| 13720 | |
| 13721 | static int hdd_driver_mode_change(enum QDF_GLOBAL_MODE mode) |
| 13722 | { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13723 | struct osif_driver_sync *driver_sync; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13724 | struct hdd_context *hdd_ctx; |
| 13725 | QDF_STATUS status; |
| 13726 | int errno; |
| 13727 | |
| 13728 | hdd_enter(); |
| 13729 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13730 | status = osif_driver_sync_trans_start_wait(&driver_sync); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13731 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13732 | hdd_err("Failed to start 'mode change'; status:%u", status); |
| 13733 | errno = qdf_status_to_os_return(status); |
| 13734 | goto exit; |
| 13735 | } |
| 13736 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13737 | osif_driver_sync_wait_for_ops(driver_sync); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13738 | |
| 13739 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13740 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13741 | if (errno) |
| 13742 | goto trans_stop; |
| 13743 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13744 | errno = __hdd_driver_mode_change(hdd_ctx, mode); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13745 | |
| 13746 | trans_stop: |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13747 | osif_driver_sync_trans_stop(driver_sync); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13748 | |
| 13749 | exit: |
| 13750 | hdd_exit(); |
| 13751 | |
| 13752 | return errno; |
| 13753 | } |
| 13754 | |
| 13755 | static int hdd_set_con_mode(enum QDF_GLOBAL_MODE mode) |
| 13756 | { |
| 13757 | con_mode = mode; |
| 13758 | |
| 13759 | return 0; |
| 13760 | } |
| 13761 | |
| 13762 | static int (*hdd_set_con_mode_cb)(enum QDF_GLOBAL_MODE mode) = hdd_set_con_mode; |
| 13763 | |
| 13764 | static void hdd_driver_mode_change_register(void) |
| 13765 | { |
| 13766 | hdd_set_con_mode_cb = hdd_driver_mode_change; |
| 13767 | } |
| 13768 | |
| 13769 | static void hdd_driver_mode_change_unregister(void) |
| 13770 | { |
| 13771 | hdd_set_con_mode_cb = hdd_set_con_mode; |
| 13772 | } |
| 13773 | |
| 13774 | static int con_mode_handler(const char *kmessage, const struct kernel_param *kp) |
| 13775 | { |
| 13776 | enum QDF_GLOBAL_MODE mode; |
| 13777 | int errno; |
| 13778 | |
| 13779 | errno = hdd_parse_driver_mode(kmessage, &mode); |
| 13780 | if (errno) { |
| 13781 | hdd_err_rl("Failed to parse driver mode '%s'", kmessage); |
| 13782 | return errno; |
| 13783 | } |
| 13784 | |
| 13785 | return hdd_set_con_mode_cb(mode); |
| 13786 | } |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13787 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13788 | /** |
| 13789 | * hdd_driver_load() - Perform the driver-level load operation |
| 13790 | * |
| 13791 | * Note: this is used in both static and DLKM driver builds |
| 13792 | * |
| 13793 | * Return: Errno |
| 13794 | */ |
| 13795 | static int hdd_driver_load(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13796 | { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13797 | struct osif_driver_sync *driver_sync; |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13798 | QDF_STATUS status; |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13799 | int errno; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13800 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13801 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 13802 | g_wlan_driver_version); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13803 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13804 | status = hdd_qdf_init(); |
| 13805 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13806 | errno = qdf_status_to_os_return(status); |
| 13807 | goto exit; |
| 13808 | } |
| 13809 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13810 | osif_sync_init(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13811 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13812 | status = osif_driver_sync_create_and_trans(&driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13813 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13814 | hdd_err("Failed to init driver sync; status:%u", status); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13815 | errno = qdf_status_to_os_return(status); |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13816 | goto sync_deinit; |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13817 | } |
| 13818 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13819 | errno = hdd_init(); |
| 13820 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13821 | hdd_err("Failed to init HDD; errno:%d", errno); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13822 | goto trans_stop; |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13823 | } |
| 13824 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13825 | status = hdd_component_init(); |
| 13826 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13827 | hdd_err("Failed to init components; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13828 | errno = qdf_status_to_os_return(status); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13829 | goto hdd_deinit; |
| 13830 | } |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13831 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13832 | status = qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
| 13833 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13834 | hdd_err("Failed to create wake lock; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13835 | errno = qdf_status_to_os_return(status); |
| 13836 | goto comp_deinit; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13837 | } |
| 13838 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13839 | hdd_set_conparam(con_mode); |
| 13840 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13841 | errno = wlan_hdd_state_ctrl_param_create(); |
| 13842 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13843 | hdd_err("Failed to create ctrl param; errno:%d", errno); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13844 | goto wakelock_destroy; |
| 13845 | } |
| 13846 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13847 | errno = pld_init(); |
| 13848 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13849 | hdd_err("Failed to init PLD; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13850 | goto param_destroy; |
| 13851 | } |
| 13852 | |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13853 | hdd_driver_mode_change_register(); |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13854 | |
| 13855 | osif_driver_sync_register(driver_sync); |
| 13856 | osif_driver_sync_trans_stop(driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13857 | |
| 13858 | /* psoc probe can happen in registration; do after 'load' transition */ |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13859 | errno = wlan_hdd_register_driver(); |
| 13860 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13861 | hdd_err("Failed to register driver; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13862 | goto pld_deinit; |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13863 | } |
| 13864 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13865 | hdd_debug("%s: driver loaded", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13866 | |
| 13867 | return 0; |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13868 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13869 | pld_deinit: |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13870 | status = osif_driver_sync_trans_start(&driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13871 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13872 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13873 | osif_driver_sync_unregister(); |
| 13874 | osif_driver_sync_wait_for_ops(driver_sync); |
| 13875 | |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13876 | hdd_driver_mode_change_unregister(); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13877 | pld_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13878 | |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13879 | param_destroy: |
| 13880 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13881 | wakelock_destroy: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13882 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13883 | comp_deinit: |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13884 | hdd_component_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13885 | hdd_deinit: |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13886 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13887 | trans_stop: |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13888 | osif_driver_sync_trans_stop(driver_sync); |
| 13889 | osif_driver_sync_destroy(driver_sync); |
| 13890 | sync_deinit: |
| 13891 | osif_sync_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13892 | hdd_qdf_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13893 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13894 | exit: |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13895 | return errno; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13896 | } |
| 13897 | |
| 13898 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13899 | * hdd_driver_unload() - Performs the driver-level unload operation |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13900 | * |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13901 | * Note: this is used in both static and DLKM driver builds |
| 13902 | * |
| 13903 | * Return: None |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13904 | */ |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13905 | static void hdd_driver_unload(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13906 | { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13907 | struct osif_driver_sync *driver_sync; |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 13908 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13909 | QDF_STATUS status; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 13910 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13911 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 13912 | QWLAN_VERSIONSTR); |
| 13913 | |
Dustin Brown | 8c0b5e3 | 2019-01-18 13:56:02 -0800 | [diff] [blame] | 13914 | if (hdd_ctx) |
| 13915 | hdd_psoc_idle_timer_stop(hdd_ctx); |
| 13916 | |
| 13917 | /* trigger SoC remove */ |
| 13918 | wlan_hdd_unregister_driver(); |
| 13919 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13920 | status = osif_driver_sync_trans_start_wait(&driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13921 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13922 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13923 | hdd_err("Unable to unload wlan; status:%u", status); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 13924 | return; |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13925 | } |
| 13926 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13927 | osif_driver_sync_unregister(); |
| 13928 | osif_driver_sync_wait_for_ops(driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13929 | |
Will Huang | ba035ec | 2018-07-05 11:13:30 +0800 | [diff] [blame] | 13930 | cds_set_driver_loaded(false); |
| 13931 | cds_set_unload_in_progress(true); |
| 13932 | |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13933 | hdd_driver_mode_change_unregister(); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13934 | pld_deinit(); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13935 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13936 | hdd_set_conparam(0); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13937 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13938 | hdd_component_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13939 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13940 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13941 | osif_driver_sync_trans_stop(driver_sync); |
| 13942 | osif_driver_sync_destroy(driver_sync); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 13943 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13944 | osif_sync_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13945 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13946 | hdd_qdf_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13947 | } |
| 13948 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13949 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13950 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13951 | * wlan_boot_cb() - Wlan boot callback |
| 13952 | * @kobj: object whose directory we're creating the link in. |
| 13953 | * @attr: attribute the user is interacting with |
| 13954 | * @buff: the buffer containing the user data |
| 13955 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13956 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13957 | * This callback is invoked when the fs is ready to start the |
| 13958 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13959 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13960 | * 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] | 13961 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13962 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13963 | struct kobj_attribute *attr, |
| 13964 | const char *buf, |
| 13965 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13966 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13967 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13968 | if (wlan_loader->loaded_state) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13969 | hdd_err("wlan driver already initialized"); |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13970 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13971 | } |
| 13972 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13973 | if (hdd_driver_load()) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13974 | return -EIO; |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13975 | |
| 13976 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13977 | |
| 13978 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13979 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13980 | |
| 13981 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13982 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 13983 | * |
| 13984 | * Return: None |
| 13985 | * |
| 13986 | */ |
| 13987 | static void hdd_sysfs_cleanup(void) |
| 13988 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13989 | /* remove from group */ |
| 13990 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 13991 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 13992 | wlan_loader->attr_group); |
| 13993 | |
| 13994 | /* unlink the object from parent */ |
| 13995 | kobject_del(wlan_loader->boot_wlan_obj); |
| 13996 | |
| 13997 | /* free the object */ |
| 13998 | kobject_put(wlan_loader->boot_wlan_obj); |
| 13999 | |
| 14000 | kfree(wlan_loader->attr_group); |
| 14001 | kfree(wlan_loader); |
| 14002 | |
| 14003 | wlan_loader = NULL; |
| 14004 | } |
| 14005 | |
| 14006 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14007 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 14008 | * ready |
| 14009 | * |
| 14010 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 14011 | * when the filesystem is ready. |
| 14012 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 14013 | * QDF API cannot be used here since this function is called even before |
| 14014 | * initializing WLAN driver. |
| 14015 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 14016 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14017 | */ |
| 14018 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14019 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 14020 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14021 | |
| 14022 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 14023 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 14024 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14025 | |
| 14026 | wlan_loader->boot_wlan_obj = NULL; |
| 14027 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 14028 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 14029 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14030 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14031 | |
| 14032 | wlan_loader->loaded_state = 0; |
| 14033 | wlan_loader->attr_group->attrs = attrs; |
| 14034 | |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 14035 | wlan_loader->boot_wlan_obj = kobject_create_and_add(WLAN_LOADER_NAME, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14036 | kernel_kobj); |
| 14037 | if (!wlan_loader->boot_wlan_obj) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 14038 | hdd_err("sysfs create and add failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14039 | goto error_return; |
| 14040 | } |
| 14041 | |
| 14042 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 14043 | wlan_loader->attr_group); |
| 14044 | if (ret) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 14045 | hdd_err("sysfs create group failed; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14046 | goto error_return; |
| 14047 | } |
| 14048 | |
| 14049 | return 0; |
| 14050 | |
| 14051 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 14052 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14053 | |
| 14054 | return ret; |
| 14055 | } |
| 14056 | |
| 14057 | /** |
| 14058 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 14059 | * |
| 14060 | * Return: 0 on success or errno on failure |
| 14061 | */ |
| 14062 | static int wlan_deinit_sysfs(void) |
| 14063 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14064 | if (!wlan_loader) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 14065 | hdd_err("wlan_loader is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14066 | return -EINVAL; |
| 14067 | } |
| 14068 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 14069 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14070 | return 0; |
| 14071 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14072 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 14073 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14074 | |
| 14075 | #ifdef MODULE |
| 14076 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14077 | * hdd_module_init() - Module init helper |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14078 | * |
| 14079 | * Module init helper function used by both module and static driver. |
| 14080 | * |
| 14081 | * Return: 0 for success, errno on failure |
| 14082 | */ |
| 14083 | static int hdd_module_init(void) |
| 14084 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14085 | if (hdd_driver_load()) |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 14086 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14087 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 14088 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14089 | } |
| 14090 | #else |
| 14091 | static int __init hdd_module_init(void) |
| 14092 | { |
| 14093 | int ret = -EINVAL; |
| 14094 | |
| 14095 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 14096 | if (ret) |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 14097 | hdd_err("Failed to create sysfs entry"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14098 | |
| 14099 | return ret; |
| 14100 | } |
| 14101 | #endif |
| 14102 | |
| 14103 | |
| 14104 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14105 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14106 | * hdd_module_exit() - Exit function |
| 14107 | * |
| 14108 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 14109 | * |
| 14110 | * Return: None |
| 14111 | */ |
| 14112 | static void __exit hdd_module_exit(void) |
| 14113 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14114 | hdd_driver_unload(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14115 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14116 | #else |
| 14117 | static void __exit hdd_module_exit(void) |
| 14118 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14119 | hdd_driver_unload(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14120 | wlan_deinit_sysfs(); |
| 14121 | } |
| 14122 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14123 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14124 | static int fwpath_changed_handler(const char *kmessage, |
| 14125 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14126 | { |
| 14127 | return param_set_copystring(kmessage, kp); |
| 14128 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 14129 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14130 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14131 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14132 | { |
| 14133 | int ret; |
| 14134 | |
| 14135 | ret = param_set_int(kmessage, kp); |
| 14136 | |
| 14137 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 14138 | pr_err("Only FTM mode supported!"); |
| 14139 | return -ENOTSUPP; |
| 14140 | } |
| 14141 | |
| 14142 | hdd_set_conparam(con_mode_ftm); |
| 14143 | con_mode = con_mode_ftm; |
| 14144 | |
| 14145 | return ret; |
| 14146 | } |
| 14147 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 14148 | #ifdef WLAN_FEATURE_EPPING |
| 14149 | static int con_mode_handler_epping(const char *kmessage, |
| 14150 | const struct kernel_param *kp) |
| 14151 | { |
| 14152 | int ret; |
| 14153 | |
| 14154 | ret = param_set_int(kmessage, kp); |
| 14155 | |
| 14156 | if (con_mode_epping != QDF_GLOBAL_EPPING_MODE) { |
| 14157 | pr_err("Only EPPING mode supported!"); |
| 14158 | return -ENOTSUPP; |
| 14159 | } |
| 14160 | |
| 14161 | hdd_set_conparam(con_mode_epping); |
| 14162 | con_mode = con_mode_epping; |
| 14163 | |
| 14164 | return ret; |
| 14165 | } |
| 14166 | #endif |
| 14167 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14168 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14169 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14170 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14171 | { |
| 14172 | int ret; |
| 14173 | |
| 14174 | ret = param_set_int(kmessage, kp); |
| 14175 | |
| 14176 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 14177 | pr_err("Only Monitor mode supported!"); |
| 14178 | return -ENOTSUPP; |
| 14179 | } |
| 14180 | |
| 14181 | hdd_set_conparam(con_mode_monitor); |
| 14182 | con_mode = con_mode_monitor; |
| 14183 | |
| 14184 | return ret; |
| 14185 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14186 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14187 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14188 | /** |
| 14189 | * hdd_get_conparam() - driver exit point |
| 14190 | * |
| 14191 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 14192 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14193 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14194 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14195 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14196 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14197 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14198 | } |
| 14199 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14200 | void hdd_set_conparam(int32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14201 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 14202 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14203 | } |
| 14204 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14205 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14206 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 14207 | * @hdd_ctx: HDD context |
| 14208 | * |
| 14209 | * Cleans up the pre cac interface, if it exists |
| 14210 | * |
| 14211 | * Return: None |
| 14212 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14213 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14214 | { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 14215 | uint8_t vdev_id; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14216 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 14217 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14218 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 14219 | 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] | 14220 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14221 | hdd_err("failed to get pre cac vdev id"); |
| 14222 | return; |
| 14223 | } |
| 14224 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 14225 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14226 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 14227 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14228 | return; |
| 14229 | } |
| 14230 | |
| 14231 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 14232 | wlan_hdd_sap_pre_cac_failure, |
| 14233 | (void *)precac_adapter); |
| 14234 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 14235 | |
| 14236 | } |
| 14237 | |
| 14238 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14239 | * hdd_update_ol_config - API to update ol configuration parameters |
| 14240 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14241 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14242 | * Return: void |
| 14243 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14244 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14245 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14246 | struct ol_config_info cfg = {0}; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14247 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14248 | bool self_recovery = false; |
| 14249 | QDF_STATUS status; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14250 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14251 | if (!ol_ctx) |
| 14252 | return; |
| 14253 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14254 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14255 | if (QDF_IS_STATUS_ERROR(status)) |
| 14256 | hdd_err("Failed to get self recovery ini config"); |
| 14257 | |
| 14258 | cfg.enable_self_recovery = self_recovery; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14259 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 14260 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 14261 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 14262 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14263 | |
| 14264 | ol_init_ini_config(ol_ctx, &cfg); |
| 14265 | } |
| 14266 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14267 | #ifdef FEATURE_RUNTIME_PM |
| 14268 | /** |
| 14269 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 14270 | * @hdd_ctx: hdd context |
| 14271 | * @cfg: pointer to the configuration memory being populated |
| 14272 | * |
| 14273 | * Return: void |
| 14274 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14275 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14276 | struct hif_config_info *cfg) |
| 14277 | { |
| 14278 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14279 | cfg->runtime_pm_delay = |
| 14280 | ucfg_pmo_get_runtime_pm_delay(hdd_ctx->psoc); |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14281 | } |
| 14282 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14283 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14284 | struct hif_config_info *cfg) |
| 14285 | { |
| 14286 | } |
| 14287 | #endif |
| 14288 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14289 | /** |
| 14290 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 14291 | * @hdd_ctx: HDD Context |
| 14292 | * |
| 14293 | * Return: void |
| 14294 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14295 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14296 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14297 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14298 | struct hif_config_info cfg = {0}; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14299 | bool prevent_link_down = false; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14300 | bool self_recovery = false; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14301 | QDF_STATUS status; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14302 | |
| 14303 | if (!scn) |
| 14304 | return; |
| 14305 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14306 | status = ucfg_mlme_get_prevent_link_down(hdd_ctx->psoc, |
| 14307 | &prevent_link_down); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14308 | if (QDF_IS_STATUS_ERROR(status)) |
| 14309 | hdd_err("Failed to get prevent_link_down config"); |
| 14310 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14311 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14312 | if (QDF_IS_STATUS_ERROR(status)) |
| 14313 | hdd_err("Failed to get self recovery ini config"); |
| 14314 | |
| 14315 | cfg.enable_self_recovery = self_recovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14316 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Mohit Khanna | a8c9f56 | 2019-03-25 22:17:02 -0700 | [diff] [blame] | 14317 | cfg.rx_softirq_max_yield_duration_ns = |
| 14318 | cfg_get(hdd_ctx->psoc, |
| 14319 | CFG_DP_RX_SOFTIRQ_MAX_YIELD_TIME_NS); |
| 14320 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14321 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14322 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14323 | if (prevent_link_down) |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14324 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14325 | } |
| 14326 | |
Mohit Khanna | a8c9f56 | 2019-03-25 22:17:02 -0700 | [diff] [blame] | 14327 | #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT |
| 14328 | /** |
| 14329 | * hdd_update_dp_config_rx_softirq_limits() - Update DP rx softirq limit config |
| 14330 | * datapath |
| 14331 | * @hdd_ctx: HDD Context |
| 14332 | * @params: pointer to cdp_config_params to be updated |
| 14333 | * |
| 14334 | * Void |
| 14335 | */ |
| 14336 | static |
| 14337 | void hdd_update_dp_config_rx_softirq_limits(struct hdd_context *hdd_ctx, |
| 14338 | struct cdp_config_params *params) |
| 14339 | { |
| 14340 | params->tx_comp_loop_pkt_limit = cfg_get(hdd_ctx->psoc, |
| 14341 | CFG_DP_TX_COMP_LOOP_PKT_LIMIT); |
| 14342 | params->rx_reap_loop_pkt_limit = cfg_get(hdd_ctx->psoc, |
| 14343 | CFG_DP_RX_REAP_LOOP_PKT_LIMIT); |
| 14344 | params->rx_hp_oos_update_limit = cfg_get(hdd_ctx->psoc, |
| 14345 | CFG_DP_RX_HP_OOS_UPDATE_LIMIT); |
| 14346 | } |
| 14347 | #else |
| 14348 | static |
| 14349 | void hdd_update_dp_config_rx_softirq_limits(struct hdd_context *hdd_ctx, |
| 14350 | struct cdp_config_params *params) |
| 14351 | { |
| 14352 | } |
| 14353 | #endif /* WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT */ |
| 14354 | |
hangtian | b9c9136 | 2019-06-07 10:39:38 +0800 | [diff] [blame] | 14355 | #if defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(QCA_LL_PDEV_TX_FLOW_CONTROL) |
| 14356 | static void |
| 14357 | hdd_update_dp_config_queue_threshold(struct hdd_context *hdd_ctx, |
| 14358 | struct cdp_config_params *params) |
| 14359 | { |
| 14360 | params->tx_flow_stop_queue_threshold = |
| 14361 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH); |
| 14362 | params->tx_flow_start_queue_offset = |
| 14363 | cfg_get(hdd_ctx->psoc, |
| 14364 | CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
| 14365 | } |
| 14366 | #else |
| 14367 | static inline void |
| 14368 | hdd_update_dp_config_queue_threshold(struct hdd_context *hdd_ctx, |
| 14369 | struct cdp_config_params *params) |
| 14370 | { |
| 14371 | } |
| 14372 | #endif |
| 14373 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14374 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14375 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 14376 | * datapath |
| 14377 | * @hdd_ctx: HDD Context |
| 14378 | * |
| 14379 | * Return: 0 for success/errno for failure |
| 14380 | */ |
| 14381 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 14382 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14383 | struct cdp_config_params params = {0}; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14384 | QDF_STATUS status; |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14385 | void *soc; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14386 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14387 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 14388 | params.tso_enable = cfg_get(hdd_ctx->psoc, CFG_DP_TSO); |
| 14389 | params.lro_enable = cfg_get(hdd_ctx->psoc, CFG_DP_LRO); |
hangtian | b9c9136 | 2019-06-07 10:39:38 +0800 | [diff] [blame] | 14390 | hdd_update_dp_config_queue_threshold(hdd_ctx, ¶ms); |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14391 | params.flow_steering_enable = |
| 14392 | cfg_get(hdd_ctx->psoc, CFG_DP_FLOW_STEERING_ENABLED); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14393 | params.napi_enable = hdd_ctx->napi_enable; |
| 14394 | params.tcp_udp_checksumoffload = |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14395 | cfg_get(hdd_ctx->psoc, |
| 14396 | CFG_DP_TCP_UDP_CKSUM_OFFLOAD); |
Sravan Kumar Kairam | 0af1ee5 | 2018-12-12 20:37:51 +0530 | [diff] [blame] | 14397 | params.ipa_enable = ucfg_ipa_is_enabled(); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 14398 | params.gro_enable = cfg_get(hdd_ctx->psoc, CFG_DP_GRO); |
Mohit Khanna | a8c9f56 | 2019-03-25 22:17:02 -0700 | [diff] [blame] | 14399 | params.tx_comp_loop_pkt_limit = cfg_get(hdd_ctx->psoc, |
| 14400 | CFG_DP_TX_COMP_LOOP_PKT_LIMIT); |
| 14401 | params.rx_reap_loop_pkt_limit = cfg_get(hdd_ctx->psoc, |
| 14402 | CFG_DP_RX_REAP_LOOP_PKT_LIMIT); |
| 14403 | params.rx_hp_oos_update_limit = cfg_get(hdd_ctx->psoc, |
| 14404 | CFG_DP_RX_HP_OOS_UPDATE_LIMIT); |
| 14405 | hdd_update_dp_config_rx_softirq_limits(hdd_ctx, ¶ms); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14406 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14407 | status = cdp_update_config_parameters(soc, ¶ms); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14408 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 14409 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14410 | return status; |
| 14411 | } |
| 14412 | |
| 14413 | return 0; |
| 14414 | } |
| 14415 | |
| 14416 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14417 | * hdd_update_config() - Initialize driver per module ini parameters |
| 14418 | * @hdd_ctx: HDD Context |
| 14419 | * |
| 14420 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14421 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14422 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14423 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14424 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14425 | int ret; |
| 14426 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14427 | if (ucfg_pmo_is_ns_offloaded(hdd_ctx->psoc)) |
| 14428 | hdd_ctx->ns_offload_enable = true; |
| 14429 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14430 | hdd_update_ol_config(hdd_ctx); |
| 14431 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14432 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 14433 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 14434 | else |
| 14435 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 14436 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14437 | |
| 14438 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14439 | } |
| 14440 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14441 | /** |
| 14442 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 14443 | * @hdd_ctx: HDD context |
| 14444 | * |
| 14445 | * Return: void |
| 14446 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14447 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14448 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14449 | struct pmo_psoc_cfg psoc_cfg = {0}; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14450 | QDF_STATUS status; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14451 | enum pmo_wow_enable_type wow_enable; |
| 14452 | |
| 14453 | ucfg_pmo_get_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14454 | |
| 14455 | /* |
| 14456 | * Value of hdd_ctx->wowEnable can be, |
| 14457 | * 0 - Disable both magic pattern match and pattern byte match. |
| 14458 | * 1 - Enable magic pattern match on all interfaces. |
| 14459 | * 2 - Enable pattern byte match on all interfaces. |
| 14460 | * 3 - Enable both magic patter and pattern byte match on |
| 14461 | * all interfaces. |
| 14462 | */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14463 | wow_enable = ucfg_pmo_get_wow_enable(hdd_ctx->psoc); |
| 14464 | psoc_cfg.magic_ptrn_enable = (wow_enable & 0x01) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14465 | psoc_cfg.ptrn_match_enable_all_vdev = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14466 | (wow_enable & 0x02) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14467 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 14468 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 14469 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 14470 | &psoc_cfg.sta_max_li_mod_dtim); |
| 14471 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14472 | |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 14473 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14474 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14475 | status = ucfg_pmo_update_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 14476 | if (QDF_IS_STATUS_ERROR(status)) |
| 14477 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 14478 | |
| 14479 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14480 | } |
| 14481 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14482 | 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] | 14483 | struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14484 | { |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14485 | struct wlan_fwol_ie_whitelist whitelist = {0}; |
| 14486 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14487 | QDF_STATUS status; |
| 14488 | bool is_ie_whitelist_enable = false; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14489 | uint8_t i = 0; |
| 14490 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14491 | status = ucfg_fwol_get_ie_whitelist(psoc, &is_ie_whitelist_enable); |
| 14492 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14493 | hdd_err("Unable to get IE whitelist param"); |
| 14494 | return; |
| 14495 | } |
| 14496 | |
| 14497 | ie_whitelist->white_list = is_ie_whitelist_enable; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14498 | if (!ie_whitelist->white_list) |
| 14499 | return; |
| 14500 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14501 | status = ucfg_fwol_get_all_whitelist_params(psoc, &whitelist); |
| 14502 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14503 | hdd_err("Unable to get all whitelist params"); |
| 14504 | return; |
| 14505 | } |
| 14506 | |
| 14507 | ie_whitelist->ie_bitmap[0] = whitelist.ie_bitmap_0; |
| 14508 | ie_whitelist->ie_bitmap[1] = whitelist.ie_bitmap_1; |
| 14509 | ie_whitelist->ie_bitmap[2] = whitelist.ie_bitmap_2; |
| 14510 | ie_whitelist->ie_bitmap[3] = whitelist.ie_bitmap_3; |
| 14511 | ie_whitelist->ie_bitmap[4] = whitelist.ie_bitmap_4; |
| 14512 | ie_whitelist->ie_bitmap[5] = whitelist.ie_bitmap_5; |
| 14513 | ie_whitelist->ie_bitmap[6] = whitelist.ie_bitmap_6; |
| 14514 | ie_whitelist->ie_bitmap[7] = whitelist.ie_bitmap_7; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14515 | |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14516 | ie_whitelist->num_vendor_oui = whitelist.no_of_probe_req_ouis; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14517 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14518 | ie_whitelist->voui[i] = whitelist.probe_req_voui[i]; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14519 | } |
| 14520 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14521 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 14522 | { |
| 14523 | uint8_t i, score; |
| 14524 | |
| 14525 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 14526 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 14527 | if (score > MAX_INDEX_SCORE) |
| 14528 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 14529 | MAX_INDEX_SCORE, i); |
| 14530 | } |
| 14531 | |
| 14532 | return per_index_score; |
| 14533 | } |
| 14534 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14535 | QDF_STATUS hdd_update_score_config( |
| 14536 | struct scoring_config *score_config, struct hdd_context *hdd_ctx) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14537 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14538 | struct hdd_config *cfg = hdd_ctx->config; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14539 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14540 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14541 | bool bval = false; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 14542 | uint32_t channel_bonding_mode; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14543 | |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14544 | qdf_mem_zero(&vdev_ini_cfg, sizeof(struct wlan_mlme_nss_chains)); |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14545 | /* Populate the nss chain params from ini for this vdev type */ |
| 14546 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 14547 | QDF_STA_MODE, |
| 14548 | hdd_ctx->num_rf_chains); |
| 14549 | |
| 14550 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]; |
gaurank kathpalia | 19c2354 | 2019-06-01 16:57:28 +0530 | [diff] [blame] | 14551 | score_config->vdev_nss_5g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14552 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14553 | sme_update_score_config(hdd_ctx->mac_handle, score_config); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14554 | |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 14555 | ucfg_mlme_get_channel_bonding_24ghz(hdd_ctx->psoc, |
| 14556 | &channel_bonding_mode); |
| 14557 | score_config->cb_mode_24G = channel_bonding_mode; |
| 14558 | ucfg_mlme_get_channel_bonding_5ghz(hdd_ctx->psoc, |
| 14559 | &channel_bonding_mode); |
| 14560 | score_config->cb_mode_5G = channel_bonding_mode; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14561 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14562 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 14563 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 14564 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 14565 | score_config->he_cap = 1; |
| 14566 | |
| 14567 | if (score_config->he_cap || |
| 14568 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 14569 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 14570 | score_config->vht_cap = 1; |
| 14571 | |
| 14572 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 14573 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 14574 | score_config->ht_cap = 1; |
| 14575 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14576 | status = ucfg_mlme_get_vht_for_24ghz(hdd_ctx->psoc, &bval); |
| 14577 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14578 | hdd_err("Failed to get vht_for_24ghz"); |
| 14579 | if (score_config->vht_cap && bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14580 | score_config->vht_24G_cap = 1; |
| 14581 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14582 | status = ucfg_mlme_get_vht_enable_tx_bf(hdd_ctx->psoc, |
| 14583 | &bval); |
| 14584 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14585 | hdd_err("unable to get vht_enable_tx_bf"); |
| 14586 | |
| 14587 | if (bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14588 | score_config->beamformee_cap = 1; |
| 14589 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14590 | return QDF_STATUS_SUCCESS; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14591 | } |
| 14592 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14593 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14594 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 14595 | * @hdd_ctx: HDD context |
| 14596 | * |
| 14597 | * Return: 0 if success else err |
| 14598 | */ |
| 14599 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 14600 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14601 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14602 | struct dfs_user_config dfs_cfg = {0}; |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14603 | QDF_STATUS status; |
| 14604 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 14605 | ucfg_mlme_get_dfs_filter_offload(hdd_ctx->psoc, |
| 14606 | &dfs_cfg.dfs_is_phyerr_filter_offload); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14607 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 14608 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14609 | hdd_err("failed dfs psoc configuration"); |
| 14610 | return -EINVAL; |
| 14611 | } |
| 14612 | |
| 14613 | return 0; |
| 14614 | } |
| 14615 | |
| 14616 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14617 | * hdd_update_scan_config - API to update scan configuration parameters |
| 14618 | * @hdd_ctx: HDD context |
| 14619 | * |
| 14620 | * Return: 0 if success else err |
| 14621 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14622 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14623 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14624 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Sandeep Puligilla | d788702 | 2019-02-26 00:48:52 -0800 | [diff] [blame] | 14625 | struct scan_user_cfg scan_cfg; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14626 | QDF_STATUS status; |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14627 | uint32_t mcast_mcc_rest_time = 0; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14628 | |
Sandeep Puligilla | d788702 | 2019-02-26 00:48:52 -0800 | [diff] [blame] | 14629 | qdf_mem_zero(&scan_cfg, sizeof(scan_cfg)); |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14630 | status = ucfg_mlme_get_sta_miracast_mcc_rest_time(hdd_ctx->psoc, |
| 14631 | &mcast_mcc_rest_time); |
| 14632 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14633 | hdd_err("ucfg_mlme_get_sta_miracast_mcc_rest_time, use def"); |
| 14634 | return -EIO; |
| 14635 | } |
| 14636 | scan_cfg.sta_miracast_mcc_rest_time = mcast_mcc_rest_time; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14637 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14638 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14639 | status = hdd_update_score_config(&scan_cfg.score_config, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14640 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14641 | hdd_err("Failed to update scoring config"); |
| 14642 | return -EINVAL; |
| 14643 | } |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14644 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14645 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 14646 | if (status != QDF_STATUS_SUCCESS) { |
| 14647 | hdd_err("failed pmo psoc configuration"); |
| 14648 | return -EINVAL; |
| 14649 | } |
| 14650 | |
| 14651 | return 0; |
| 14652 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14653 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14654 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14655 | { |
| 14656 | int ret; |
| 14657 | |
| 14658 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14659 | if (ret) |
| 14660 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14661 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14662 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14663 | if (ret) |
| 14664 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14665 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14666 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14667 | if (ret) |
| 14668 | return ret; |
| 14669 | |
| 14670 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14671 | if (ret) |
| 14672 | return ret; |
| 14673 | |
| 14674 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14675 | |
| 14676 | return ret; |
| 14677 | } |
| 14678 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14679 | /** |
| 14680 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 14681 | * @mode : cfg80211 DFS mode |
| 14682 | * |
| 14683 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 14684 | */ |
| 14685 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 14686 | { |
| 14687 | switch (mode) { |
| 14688 | case DFS_MODE_ENABLE: |
| 14689 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14690 | case DFS_MODE_DISABLE: |
| 14691 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14692 | case DFS_MODE_DEPRIORITIZE: |
| 14693 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14694 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14695 | hdd_debug("ACS dfs mode is NONE"); |
| 14696 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14697 | } |
| 14698 | } |
| 14699 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14700 | /** |
| 14701 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 14702 | * @hddctx: pointer to hdd context |
| 14703 | * @set_value: enable/disable |
| 14704 | * |
| 14705 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 14706 | * Host(even though it is duplicate). When Host send vendor command |
| 14707 | * disable,FW doesn't perform any action. Whenever any change in |
| 14708 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 14709 | * |
| 14710 | * return - 0 on success, appropriate error values on failure. |
| 14711 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14712 | 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] | 14713 | { |
| 14714 | QDF_STATUS status; |
| 14715 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14716 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14717 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14718 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14719 | status = sme_enable_disable_chanavoidind_event(hdd_ctx->mac_handle, |
| 14720 | set_value); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14721 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14722 | hdd_err("Failed to send chan avoid command to SME"); |
| 14723 | return -EINVAL; |
| 14724 | } |
| 14725 | return 0; |
| 14726 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14727 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14728 | /** |
| 14729 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 14730 | * @value: value to set |
| 14731 | * |
| 14732 | * This function will set the passed value to roaming in progress flag. |
| 14733 | * |
| 14734 | * Return: None |
| 14735 | */ |
| 14736 | void hdd_set_roaming_in_progress(bool value) |
| 14737 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14738 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14739 | |
| 14740 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14741 | if (!hdd_ctx) { |
| 14742 | hdd_err("HDD context is NULL"); |
| 14743 | return; |
| 14744 | } |
| 14745 | |
| 14746 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14747 | hdd_debug("Roaming in Progress set to %d", value); |
Abhinav Kumar | 2b431b6 | 2019-03-18 20:23:58 +0530 | [diff] [blame] | 14748 | if (!hdd_ctx->roaming_in_progress) { |
| 14749 | /* Reset scan reject params on successful roam complete */ |
| 14750 | hdd_debug("Reset scan reject params"); |
| 14751 | hdd_init_scan_reject_params(hdd_ctx); |
| 14752 | } |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14753 | } |
| 14754 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14755 | bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14756 | { |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14757 | if (!hdd_ctx) { |
| 14758 | hdd_err("HDD context is NULL"); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14759 | return false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14760 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 14761 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14762 | hdd_debug("roaming_in_progress = %d", hdd_ctx->roaming_in_progress); |
| 14763 | |
| 14764 | return hdd_ctx->roaming_in_progress; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14765 | } |
| 14766 | |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14767 | bool hdd_is_connection_in_progress(uint8_t *out_vdev_id, |
| 14768 | enum scan_reject_states *out_reason) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14769 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 14770 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14771 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14772 | uint8_t sta_id = 0; |
| 14773 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14774 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14775 | mac_handle_t mac_handle; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14776 | |
| 14777 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14778 | if (!hdd_ctx) { |
| 14779 | hdd_err("HDD context is NULL"); |
| 14780 | return false; |
| 14781 | } |
| 14782 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14783 | mac_handle = hdd_ctx->mac_handle; |
| 14784 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14785 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 929afa4 | 2018-06-01 15:04:44 -0700 | [diff] [blame] | 14786 | hdd_debug("Adapter with device mode %s(%d) exists", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 14787 | qdf_opmode_str(adapter->device_mode), |
| 14788 | adapter->device_mode); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14789 | if (((QDF_STA_MODE == adapter->device_mode) |
| 14790 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 14791 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 14792 | && (eConnectionState_Connecting == |
| 14793 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 14794 | conn_info.conn_state)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14795 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14796 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14797 | adapter->vdev_id); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14798 | if (out_vdev_id && out_reason) { |
| 14799 | *out_vdev_id = adapter->vdev_id; |
| 14800 | *out_reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14801 | } |
| 14802 | return true; |
| 14803 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 14804 | /* |
| 14805 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 14806 | * hdd_is_roaming_in_progress is for LFR3 |
| 14807 | */ |
| 14808 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 14809 | sme_neighbor_middle_of_roaming( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14810 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14811 | adapter->vdev_id)) || |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14812 | hdd_is_roaming_in_progress(hdd_ctx)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14813 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14814 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14815 | adapter->vdev_id); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14816 | if (out_vdev_id && out_reason) { |
| 14817 | *out_vdev_id = adapter->vdev_id; |
| 14818 | *out_reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14819 | } |
| 14820 | return true; |
| 14821 | } |
| 14822 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 14823 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 14824 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 14825 | hdd_sta_ctx = |
| 14826 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 14827 | if ((eConnectionState_Associated == |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 14828 | hdd_sta_ctx->conn_info.conn_state) |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 14829 | && sme_is_sta_key_exchange_in_progress( |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14830 | mac_handle, adapter->vdev_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14831 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 14832 | &(adapter->mac_addr.bytes[0]); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 14833 | hdd_debug("client " QDF_MAC_ADDR_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14834 | " is in middle of WPS/EAPOL exchange.", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 14835 | QDF_MAC_ADDR_ARRAY(sta_mac)); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14836 | if (out_vdev_id && out_reason) { |
| 14837 | *out_vdev_id = adapter->vdev_id; |
| 14838 | *out_reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14839 | } |
| 14840 | return true; |
| 14841 | } |
| 14842 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 14843 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 14844 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 14845 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14846 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14847 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14848 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14849 | continue; |
| 14850 | |
| 14851 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14852 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 14853 | sta_mac.bytes[0]); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 14854 | hdd_debug("client " QDF_MAC_ADDR_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14855 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 14856 | QDF_MAC_ADDR_ARRAY(sta_mac)); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14857 | if (out_vdev_id && out_reason) { |
| 14858 | *out_vdev_id = adapter->vdev_id; |
| 14859 | *out_reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14860 | } |
| 14861 | return true; |
| 14862 | } |
| 14863 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14864 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14865 | return true; |
| 14866 | } |
| 14867 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14868 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14869 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14870 | return false; |
| 14871 | } |
| 14872 | |
| 14873 | /** |
| 14874 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14875 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14876 | * |
| 14877 | * Return: None |
| 14878 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14879 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14880 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 14881 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 14882 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14883 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14884 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | 8f8ceb9 | 2019-03-24 08:16:55 -0700 | [diff] [blame] | 14885 | struct sap_config *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14886 | void *sap_ctx; |
| 14887 | |
| 14888 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 14889 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 14890 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14891 | |
| 14892 | mutex_lock(&hdd_ctx->sap_lock); |
| 14893 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 14894 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14895 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 14896 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 14897 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 14898 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14899 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14900 | qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 14901 | SME_CMD_STOP_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14902 | |
| 14903 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14904 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14905 | goto end; |
| 14906 | } |
| 14907 | } |
| 14908 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14909 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14910 | ap_adapter->device_mode, ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14911 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14912 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14913 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14914 | |
| 14915 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14916 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14917 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14918 | eUPDATE_IE_ALL); |
| 14919 | goto end; |
| 14920 | } |
| 14921 | |
| 14922 | qdf_event_reset(&hostapd_state->qdf_event); |
| 14923 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 14924 | sap_config, |
| 14925 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14926 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14927 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14928 | eUPDATE_IE_ALL); |
| 14929 | goto end; |
| 14930 | } |
| 14931 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14932 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14933 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14934 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 14935 | SME_CMD_START_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14936 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14937 | eUPDATE_IE_ALL); |
| 14938 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14939 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14940 | goto end; |
| 14941 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14942 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14943 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14944 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14945 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14946 | ap_adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14947 | ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14948 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14949 | ap_adapter->device_mode, |
| 14950 | true); |
| 14951 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14952 | } |
| 14953 | end: |
| 14954 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14955 | } |
| 14956 | |
| 14957 | /** |
| 14958 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 14959 | * with non dfs acs |
| 14960 | * |
| 14961 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 14962 | * |
| 14963 | * Return: None |
| 14964 | */ |
| 14965 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 14966 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14967 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14968 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 14969 | struct cds_context *cds_ctx; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14970 | uint8_t restart_chan; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14971 | |
| 14972 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14973 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14974 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14975 | return; |
| 14976 | } |
| 14977 | |
| 14978 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 14979 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14980 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14981 | return; |
| 14982 | } |
| 14983 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14984 | if (policy_mgr_get_concurrency_mode(hdd_ctx->psoc) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14985 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 14986 | hdd_debug("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14987 | return; |
| 14988 | } |
| 14989 | |
| 14990 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14991 | if (ap_adapter && |
| 14992 | test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags) && |
| 14993 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, |
| 14994 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14995 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14996 | 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] | 14997 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14998 | restart_chan = |
bings | 6c4672b | 2019-03-19 16:00:19 +0800 | [diff] [blame] | 14999 | wlansap_get_safe_channel_from_pcl_and_acs_range( |
| 15000 | WLAN_HDD_GET_SAP_CTX_PTR(ap_adapter)); |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 15001 | if (!restart_chan || |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 15002 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, restart_chan)) |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 15003 | restart_chan = SAP_DEFAULT_5GHZ_CHANNEL; |
| 15004 | |
| 15005 | hdd_switch_sap_channel(ap_adapter, restart_chan, true); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 15006 | } |
| 15007 | } |
| 15008 | |
| 15009 | /** |
| 15010 | * hdd_set_connection_in_progress() - to set the connection in |
| 15011 | * progress flag |
| 15012 | * @value: value to set |
| 15013 | * |
| 15014 | * This function will set the passed value to connection in progress flag. |
| 15015 | * If value is previously being set to true then no need to set it again. |
| 15016 | * |
| 15017 | * Return: true if value is being set correctly and false otherwise. |
| 15018 | */ |
| 15019 | bool hdd_set_connection_in_progress(bool value) |
| 15020 | { |
| 15021 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 15022 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 15023 | |
| 15024 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 15025 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 15026 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 15027 | return false; |
| 15028 | } |
| 15029 | |
| 15030 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 15031 | /* |
| 15032 | * if the value is set to true previously and if someone is |
| 15033 | * trying to make it true again then it could be some race |
| 15034 | * condition being triggered. Avoid this situation by returning |
| 15035 | * false |
| 15036 | */ |
| 15037 | if (hdd_ctx->connection_in_progress && value) |
| 15038 | status = false; |
| 15039 | else |
| 15040 | hdd_ctx->connection_in_progress = value; |
| 15041 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 15042 | return status; |
| 15043 | } |
| 15044 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 15045 | 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] | 15046 | { |
| 15047 | if (!adapter) { |
| 15048 | hdd_err("Invalid adapter"); |
| 15049 | return -EINVAL; |
| 15050 | } |
| 15051 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 15052 | sme_cli_set_command(adapter->vdev_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 15053 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 15054 | set_value, VDEV_CMD); |
| 15055 | return 0; |
| 15056 | |
| 15057 | } |
| 15058 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 15059 | 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] | 15060 | { |
| 15061 | if (!adapter) { |
| 15062 | hdd_err("Invalid adapter"); |
| 15063 | return -EINVAL; |
| 15064 | } |
| 15065 | |
| 15066 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 15067 | sme_cli_set_command(adapter->vdev_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 15068 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 15069 | set_value, VDEV_CMD); |
| 15070 | return 0; |
| 15071 | } |
| 15072 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 15073 | 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] | 15074 | *psoc, uint8_t vdev_id) |
| 15075 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 15076 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 15077 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 15078 | |
| 15079 | /* |
| 15080 | * Currently PSOC is not being used. But this logic will |
| 15081 | * change once we have the converged implementation of |
| 15082 | * HDD context per PSOC in place. This would break if |
| 15083 | * multiple vdev objects reuse the vdev id. |
| 15084 | */ |
| 15085 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 15086 | if (!adapter) |
| 15087 | hdd_err("Get adapter by vdev id failed"); |
| 15088 | |
| 15089 | return adapter; |
| 15090 | } |
| 15091 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 15092 | 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] | 15093 | int8_t *rssi, int8_t *snr) |
| 15094 | { |
| 15095 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 15096 | mac_handle_t mac_handle; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 15097 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 15098 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 15099 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 15100 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 15101 | status = sme_get_rssi_snr_by_bssid(mac_handle, |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 15102 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 15103 | if (QDF_STATUS_SUCCESS != status) { |
| 15104 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 15105 | return -EINVAL; |
| 15106 | } |
| 15107 | |
| 15108 | return 0; |
| 15109 | } |
| 15110 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 15111 | /** |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15112 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 15113 | * @adapter - HDD adapter |
| 15114 | * |
| 15115 | * Return: 0 on success and non zero value on failure |
| 15116 | */ |
| 15117 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 15118 | { |
| 15119 | struct hdd_context *hdd_ctx; |
| 15120 | int ret; |
| 15121 | QDF_STATUS status; |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 15122 | uint8_t sys_pref = 0; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15123 | |
| 15124 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 15125 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 15126 | if (ret < 0) |
| 15127 | return ret; |
| 15128 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 15129 | ucfg_policy_mgr_get_sys_pref(hdd_ctx->psoc, |
| 15130 | &sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15131 | /* set the system preferece to default */ |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 15132 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->psoc, sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15133 | |
| 15134 | /* clear the bitmap */ |
| 15135 | adapter->active_ac = 0; |
| 15136 | |
| 15137 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 15138 | adapter->vdev_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15139 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 15140 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 15141 | adapter->vdev_id, |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 15142 | false, 0, 0, false); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15143 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 15144 | hdd_err("failed to reset limit off chan params"); |
| 15145 | ret = -EINVAL; |
| 15146 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 15147 | |
| 15148 | return ret; |
| 15149 | } |
| 15150 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15151 | void hdd_set_rx_mode_rps(bool enable) |
| 15152 | { |
| 15153 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 15154 | struct hdd_context *hdd_ctx; |
| 15155 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15156 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 15157 | if (!cds_cfg) |
| 15158 | return; |
| 15159 | |
| 15160 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 15161 | if (!hdd_ctx) |
| 15162 | return; |
| 15163 | |
| 15164 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 15165 | if (!adapter) |
| 15166 | return; |
| 15167 | |
| 15168 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15169 | if (enable && !cds_cfg->rps_enabled) |
| 15170 | hdd_send_rps_ind(adapter); |
| 15171 | else if (!enable && cds_cfg->rps_enabled) |
| 15172 | hdd_send_rps_disable_ind(adapter); |
| 15173 | } |
| 15174 | } |
| 15175 | |
Abhinav Kumar | 338e57d | 2019-02-04 17:30:10 +0530 | [diff] [blame] | 15176 | void hdd_hidden_ssid_enable_roaming(hdd_handle_t hdd_handle, uint8_t vdev_id) |
| 15177 | { |
| 15178 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
| 15179 | struct hdd_adapter *adapter; |
| 15180 | |
| 15181 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 15182 | |
| 15183 | if (!adapter) { |
| 15184 | hdd_err("Adapter is null"); |
| 15185 | return; |
| 15186 | } |
| 15187 | /* enable roaming on all adapters once hdd get hidden ssid rsp */ |
| 15188 | wlan_hdd_enable_roaming(adapter); |
| 15189 | } |
| 15190 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15191 | /* Register the module init/exit functions */ |
| 15192 | module_init(hdd_module_init); |
| 15193 | module_exit(hdd_module_exit); |
| 15194 | |
| 15195 | MODULE_LICENSE("Dual BSD/GPL"); |
| 15196 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 15197 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 15198 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15199 | static const struct kernel_param_ops con_mode_ops = { |
| 15200 | .set = con_mode_handler, |
| 15201 | .get = param_get_int, |
| 15202 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15203 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15204 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 15205 | .set = con_mode_handler_ftm, |
| 15206 | .get = param_get_int, |
| 15207 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 15208 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 15209 | #ifdef WLAN_FEATURE_EPPING |
| 15210 | static const struct kernel_param_ops con_mode_epping_ops = { |
| 15211 | .set = con_mode_handler_epping, |
| 15212 | .get = param_get_int, |
| 15213 | }; |
| 15214 | #endif |
| 15215 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15216 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15217 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 15218 | .set = con_mode_handler_monitor, |
| 15219 | .get = param_get_int, |
| 15220 | }; |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15221 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 15222 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15223 | static const struct kernel_param_ops fwpath_ops = { |
| 15224 | .set = fwpath_changed_handler, |
| 15225 | .get = param_get_string, |
| 15226 | }; |
| 15227 | |
| 15228 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 15229 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15230 | |
| 15231 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 15232 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15233 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 15234 | #ifdef WLAN_FEATURE_EPPING |
| 15235 | module_param_cb(con_mode_epping, &con_mode_epping_ops, |
| 15236 | &con_mode_epping, 0644); |
| 15237 | #endif |
| 15238 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15239 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15240 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 15241 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15242 | #endif |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15243 | |
| 15244 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 15245 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15246 | |
| 15247 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15248 | |
| 15249 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15250 | |
| 15251 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |
Dustin Brown | 4bbd546 | 2019-03-22 11:18:13 -0700 | [diff] [blame] | 15252 | |
| 15253 | static int timer_multiplier_get_handler(char *buffer, |
| 15254 | const struct kernel_param *kp) |
| 15255 | { |
| 15256 | return scnprintf(buffer, PAGE_SIZE, "%u", qdf_timer_get_multiplier()); |
| 15257 | } |
| 15258 | |
| 15259 | static int timer_multiplier_set_handler(const char *kmessage, |
| 15260 | const struct kernel_param *kp) |
| 15261 | { |
| 15262 | QDF_STATUS status; |
| 15263 | uint32_t scalar; |
| 15264 | |
| 15265 | status = qdf_uint32_parse(kmessage, &scalar); |
| 15266 | if (QDF_IS_STATUS_ERROR(status)) |
| 15267 | return qdf_status_to_os_return(status); |
| 15268 | |
| 15269 | if (!cfg_in_range(CFG_TIMER_MULTIPLIER, scalar)) |
| 15270 | return -ERANGE; |
| 15271 | |
| 15272 | qdf_timer_set_multiplier(scalar); |
| 15273 | |
| 15274 | return 0; |
| 15275 | } |
| 15276 | |
| 15277 | static const struct kernel_param_ops timer_multiplier_ops = { |
| 15278 | .get = timer_multiplier_get_handler, |
| 15279 | .set = timer_multiplier_set_handler, |
| 15280 | }; |
| 15281 | |
| 15282 | module_param_cb(timer_multiplier, &timer_multiplier_ops, NULL, 0644); |
| 15283 | |