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 | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 58 | #include "qdf_str.h" |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 59 | #include "qdf_talloc.h" |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 60 | #include "qdf_trace.h" |
| 61 | #include "qdf_types.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 62 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 63 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 64 | #include <cdp_txrx_stats.h> |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 65 | #include "cdp_txrx_flow_ctrl_legacy.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 66 | |
| 67 | #include <net/addrconf.h> |
| 68 | #include <linux/wireless.h> |
| 69 | #include <net/cfg80211.h> |
| 70 | #include <linux/inetdevice.h> |
| 71 | #include <net/addrconf.h> |
| 72 | #include "wlan_hdd_cfg80211.h" |
| 73 | #include "wlan_hdd_ext_scan.h" |
| 74 | #include "wlan_hdd_p2p.h" |
| 75 | #include <linux/rtnetlink.h> |
| 76 | #include "sap_api.h" |
| 77 | #include <linux/semaphore.h> |
| 78 | #include <linux/ctype.h> |
| 79 | #include <linux/compat.h> |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 80 | #include <linux/reboot.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 81 | #ifdef MSM_PLATFORM |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 82 | #include "qdf_periodic_work.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 83 | #include <soc/qcom/subsystem_restart.h> |
| 84 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 85 | #include <wlan_hdd_hostapd.h> |
| 86 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 87 | #include <wlan_hdd_green_ap.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 88 | #include "qwlan_version.h" |
| 89 | #include "wma_types.h" |
| 90 | #include "wlan_hdd_tdls.h" |
| 91 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 92 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 93 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 94 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 95 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 96 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 97 | #include "wlan_hdd_nan.h" |
| 98 | #include "wlan_hdd_debugfs.h" |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 99 | #include "wlan_hdd_debugfs_csr.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 100 | #include "wlan_hdd_driver_ops.h" |
| 101 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 102 | #include "wlan_hdd_data_stall_detection.h" |
stonez | c9936cb | 2019-03-11 16:41:22 +0800 | [diff] [blame] | 103 | #include "wlan_hdd_mpta_helper.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 104 | |
| 105 | #include <wlan_hdd_ipa.h> |
| 106 | #include "hif.h" |
| 107 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 108 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 109 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 110 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 111 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 112 | #include "wlan_hdd_lpass.h" |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 113 | #include "wlan_nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 114 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 115 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 116 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 117 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 118 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 119 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 120 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 121 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 122 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 123 | #include "os_if_wifi_pos.h" |
| 124 | #include "wifi_pos_api.h" |
| 125 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 126 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 127 | #include "os_if_nan.h" |
| 128 | #include "nan_public_structs.h" |
Nachiket Kukade | 85aa378 | 2018-11-02 20:12:34 +0530 | [diff] [blame] | 129 | #include "nan_ucfg_api.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 130 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 131 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 132 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 133 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 134 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 135 | #include <cdp_txrx_cmn_struct.h> |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 136 | #include <dp_txrx.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 137 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 138 | #include "wlan_disa_ucfg_api.h" |
Wu Gao | 52084c1 | 2018-05-17 20:47:11 +0800 | [diff] [blame] | 139 | #include "wlan_disa_obj_mgmt_api.h" |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 140 | #include "wlan_action_oui_ucfg_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 141 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 142 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 143 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 144 | #include "wlan_hdd_apf.h" |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 145 | #include "wlan_hdd_twt.h" |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 146 | #include "qc_sap_ioctl.h" |
Sandeep Puligilla | c5609d5 | 2018-05-17 19:23:41 -0700 | [diff] [blame] | 147 | #include "wlan_mlme_main.h" |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 148 | #include "wlan_p2p_cfg_api.h" |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 149 | #include "wlan_cfg80211_p2p.h" |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 150 | #include "wlan_tdls_cfg_api.h" |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 151 | #include <wlan_hdd_rssi_monitor.h> |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 152 | #include "wlan_mlme_ucfg_api.h" |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 153 | #include "wlan_fwol_ucfg_api.h" |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 154 | #include "wlan_policy_mgr_ucfg.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 155 | #ifdef CNSS_GENL |
| 156 | #include <net/cnss_nl.h> |
| 157 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 158 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 159 | #include "wlan_ocb_ucfg_api.h" |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 160 | #include <wlan_hdd_spectralscan.h> |
gaurank kathpalia | 4a205fc | 2018-09-15 00:59:15 +0530 | [diff] [blame] | 161 | #include "wlan_green_ap_ucfg_api.h" |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 162 | #include <wlan_p2p_ucfg_api.h> |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 163 | #include <target_type.h> |
Arun Kumar Khandavalli | deda5a8 | 2019-03-11 15:32:19 +0530 | [diff] [blame^] | 164 | #include <wlan_hdd_debugfs_coex.h> |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 165 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 166 | #ifdef MODULE |
| 167 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 168 | #else |
| 169 | #define WLAN_MODULE_NAME "wlan" |
| 170 | #endif |
| 171 | |
| 172 | #ifdef TIMER_MANAGER |
| 173 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 174 | #else |
| 175 | #define TIMER_MANAGER_STR "" |
| 176 | #endif |
| 177 | |
| 178 | #ifdef MEMORY_DEBUG |
| 179 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 180 | #else |
| 181 | #define MEMORY_DEBUG_STR "" |
| 182 | #endif |
| 183 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 184 | #ifdef PANIC_ON_BUG |
| 185 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 186 | #else |
| 187 | #define PANIC_ON_BUG_STR "" |
| 188 | #endif |
| 189 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 190 | bool g_is_system_reboot_triggered; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 191 | int wlan_start_ret_val; |
| 192 | static DECLARE_COMPLETION(wlan_start_comp); |
| 193 | static unsigned int dev_num = 1; |
| 194 | static struct cdev wlan_hdd_state_cdev; |
| 195 | static struct class *class; |
| 196 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 197 | #ifndef MODULE |
| 198 | static struct gwlan_loader *wlan_loader; |
| 199 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 200 | struct kobj_attribute *attr, |
| 201 | const char *buf, size_t count); |
| 202 | struct gwlan_loader { |
| 203 | bool loaded_state; |
| 204 | struct kobject *boot_wlan_obj; |
| 205 | struct attribute_group *attr_group; |
| 206 | }; |
| 207 | |
| 208 | static struct kobj_attribute wlan_boot_attribute = |
| 209 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 210 | |
| 211 | static struct attribute *attrs[] = { |
| 212 | &wlan_boot_attribute.attr, |
| 213 | NULL, |
| 214 | }; |
| 215 | |
| 216 | #define MODULE_INITIALIZED 1 |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 217 | |
| 218 | #ifdef MULTI_IF_NAME |
| 219 | #define WLAN_LOADER_NAME "boot_" MULTI_IF_NAME |
| 220 | #else |
| 221 | #define WLAN_LOADER_NAME "boot_wlan" |
| 222 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 223 | #endif |
| 224 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 225 | /* the Android framework expects this param even though we don't use it */ |
| 226 | #define BUF_LEN 20 |
| 227 | static char fwpath_buffer[BUF_LEN]; |
| 228 | static struct kparam_string fwpath = { |
| 229 | .string = fwpath_buffer, |
| 230 | .maxlen = BUF_LEN, |
| 231 | }; |
| 232 | |
| 233 | static char *country_code; |
| 234 | static int enable_11d = -1; |
| 235 | static int enable_dfs_chan_scan = -1; |
| 236 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 237 | #define WLAN_NLINK_CESIUM 30 |
| 238 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 239 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 240 | |
| 241 | #define WOW_MAX_FILTER_LISTS 1 |
| 242 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 243 | #define WOW_MIN_PATTERN_SIZE 6 |
| 244 | #define WOW_MAX_PATTERN_SIZE 64 |
| 245 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 246 | /* max peer can be tdls peers + self peer + bss peer */ |
| 247 | #define HDD_MAX_VDEV_PEER_COUNT (HDD_MAX_NUM_TDLS_STA + 2) |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 248 | #define IS_IDLE_STOP (!cds_is_driver_unloading() && \ |
| 249 | !cds_is_driver_recovering() && !cds_is_driver_loading()) |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 250 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 251 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 252 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 253 | .flags = WIPHY_WOWLAN_ANY | |
| 254 | WIPHY_WOWLAN_MAGIC_PKT | |
| 255 | WIPHY_WOWLAN_DISCONNECT | |
| 256 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 257 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 258 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 259 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 260 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 261 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 262 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 263 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 264 | }; |
| 265 | #endif |
| 266 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 267 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 268 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 269 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 270 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 271 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 272 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 273 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 274 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 275 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 276 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 277 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 278 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 280 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 281 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 282 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 283 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 284 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 285 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 286 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 287 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 288 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 289 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 290 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 291 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 292 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 293 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 294 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 295 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 296 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 297 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 298 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 299 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 300 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 301 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 302 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 303 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 304 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 305 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 306 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 307 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 308 | [QDF_MODULE_ID_ACTION_OUI] = {QDF_TRACE_LEVEL_ALL}, |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 309 | [QDF_MODULE_ID_CONFIG] = {QDF_TRACE_LEVEL_ALL}, |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 310 | [QDF_MODULE_ID_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 8d039c8 | 2018-07-11 20:41:14 +0530 | [diff] [blame] | 311 | [QDF_MODULE_ID_TARGET] = {QDF_TRACE_LEVEL_ALL}, |
Kiran Kumar Lokere | 4ce4048 | 2018-08-30 16:31:00 -0700 | [diff] [blame] | 312 | [QDF_MODULE_ID_CRYPTO] = {QDF_TRACE_LEVEL_ALL}, |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 313 | [QDF_MODULE_ID_FWOL] = {QDF_TRACE_LEVEL_ALL}, |
Abhishek Singh | 0b0105f | 2018-09-25 10:44:16 +0530 | [diff] [blame] | 314 | [QDF_MODULE_ID_SM_ENGINE] = {QDF_TRACE_LEVEL_ALL}, |
| 315 | [QDF_MODULE_ID_CMN_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Nachiket Kukade | 089b983 | 2018-12-12 16:38:17 +0530 | [diff] [blame] | 316 | [QDF_MODULE_ID_NAN] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 6ed4434 | 2019-02-07 21:11:00 +0530 | [diff] [blame] | 317 | [QDF_MODULE_ID_CP_STATS] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 318 | }; |
| 319 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 320 | struct notifier_block hdd_netdev_notifier; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 321 | struct notifier_block system_reboot_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 322 | |
| 323 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 324 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 325 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 326 | #endif |
| 327 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 328 | void hdd_start_complete(int ret) |
| 329 | { |
| 330 | wlan_start_ret_val = ret; |
| 331 | |
| 332 | complete(&wlan_start_comp); |
| 333 | } |
| 334 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 335 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 336 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 337 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 338 | * |
| 339 | * Return: none |
| 340 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 341 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 342 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 343 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 344 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 345 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 346 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 347 | } |
| 348 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 349 | #ifdef QCA_HL_NETDEV_FLOW_CONTROL |
| 350 | void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter, |
| 351 | enum netif_action_type action) |
| 352 | { |
| 353 | if (!adapter->tx_flow_timer_initialized) |
| 354 | return; |
| 355 | |
| 356 | if (action == WLAN_WAKE_NON_PRIORITY_QUEUE) { |
| 357 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
Ajit Pal Singh | e6da1de | 2018-12-27 16:20:45 +0530 | [diff] [blame] | 358 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = false; |
| 359 | adapter->hdd_stats.tx_rx_stats.txflow_unpause_cnt++; |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 360 | } else if (action == WLAN_STOP_NON_PRIORITY_QUEUE) { |
| 361 | QDF_STATUS status = |
| 362 | qdf_mc_timer_start(&adapter->tx_flow_control_timer, |
| 363 | WLAN_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 364 | |
| 365 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 366 | hdd_err("Failed to start tx_flow_control_timer"); |
| 367 | else |
| 368 | adapter-> |
| 369 | hdd_stats.tx_rx_stats.txflow_timer_cnt++; |
| 370 | |
| 371 | adapter->hdd_stats.tx_rx_stats.txflow_pause_cnt++; |
| 372 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = true; |
| 373 | } |
| 374 | } |
| 375 | #endif /* QCA_HL_NETDEV_FLOW_CONTROL */ |
| 376 | |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 377 | #ifdef MSM_PLATFORM |
| 378 | void wlan_hdd_update_tcp_rx_param(struct hdd_context *hdd_ctx, void *data) |
| 379 | { |
| 380 | if (!hdd_ctx) { |
| 381 | hdd_err("HDD context is null"); |
| 382 | return; |
| 383 | } |
| 384 | |
| 385 | if (!data) { |
| 386 | hdd_err("Data is null"); |
| 387 | return; |
| 388 | } |
| 389 | if (hdd_ctx->config->enable_tcp_param_update) |
| 390 | wlan_hdd_send_tcp_param_update_event(hdd_ctx, data, 1); |
| 391 | else |
| 392 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 393 | WLAN_SVC_WLAN_TP_IND, |
| 394 | data, |
| 395 | sizeof(struct wlan_rx_tp_data)); |
| 396 | } |
| 397 | |
| 398 | void wlan_hdd_update_tcp_tx_param(struct hdd_context *hdd_ctx, void *data) |
| 399 | { |
| 400 | enum wlan_tp_level next_tx_level; |
| 401 | struct wlan_tx_tp_data *tx_tp_data; |
| 402 | |
| 403 | if (!hdd_ctx) { |
| 404 | hdd_err("HDD context is null"); |
| 405 | return; |
| 406 | } |
| 407 | |
| 408 | if (!data) { |
| 409 | hdd_err("Data is null"); |
| 410 | return; |
| 411 | } |
| 412 | |
| 413 | tx_tp_data = (struct wlan_tx_tp_data *)data; |
| 414 | next_tx_level = tx_tp_data->level; |
| 415 | |
| 416 | if (hdd_ctx->config->enable_tcp_param_update) |
| 417 | wlan_hdd_send_tcp_param_update_event(hdd_ctx, data, 0); |
| 418 | else |
| 419 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 420 | WLAN_SVC_WLAN_TP_TX_IND, |
| 421 | &next_tx_level, |
| 422 | sizeof(next_tx_level)); |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * wlan_hdd_send_tcp_param_update_event() - Send vendor event to update |
| 427 | * TCP parameter through Wi-Fi HAL |
| 428 | * @hdd_ctx: Pointer to HDD context |
| 429 | * @data: Parameters to update |
| 430 | * @dir: Direction(tx/rx) to update |
| 431 | * |
| 432 | * Return: None |
| 433 | */ |
| 434 | void wlan_hdd_send_tcp_param_update_event(struct hdd_context *hdd_ctx, |
| 435 | void *data, |
| 436 | uint8_t dir) |
| 437 | { |
| 438 | struct sk_buff *vendor_event; |
| 439 | uint32_t event_len; |
| 440 | bool tcp_limit_output = false; |
| 441 | bool tcp_del_ack_ind_enabled = false; |
| 442 | bool tcp_adv_win_scl_enabled = false; |
| 443 | enum wlan_tp_level next_tp_level = WLAN_SVC_TP_NONE; |
| 444 | |
| 445 | event_len = sizeof(uint8_t) + sizeof(uint8_t) + NLMSG_HDRLEN; |
| 446 | |
| 447 | if (dir == 0) /*TX Flow */ { |
| 448 | struct wlan_tx_tp_data *tx_tp_data = |
| 449 | (struct wlan_tx_tp_data *)data; |
| 450 | |
| 451 | next_tp_level = tx_tp_data->level; |
| 452 | |
| 453 | if (tx_tp_data->tcp_limit_output) { |
| 454 | /* TCP_LIMIT_OUTPUT_BYTES */ |
| 455 | event_len += sizeof(uint32_t); |
| 456 | tcp_limit_output = true; |
| 457 | } |
| 458 | } else if (dir == 1) /* RX Flow */ { |
| 459 | struct wlan_rx_tp_data *rx_tp_data = |
| 460 | (struct wlan_rx_tp_data *)data; |
| 461 | |
| 462 | next_tp_level = rx_tp_data->level; |
| 463 | |
| 464 | if (rx_tp_data->rx_tp_flags & TCP_DEL_ACK_IND_MASK) { |
| 465 | event_len += sizeof(uint32_t); /* TCP_DELACK_SEG */ |
| 466 | tcp_del_ack_ind_enabled = true; |
| 467 | } |
| 468 | if (rx_tp_data->rx_tp_flags & TCP_ADV_WIN_SCL_MASK) { |
| 469 | event_len += sizeof(uint32_t); /* TCP_ADV_WIN_SCALE */ |
| 470 | tcp_adv_win_scl_enabled = true; |
| 471 | } |
| 472 | } else { |
| 473 | hdd_err("Invalid Direction [%d]", dir); |
| 474 | return; |
| 475 | } |
| 476 | |
| 477 | vendor_event = |
| 478 | cfg80211_vendor_event_alloc( |
| 479 | hdd_ctx->wiphy, |
| 480 | NULL, event_len, |
| 481 | QCA_NL80211_VENDOR_SUBCMD_THROUGHPUT_CHANGE_EVENT_INDEX, |
| 482 | GFP_KERNEL); |
| 483 | |
| 484 | if (!vendor_event) { |
| 485 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 486 | return; |
| 487 | } |
| 488 | |
| 489 | if (nla_put_u8( |
| 490 | vendor_event, |
| 491 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_DIRECTION, |
| 492 | dir)) |
| 493 | goto tcp_param_change_nla_failed; |
| 494 | |
| 495 | if (nla_put_u8( |
| 496 | vendor_event, |
| 497 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_THROUGHPUT_LEVEL, |
| 498 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 499 | QCA_WLAN_THROUGHPUT_LEVEL_LOW : |
| 500 | QCA_WLAN_THROUGHPUT_LEVEL_HIGH))) |
| 501 | goto tcp_param_change_nla_failed; |
| 502 | |
| 503 | if (tcp_limit_output && |
| 504 | nla_put_u32( |
| 505 | vendor_event, |
| 506 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_LIMIT_OUTPUT_BYTES, |
| 507 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 508 | TCP_LIMIT_OUTPUT_BYTES_LOW : |
| 509 | TCP_LIMIT_OUTPUT_BYTES_HI))) |
| 510 | goto tcp_param_change_nla_failed; |
| 511 | |
| 512 | if (tcp_del_ack_ind_enabled && |
| 513 | (nla_put_u32( |
| 514 | vendor_event, |
| 515 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_DELACK_SEG, |
| 516 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 517 | TCP_DEL_ACK_LOW : TCP_DEL_ACK_HI)))) |
| 518 | goto tcp_param_change_nla_failed; |
| 519 | |
| 520 | if (tcp_adv_win_scl_enabled && |
| 521 | (nla_put_u32( |
| 522 | vendor_event, |
| 523 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_ADV_WIN_SCALE, |
| 524 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 525 | WIN_SCALE_LOW : WIN_SCALE_HI)))) |
| 526 | goto tcp_param_change_nla_failed; |
| 527 | |
| 528 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 529 | return; |
| 530 | |
| 531 | tcp_param_change_nla_failed: |
| 532 | hdd_err("nla_put api failed"); |
| 533 | kfree_skb(vendor_event); |
| 534 | } |
| 535 | #endif /* MSM_PLATFORM */ |
| 536 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 537 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 538 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 539 | * @vdev_id: vdev_id |
| 540 | * @action: action type |
| 541 | * @reason: reason type |
| 542 | * |
| 543 | * Return: none |
| 544 | */ |
| 545 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 546 | enum netif_action_type action, enum netif_reason_type reason) |
| 547 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 548 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 549 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 550 | |
| 551 | if (!hdd_ctx) { |
| 552 | hdd_err("hdd ctx is NULL"); |
| 553 | return; |
| 554 | } |
| 555 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 556 | wlan_hdd_mod_fc_timer(adapter, action); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 557 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 561 | * Store WLAN driver version and timestamp info in global variables such that |
| 562 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 563 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 564 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 565 | #ifdef BUILD_TAG |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 566 | 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] | 567 | #else |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 568 | 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] | 569 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 570 | |
| 571 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 572 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 573 | * @hdd_ctx: HDD context |
| 574 | * @chan_list: buf hold returned chan list |
| 575 | * @chan_num: input buf size and output returned chan num |
| 576 | * |
| 577 | * This function helps get current available chan list from regulatory |
| 578 | * module. It excludes the "disabled" and "invalid" channels. |
| 579 | * |
| 580 | * Return: 0 for success. |
| 581 | */ |
| 582 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 583 | uint8_t *chan_list, |
| 584 | uint32_t *chan_num) |
| 585 | { |
| 586 | int i = 0, j = 0; |
| 587 | struct regulatory_channel *cur_chan_list; |
| 588 | struct wlan_objmgr_pdev *pdev; |
| 589 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 590 | if (!hdd_ctx || !hdd_ctx->pdev || !chan_list || !chan_num) |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 591 | return -EINVAL; |
| 592 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 593 | pdev = hdd_ctx->pdev; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 594 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 595 | sizeof(struct regulatory_channel)); |
| 596 | if (!cur_chan_list) |
| 597 | return -ENOMEM; |
| 598 | |
| 599 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 600 | QDF_STATUS_SUCCESS) { |
| 601 | qdf_mem_free(cur_chan_list); |
| 602 | return -EINVAL; |
| 603 | } |
| 604 | |
| 605 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 606 | uint32_t ch = cur_chan_list[i].chan_num; |
| 607 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 608 | ch); |
| 609 | |
| 610 | if (state != CHANNEL_STATE_DISABLE && |
| 611 | state != CHANNEL_STATE_INVALID && |
| 612 | j < *chan_num) { |
| 613 | chan_list[j] = (uint8_t)ch; |
| 614 | j++; |
| 615 | } |
| 616 | } |
| 617 | *chan_num = j; |
| 618 | qdf_mem_free(cur_chan_list); |
| 619 | return 0; |
| 620 | } |
| 621 | |
| 622 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 623 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 624 | * @adapter: HDD adapter |
| 625 | * @chan_number: Channel number |
| 626 | * @chan_bw: Bandwidth |
| 627 | * |
| 628 | * Checks if the given bandwidth is valid for the given channel number. |
| 629 | * |
| 630 | * Return: 0 for success, non-zero for failure |
| 631 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 632 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 633 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 634 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 635 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 636 | uint8_t chan[NUM_CHANNELS]; |
| 637 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 638 | bool found = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 639 | mac_handle_t mac_handle; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 640 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 641 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 642 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 643 | if (!mac_handle) { |
| 644 | hdd_err("Invalid MAC handle"); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 645 | return -EINVAL; |
| 646 | } |
| 647 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 648 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 649 | &len); |
| 650 | if (ret) { |
| 651 | hdd_err("error %d in getting valid channel list", ret); |
| 652 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | for (i = 0; i < len; i++) { |
| 656 | if (chan[i] == chan_number) { |
| 657 | found = true; |
| 658 | break; |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | if (found == false) { |
| 663 | hdd_err("Channel not in driver's valid channel list"); |
| 664 | return -EOPNOTSUPP; |
| 665 | } |
| 666 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 667 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 668 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 669 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 670 | return -EINVAL; |
| 671 | } |
| 672 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 673 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 674 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 675 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 676 | return -EINVAL; |
| 677 | } |
| 678 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 679 | (chan_bw != CH_WIDTH_MAX)) { |
| 680 | hdd_err("Only BW20 possible on channel 14"); |
| 681 | return -EINVAL; |
| 682 | } |
| 683 | } |
| 684 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 685 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 686 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 687 | (chan_bw != CH_WIDTH_MAX)) { |
| 688 | hdd_err("Only BW20 possible on channel 165"); |
| 689 | return -EINVAL; |
| 690 | } |
| 691 | } |
| 692 | |
| 693 | return 0; |
| 694 | } |
| 695 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 696 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 697 | static inline struct net_device *hdd_net_dev_from_notifier(void *context) |
| 698 | { |
| 699 | struct netdev_notifier_info *info = context; |
| 700 | |
| 701 | return info->dev; |
| 702 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 703 | #else |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 704 | static inline struct net_device *hdd_net_dev_from_notifier(void *context) |
| 705 | { |
| 706 | return context; |
| 707 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 708 | #endif |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 709 | |
| 710 | static int __hdd_netdev_notifier_call(struct net_device *net_dev, |
| 711 | unsigned long state) |
| 712 | { |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 713 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 714 | struct hdd_context *hdd_ctx; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 715 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 716 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 717 | hdd_enter_dev(net_dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 718 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 719 | if (!net_dev->ieee80211_ptr) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 720 | hdd_debug("ieee80211_ptr is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 721 | return NOTIFY_DONE; |
| 722 | } |
| 723 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 724 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 725 | if (!hdd_ctx) { |
| 726 | hdd_err("HDD Context is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 727 | return NOTIFY_DONE; |
| 728 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 729 | |
| 730 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 731 | hdd_debug("%s: Driver module is closed", __func__); |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 732 | return NOTIFY_DONE; |
| 733 | } |
| 734 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 735 | /* Make sure that this callback corresponds to our device. */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 736 | adapter = hdd_get_adapter_by_iface_name(hdd_ctx, net_dev->name); |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 737 | if (!adapter) { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 738 | hdd_debug("failed to look up adapter for '%s'", net_dev->name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 739 | return NOTIFY_DONE; |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 740 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 741 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 742 | if (adapter != WLAN_HDD_GET_PRIV_PTR(net_dev)) { |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 743 | hdd_err("HDD adapter mismatch!"); |
| 744 | return NOTIFY_DONE; |
| 745 | } |
| 746 | |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 747 | if (cds_is_driver_recovering()) { |
| 748 | hdd_debug("Driver is recovering"); |
| 749 | return NOTIFY_DONE; |
| 750 | } |
| 751 | |
| 752 | if (cds_is_driver_in_bad_state()) { |
| 753 | hdd_debug("Driver is in failed recovery state"); |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 754 | return NOTIFY_DONE; |
| 755 | } |
| 756 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 757 | hdd_debug("%s New Net Device State = %lu", net_dev->name, state); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 758 | |
| 759 | switch (state) { |
| 760 | case NETDEV_REGISTER: |
| 761 | break; |
| 762 | |
| 763 | case NETDEV_UNREGISTER: |
| 764 | break; |
| 765 | |
| 766 | case NETDEV_UP: |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 767 | sme_ch_avoid_update_req(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 768 | break; |
| 769 | |
| 770 | case NETDEV_DOWN: |
| 771 | break; |
| 772 | |
| 773 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 774 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 775 | complete(&adapter->linkup_event_var); |
| 776 | break; |
| 777 | |
| 778 | case NETDEV_GOING_DOWN: |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 779 | vdev = hdd_objmgr_get_vdev(adapter); |
| 780 | if (!vdev) |
| 781 | break; |
| 782 | if (ucfg_scan_get_vdev_status(vdev) != |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 783 | SCAN_NOT_IN_PROGRESS) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 784 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 785 | adapter->vdev_id, INVALID_SCAN_ID, |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 786 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 787 | } |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 788 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 789 | cds_flush_work(&adapter->scan_block_work); |
| 790 | /* Need to clean up blocked scan request */ |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 791 | wlan_hdd_cfg80211_scan_block(adapter); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 792 | hdd_debug("Scan is not Pending from user"); |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 793 | /* |
| 794 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 795 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 796 | * flag after which driver does not send the cfg80211_scan_done. |
| 797 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 798 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 799 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, net_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 800 | break; |
| 801 | |
| 802 | default: |
| 803 | break; |
| 804 | } |
| 805 | |
| 806 | return NOTIFY_DONE; |
| 807 | } |
| 808 | |
| 809 | /** |
| 810 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 811 | * @nb: pointer to notifier block |
| 812 | * @state: state |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 813 | * @context: notifier callback context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 814 | * |
| 815 | * Return: 0 on success, error number otherwise. |
| 816 | */ |
| 817 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 818 | unsigned long state, |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 819 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 820 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 821 | struct net_device *net_dev = hdd_net_dev_from_notifier(context); |
| 822 | struct osif_vdev_sync *vdev_sync; |
| 823 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 824 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 825 | errno = osif_vdev_sync_op_start(net_dev, &vdev_sync); |
| 826 | if (errno) |
| 827 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 828 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 829 | errno = __hdd_netdev_notifier_call(net_dev, state); |
| 830 | |
| 831 | osif_vdev_sync_op_stop(vdev_sync); |
| 832 | |
| 833 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | struct notifier_block hdd_netdev_notifier = { |
| 837 | .notifier_call = hdd_netdev_notifier_call, |
| 838 | }; |
| 839 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 840 | static int system_reboot_notifier_call(struct notifier_block *nb, |
| 841 | unsigned long msg_type, void *_unused) |
| 842 | { |
| 843 | switch (msg_type) { |
| 844 | case SYS_DOWN: |
| 845 | case SYS_HALT: |
| 846 | case SYS_POWER_OFF: |
| 847 | g_is_system_reboot_triggered = true; |
| 848 | hdd_info("reboot, reason: %ld", msg_type); |
| 849 | break; |
| 850 | default: |
| 851 | break; |
| 852 | } |
| 853 | |
| 854 | return NOTIFY_OK; |
| 855 | } |
| 856 | |
| 857 | struct notifier_block system_reboot_notifier = { |
| 858 | .notifier_call = system_reboot_notifier_call, |
| 859 | }; |
| 860 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 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]: " |
| 1217 | MAC_ADDRESS_STR, |
| 1218 | MAC_ADDR_ARRAY(hdd_ctx-> |
| 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]: " |
| 1226 | MAC_ADDRESS_STR, |
| 1227 | MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[0].bytes)); |
| 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]: " |
| 1249 | MAC_ADDRESS_STR, i, |
| 1250 | MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes)); |
| 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; |
| 1285 | |
| 1286 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1287 | if (status != QDF_STATUS_SUCCESS) { |
| 1288 | hdd_err("failed pmo psoc configuration"); |
| 1289 | return -EINVAL; |
| 1290 | } |
| 1291 | |
| 1292 | hdd_ctx->tdls_umac_comp_active = true; |
| 1293 | /* enable napier specific tdls data path */ |
| 1294 | hdd_ctx->tdls_nap_active = true; |
| 1295 | |
| 1296 | return 0; |
| 1297 | } |
Jeff Johnson | 74c6bb2 | 2019-02-15 10:15:07 -0800 | [diff] [blame] | 1298 | #else |
| 1299 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1300 | { |
| 1301 | return 0; |
| 1302 | } |
| 1303 | #endif |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1304 | |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1305 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1306 | static void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1307 | struct wma_tgt_services *cfg) |
| 1308 | { |
| 1309 | bool roam_offload_enable; |
| 1310 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1311 | ucfg_mlme_get_roaming_offload(hdd_ctx->psoc, &roam_offload_enable); |
| 1312 | ucfg_mlme_set_roaming_offload(hdd_ctx->psoc, |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1313 | roam_offload_enable & |
| 1314 | cfg->en_roam_offload); |
| 1315 | } |
| 1316 | #else |
| 1317 | static inline void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1318 | struct wma_tgt_services *cfg) |
| 1319 | { |
| 1320 | } |
| 1321 | #endif |
| 1322 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1323 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1324 | struct wma_tgt_services *cfg) |
| 1325 | { |
| 1326 | struct hdd_config *config = hdd_ctx->config; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1327 | bool arp_offload_enable; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1328 | bool mawc_enabled; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1329 | #ifdef FEATURE_WLAN_TDLS |
| 1330 | bool tdls_support; |
| 1331 | bool tdls_off_channel; |
| 1332 | bool tdls_buffer_sta; |
| 1333 | uint32_t tdls_uapsd_mask; |
| 1334 | #endif |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1335 | bool value; |
| 1336 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1337 | /* Set up UAPSD */ |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 1338 | ucfg_mlme_set_sap_uapsd_flag(hdd_ctx->psoc, cfg->uapsd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1339 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1340 | /* 11AX mode support */ |
| 1341 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1342 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1343 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1344 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1345 | /* 11AC mode support */ |
| 1346 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1347 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1348 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1349 | |
| 1350 | /* ARP offload: override user setting if invalid */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1351 | arp_offload_enable = |
| 1352 | ucfg_pmo_is_arp_offload_enabled(hdd_ctx->psoc); |
| 1353 | ucfg_pmo_set_arp_offload_enabled(hdd_ctx->psoc, |
| 1354 | arp_offload_enable & cfg->arp_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1355 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1356 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1357 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1358 | if (cfg->pno_offload) |
Pragaspathi Thilagaraj | 24789d3 | 2018-12-10 22:28:03 +0530 | [diff] [blame] | 1359 | ucfg_scan_set_pno_offload(hdd_ctx->psoc, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1360 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1361 | #ifdef FEATURE_WLAN_TDLS |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1362 | cfg_tdls_get_support_enable(hdd_ctx->psoc, &tdls_support); |
| 1363 | cfg_tdls_set_support_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1364 | tdls_support & cfg->en_tdls); |
| 1365 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1366 | cfg_tdls_get_off_channel_enable(hdd_ctx->psoc, &tdls_off_channel); |
| 1367 | cfg_tdls_set_off_channel_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1368 | tdls_off_channel && |
| 1369 | cfg->en_tdls_offchan); |
| 1370 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1371 | cfg_tdls_get_buffer_sta_enable(hdd_ctx->psoc, &tdls_buffer_sta); |
| 1372 | cfg_tdls_set_buffer_sta_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1373 | tdls_buffer_sta && |
| 1374 | cfg->en_tdls_uapsd_buf_sta); |
| 1375 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1376 | cfg_tdls_get_uapsd_mask(hdd_ctx->psoc, &tdls_uapsd_mask); |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1377 | if (tdls_uapsd_mask && cfg->en_tdls_uapsd_sleep_sta) |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1378 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, true); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1379 | else |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1380 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1381 | #endif |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1382 | hdd_update_roam_offload(hdd_ctx, cfg); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1383 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 1384 | if (ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value) == |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1385 | QDF_STATUS_SUCCESS) |
| 1386 | value &= cfg->get_peer_info_enabled; |
| 1387 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1388 | ucfg_mlme_is_mawc_enabled(hdd_ctx->psoc, &mawc_enabled); |
| 1389 | ucfg_mlme_set_mawc_enabled(hdd_ctx->psoc, |
| 1390 | mawc_enabled & cfg->is_fw_mawc_capable); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1391 | hdd_update_tdls_config(hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1392 | sme_update_tgt_services(hdd_ctx->mac_handle, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1393 | } |
| 1394 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1395 | /** |
| 1396 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1397 | * @hdd_ctx: HDD context |
| 1398 | * |
| 1399 | * Sets the Nss per vdev type based on INI |
| 1400 | * |
| 1401 | * Return: None |
| 1402 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1403 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1404 | { |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1405 | uint8_t max_supp_nss = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1406 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1407 | QDF_STATUS status; |
| 1408 | bool bval; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1409 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1410 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1411 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1412 | hdd_err("unable to get vht_enable2x2"); |
| 1413 | |
| 1414 | if (bval && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1415 | max_supp_nss = 2; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1416 | |
| 1417 | hdd_debug("max nss %d", max_supp_nss); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1418 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1419 | mac_handle = hdd_ctx->mac_handle; |
| 1420 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1421 | NSS_CHAINS_BAND_2GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1422 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1423 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1424 | NSS_CHAINS_BAND_5GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1425 | } |
| 1426 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1427 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1428 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1429 | * @hdd_ctx: HDD context |
| 1430 | * |
| 1431 | * Updates wiphy vhtcap fields |
| 1432 | * |
| 1433 | * Return: None |
| 1434 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1435 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1436 | { |
| 1437 | struct ieee80211_supported_band *band_5g = |
| 1438 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1439 | QDF_STATUS status; |
| 1440 | uint8_t value = 0, value1 = 0; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1441 | |
| 1442 | if (!band_5g) { |
| 1443 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1444 | return; |
| 1445 | } |
| 1446 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1447 | status = ucfg_mlme_cfg_get_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 1448 | &value); |
| 1449 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1450 | hdd_err("unable to get tx_bfee_ant_supp"); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1451 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1452 | band_5g->vht_cap.cap |= |
| 1453 | (value << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1454 | |
| 1455 | value1 = NUM_OF_SOUNDING_DIMENSIONS; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1456 | band_5g->vht_cap.cap |= |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1457 | (value1 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1458 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 1459 | hdd_debug("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1460 | band_5g->vht_cap.cap, value, value1); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1461 | } |
| 1462 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1463 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1464 | struct wma_tgt_ht_cap *cfg) |
| 1465 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1466 | QDF_STATUS status; |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1467 | qdf_size_t value_len; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1468 | uint32_t value; |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1469 | uint8_t mpdu_density; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1470 | struct mlme_ht_capabilities_info ht_cap_info; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1471 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1472 | bool b_enable1x1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1473 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1474 | /* get the MPDU density */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1475 | status = ucfg_mlme_get_ht_mpdu_density(hdd_ctx->psoc, &mpdu_density); |
| 1476 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1477 | hdd_err("could not get HT MPDU Density"); |
| 1478 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1479 | } |
| 1480 | |
| 1481 | /* |
| 1482 | * MPDU density: |
| 1483 | * override user's setting if value is larger |
| 1484 | * than the one supported by target |
| 1485 | */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1486 | if (mpdu_density > cfg->mpdu_density) { |
| 1487 | status = ucfg_mlme_set_ht_mpdu_density(hdd_ctx->psoc, |
| 1488 | cfg->mpdu_density); |
| 1489 | if (QDF_IS_STATUS_ERROR(status)) |
| 1490 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1491 | } |
| 1492 | |
| 1493 | /* get the HT capability info */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1494 | 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] | 1495 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1496 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1497 | return; |
| 1498 | } |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1499 | |
| 1500 | /* check and update RX STBC */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1501 | if (ht_cap_info.rx_stbc && !cfg->ht_rx_stbc) |
| 1502 | ht_cap_info.rx_stbc = cfg->ht_rx_stbc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1503 | |
| 1504 | /* Set the LDPC capability */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1505 | ht_cap_info.adv_coding_cap = cfg->ht_rx_ldpc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1506 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1507 | if (ht_cap_info.short_gi_20_mhz && !cfg->ht_sgi_20) |
| 1508 | ht_cap_info.short_gi_20_mhz = cfg->ht_sgi_20; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1509 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1510 | if (ht_cap_info.short_gi_40_mhz && !cfg->ht_sgi_40) |
| 1511 | ht_cap_info.short_gi_40_mhz = cfg->ht_sgi_40; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1512 | |
| 1513 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1514 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1515 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1516 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &b_enable1x1); |
| 1517 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1518 | hdd_err("unable to get vht_enable2x2"); |
| 1519 | |
| 1520 | b_enable1x1 = b_enable1x1 && (cfg->num_rf_chains == 2); |
| 1521 | |
| 1522 | status = ucfg_mlme_set_vht_enable2x2(hdd_ctx->psoc, b_enable1x1); |
| 1523 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1524 | hdd_err("unable to set vht_enable2x2"); |
| 1525 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1526 | if (!b_enable1x1) { |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1527 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1528 | |
| 1529 | /* 1x1 */ |
| 1530 | /* Update Rx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1531 | status = ucfg_mlme_cfg_set_vht_rx_supp_data_rate( |
| 1532 | hdd_ctx->psoc, |
| 1533 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1534 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1535 | hdd_err("Failed to set rx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1536 | /* Update Tx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1537 | status = ucfg_mlme_cfg_set_vht_tx_supp_data_rate( |
| 1538 | hdd_ctx->psoc, |
| 1539 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1540 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1541 | hdd_err("Failed to set tx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1542 | } |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1543 | if (!(cfg->ht_tx_stbc && b_enable1x1)) |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1544 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1545 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1546 | 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] | 1547 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1548 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1549 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1550 | value_len = SIZE_OF_SUPPORTED_MCS_SET; |
| 1551 | if (ucfg_mlme_get_supported_mcs_set( |
| 1552 | hdd_ctx->psoc, mcs_set, |
| 1553 | &value_len) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1554 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1555 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1556 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1557 | |
| 1558 | if (b_enable1x1) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1559 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1560 | mcs_set[value] = |
| 1561 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1562 | |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1563 | status = ucfg_mlme_set_supported_mcs_set( |
| 1564 | hdd_ctx->psoc, |
| 1565 | mcs_set, |
| 1566 | (qdf_size_t)SIZE_OF_SUPPORTED_MCS_SET); |
| 1567 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1568 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1569 | } |
| 1570 | } |
| 1571 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1572 | } |
| 1573 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1574 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1575 | struct wma_tgt_vht_cap *cfg) |
| 1576 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1577 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1578 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1579 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1580 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1581 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1582 | struct wma_caps_per_phy caps_per_phy; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1583 | uint8_t val = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1584 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1585 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1586 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1587 | return; |
| 1588 | } |
| 1589 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1590 | status = ucfg_mlme_update_vht_cap(hdd_ctx->psoc, cfg); |
| 1591 | if (QDF_IS_STATUS_ERROR(status)) |
| 1592 | hdd_err("could not update vht capabilities"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1593 | |
| 1594 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1595 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1596 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1597 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1598 | else |
| 1599 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1600 | |
| 1601 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1602 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1603 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1604 | VHT_CAP_160_AND_80P80_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1605 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1606 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1607 | band_5g->vht_cap.cap |= |
| 1608 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1609 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1610 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1611 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1612 | VHT_CAP_160_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1613 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1614 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1615 | band_5g->vht_cap.cap |= |
| 1616 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1617 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1618 | } |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1619 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1620 | status = |
| 1621 | ucfg_mlme_cfg_get_vht_chan_width(hdd_ctx->psoc, &val); |
| 1622 | if (QDF_IS_STATUS_ERROR(status)) |
| 1623 | hdd_err("could not get channel_width"); |
| 1624 | |
| 1625 | val = QDF_MIN(val, ch_width); |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1626 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, val); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1627 | if (QDF_IS_STATUS_ERROR(status)) |
| 1628 | hdd_err("could not set the channel width"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1629 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1630 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1631 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1632 | hdd_debug("VHT RxLDPC capability is set"); |
| 1633 | } else { |
| 1634 | /* |
| 1635 | * Get the RX LDPC capability for the NON DBS |
| 1636 | * hardware mode for 5G band |
| 1637 | */ |
| 1638 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1639 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1640 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1641 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1642 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1643 | hdd_debug("VHT RX LDPC capability is set"); |
| 1644 | } |
| 1645 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1646 | |
| 1647 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1648 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1649 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1650 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1651 | |
| 1652 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1653 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1654 | |
| 1655 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1656 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1657 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1658 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1659 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1660 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1661 | |
| 1662 | band_5g->vht_cap.cap |= |
| 1663 | (cfg->vht_max_ampdu_len_exp << |
| 1664 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1665 | |
| 1666 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1667 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1668 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1669 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1670 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1671 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1672 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1673 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1674 | |
| 1675 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1676 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1677 | |
| 1678 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1679 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1680 | /** |
| 1681 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1682 | * @hdd_ctx: Pointer to the HDD context |
| 1683 | * |
| 1684 | * Auto-generate mac address using device serial number. |
| 1685 | * Keep the first 3 bytes of OUI as before and replace |
| 1686 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1687 | * |
| 1688 | * Return: 0 for success |
| 1689 | * Non zero failure code for errors |
| 1690 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1691 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1692 | { |
| 1693 | unsigned int serialno = 0; |
| 1694 | struct qdf_mac_addr mac_addr = { |
| 1695 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1696 | }; |
| 1697 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1698 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1699 | if (serialno == 0) |
| 1700 | return -EINVAL; |
| 1701 | |
| 1702 | serialno &= 0x00ffffff; |
| 1703 | |
| 1704 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1705 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1706 | mac_addr.bytes[5] = serialno & 0xff; |
| 1707 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1708 | hdd_update_macaddr(hdd_ctx, mac_addr, true); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1709 | return 0; |
| 1710 | } |
| 1711 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1712 | static void hdd_sar_target_config(struct hdd_context *hdd_ctx, |
| 1713 | struct wma_tgt_cfg *cfg) |
| 1714 | { |
| 1715 | hdd_ctx->sar_version = cfg->sar_version; |
| 1716 | } |
| 1717 | |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1718 | static void hdd_update_vhtcap_2g(struct hdd_context *hdd_ctx) |
| 1719 | { |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1720 | uint32_t chip_mode = 0; |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1721 | QDF_STATUS status; |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1722 | bool b2g_vht_cfg = false; |
| 1723 | bool b2g_vht_target = false; |
| 1724 | struct wma_caps_per_phy caps_per_phy; |
| 1725 | struct wmi_unified *wmi_handle; |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1726 | |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1727 | wmi_handle = get_wmi_unified_hdl_from_psoc(hdd_ctx->psoc); |
| 1728 | if (!wmi_handle) { |
| 1729 | hdd_err("wmi handle is NULL"); |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1730 | return; |
| 1731 | } |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1732 | |
| 1733 | 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] | 1734 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1735 | hdd_err("Failed to get 2g vht mode"); |
| 1736 | return; |
| 1737 | } |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1738 | if (wmi_service_enabled(wmi_handle, wmi_service_ext_msg)) { |
| 1739 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1740 | HW_MODE_DBS_NONE, |
| 1741 | CDS_BAND_ALL); |
| 1742 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1743 | hdd_err("Failed to get phy caps"); |
| 1744 | return; |
| 1745 | } |
| 1746 | if (caps_per_phy.vht_2g) |
| 1747 | b2g_vht_target = true; |
| 1748 | } else { |
| 1749 | status = wlan_reg_get_chip_mode(hdd_ctx->pdev, &chip_mode); |
| 1750 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1751 | hdd_err("Failed to get chip mode"); |
| 1752 | return; |
| 1753 | } |
| 1754 | b2g_vht_target = |
| 1755 | (chip_mode & WMI_HOST_REGDMN_MODE_11AC_VHT20_2G) ? |
| 1756 | true : false; |
| 1757 | } |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1758 | |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1759 | b2g_vht_cfg = b2g_vht_cfg && b2g_vht_target; |
| 1760 | hdd_debug("vht 2g target: %d, cfg: %d", b2g_vht_target, b2g_vht_cfg); |
| 1761 | 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] | 1762 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1763 | hdd_err("Failed to update 2g vht mode"); |
| 1764 | return; |
| 1765 | } |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1766 | } |
| 1767 | |
Jeff Johnson | 8abc593 | 2018-06-02 22:51:37 -0700 | [diff] [blame] | 1768 | void hdd_update_tgt_cfg(hdd_handle_t hdd_handle, struct wma_tgt_cfg *cfg) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1769 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1770 | int ret; |
Jeff Johnson | ea70b94 | 2018-07-02 09:42:31 -0700 | [diff] [blame] | 1771 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1772 | uint8_t temp_band_cap, band_capability; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1773 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1774 | uint8_t antenna_mode; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1775 | uint8_t sub_20_chan_width; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1776 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1777 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1778 | bool bval = false; |
| 1779 | uint8_t value = 0; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1780 | uint32_t fine_time_meas_cap = 0; |
gaurank kathpalia | fa7ad0a | 2019-03-12 19:17:56 +0530 | [diff] [blame] | 1781 | enum nss_chains_band_info band; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1782 | |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1783 | if (!hdd_ctx) { |
| 1784 | hdd_err("HDD context is NULL"); |
| 1785 | return; |
| 1786 | } |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1787 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1788 | if (ret) { |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1789 | QDF_DEBUG_PANIC("Failed to create pdev; errno:%d", ret); |
| 1790 | return; |
| 1791 | } |
| 1792 | |
| 1793 | hdd_debug("New pdev has been created with pdev_id = %u", |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1794 | hdd_ctx->pdev->pdev_objmgr.wlan_pdev_id); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1795 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1796 | status = dispatcher_pdev_open(hdd_ctx->pdev); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1797 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1798 | QDF_DEBUG_PANIC("dispatcher pdev open failed; status:%d", |
| 1799 | status); |
| 1800 | return; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1801 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1802 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 1803 | status = hdd_component_pdev_open(hdd_ctx->pdev); |
| 1804 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1805 | QDF_DEBUG_PANIC("hdd component pdev open failed; status:%d", |
| 1806 | status); |
| 1807 | return; |
| 1808 | } |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1809 | cdp_pdev_set_ctrl_pdev(cds_get_context(QDF_MODULE_ID_SOC), |
| 1810 | cds_get_context(QDF_MODULE_ID_TXRX), |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1811 | (struct cdp_ctrl_objmgr_pdev *)hdd_ctx->pdev); |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1812 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1813 | wlan_pdev_set_dp_handle(hdd_ctx->pdev, |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1814 | cds_get_context(QDF_MODULE_ID_TXRX)); |
| 1815 | |
Will Huang | 0724417 | 2018-05-14 14:23:30 +0800 | [diff] [blame] | 1816 | hdd_objmgr_update_tgt_max_vdev_psoc(hdd_ctx, cfg->max_intf_count); |
| 1817 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1818 | ucfg_ipa_set_dp_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1819 | cds_get_context(QDF_MODULE_ID_SOC)); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1820 | ucfg_ipa_set_txrx_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1821 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1822 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1823 | hdd_softap_hard_start_xmit); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1824 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1825 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1826 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1827 | status = ucfg_mlme_get_sub_20_chan_width(hdd_ctx->psoc, |
| 1828 | &sub_20_chan_width); |
| 1829 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1830 | hdd_err("Failed to get sub_20_chan_width config"); |
| 1831 | return; |
| 1832 | } |
| 1833 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1834 | if (cds_cfg) { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1835 | if (sub_20_chan_width != |
| 1836 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1837 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1838 | cds_cfg->sub_20_channel_width = |
| 1839 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1840 | } else { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1841 | cds_cfg->sub_20_channel_width = sub_20_chan_width; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1842 | } |
| 1843 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1844 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1845 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 1846 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1847 | hdd_err("Failed to get MLME band capability"); |
| 1848 | return; |
| 1849 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1850 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1851 | /* first store the INI band capability */ |
| 1852 | temp_band_cap = band_capability; |
| 1853 | |
| 1854 | band_capability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1855 | hdd_ctx->is_fils_roaming_supported = |
| 1856 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1857 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1858 | hdd_ctx->config->is_11k_offload_supported = |
| 1859 | cfg->services.is_11k_offload_supported; |
| 1860 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1861 | /* |
| 1862 | * now overwrite the target band capability with INI |
| 1863 | * setting if INI setting is a subset |
| 1864 | */ |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1865 | if ((band_capability == BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1866 | (temp_band_cap != BAND_ALL)) |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1867 | band_capability = temp_band_cap; |
| 1868 | else if ((band_capability != BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1869 | (temp_band_cap != BAND_ALL) && |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1870 | (band_capability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1871 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1872 | } |
| 1873 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1874 | status = ucfg_mlme_set_band_capability(hdd_ctx->psoc, band_capability); |
| 1875 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1876 | hdd_err("Failed to set MLME Band Capability"); |
| 1877 | return; |
| 1878 | } |
| 1879 | |
| 1880 | hdd_ctx->curr_band = band_capability; |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1881 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1882 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1883 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1884 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1885 | } |
| 1886 | |
| 1887 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1888 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1889 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) |
| 1890 | qdf_mem_copy(&hdd_ctx->hw_macaddr, &cfg->hw_macaddr, |
| 1891 | QDF_MAC_ADDR_SIZE); |
| 1892 | else |
| 1893 | hdd_info("hw_mac is zero"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1894 | |
| 1895 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1896 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1897 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 1898 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 1899 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 1900 | sizeof(cfg->hw_bd_info)); |
| 1901 | |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 1902 | if (cfg->max_intf_count > WLAN_MAX_VDEVS) { |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 1903 | hdd_err("fw max vdevs (%u) > host max vdevs (%u); using %u", |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 1904 | cfg->max_intf_count, WLAN_MAX_VDEVS, WLAN_MAX_VDEVS); |
| 1905 | hdd_ctx->max_intf_count = WLAN_MAX_VDEVS; |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 1906 | } else { |
| 1907 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1908 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1909 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1910 | hdd_sar_target_config(hdd_ctx, cfg); |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1911 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1912 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1913 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1914 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1915 | |
| 1916 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1917 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1918 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1919 | if (cfg->services.en_11ax) { |
| 1920 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1921 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1922 | } |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 1923 | hdd_update_tgt_twt_cap(hdd_ctx, cfg); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1924 | |
gaurank kathpalia | fa7ad0a | 2019-03-12 19:17:56 +0530 | [diff] [blame] | 1925 | for (band = NSS_CHAINS_BAND_2GHZ; band < NSS_CHAINS_BAND_MAX; band++) { |
| 1926 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1927 | QDF_STA_MODE, band); |
| 1928 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1929 | QDF_SAP_MODE, band); |
| 1930 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1931 | QDF_TDLS_MODE, band); |
| 1932 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1933 | QDF_P2P_DEVICE_MODE, |
| 1934 | band); |
| 1935 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1936 | QDF_OCB_MODE, band); |
| 1937 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1938 | QDF_TDLS_MODE, band); |
| 1939 | } |
| 1940 | |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1941 | hdd_update_vdev_nss(hdd_ctx); |
| 1942 | |
gaurank kathpalia | 5fcefa9 | 2018-10-24 15:03:15 +0530 | [diff] [blame] | 1943 | hdd_ctx->dynamic_nss_chains_support = |
| 1944 | cfg->dynamic_nss_chains_support; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1945 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, &fine_time_meas_cap); |
| 1946 | fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
| 1947 | status = ucfg_mlme_set_fine_time_meas_cap(hdd_ctx->psoc, |
| 1948 | fine_time_meas_cap); |
| 1949 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1950 | hdd_err("failed to set fine_time_meas_cap, 0x%x, ox%x", |
| 1951 | fine_time_meas_cap, cfg->fine_time_measurement_cap); |
| 1952 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 1953 | &fine_time_meas_cap); |
| 1954 | } |
| 1955 | |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1956 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1957 | hdd_debug("fine_time_meas_cap: 0x%x", fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1958 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1959 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1960 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1961 | hdd_err("unable to get vht_enable2x2"); |
| 1962 | |
| 1963 | antenna_mode = (bval == 0x01) ? |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1964 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1965 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1966 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1967 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1968 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1969 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1970 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1971 | 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] | 1972 | &value); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1973 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1974 | status = false; |
| 1975 | hdd_err("set tx_bfee_ant_supp failed"); |
| 1976 | } |
| 1977 | |
| 1978 | if ((value > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1979 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1980 | !cfg->tx_bfee_8ss_enabled) { |
| 1981 | status = |
| 1982 | ucfg_mlme_cfg_set_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 1983 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF); |
| 1984 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1985 | status = false; |
| 1986 | hdd_err("set tx_bfee_ant_supp failed"); |
| 1987 | } |
| 1988 | } |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1989 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1990 | mac_handle = hdd_ctx->mac_handle; |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1991 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1992 | hdd_debug("txBFCsnValue %d", value); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1993 | |
| 1994 | /* |
| 1995 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 1996 | */ |
| 1997 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 1998 | |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1999 | hdd_update_vhtcap_2g(hdd_ctx); |
| 2000 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2001 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2002 | |
Ashish Kumar Dhanotiya | 908925d | 2019-03-01 17:35:30 +0530 | [diff] [blame] | 2003 | 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] | 2004 | /* |
| 2005 | * This needs to be done after HDD pdev is created and stored since |
| 2006 | * it will access the HDD pdev object lock. |
| 2007 | */ |
| 2008 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2009 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2010 | /* Configure NAN datapath features */ |
| 2011 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Nachiket Kukade | 85aa378 | 2018-11-02 20:12:34 +0530 | [diff] [blame] | 2012 | ucfg_nan_set_tgt_caps(hdd_ctx->psoc, &cfg->nan_caps); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2013 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2014 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 2015 | hdd_ctx->obss_scan_offload = cfg->services.obss_scan_offload; |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 2016 | status = ucfg_mlme_set_obss_detection_offload_enabled( |
| 2017 | hdd_ctx->psoc, cfg->obss_detection_offloaded); |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2018 | if (QDF_IS_STATUS_ERROR(status)) |
| 2019 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2020 | |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 2021 | status = ucfg_mlme_set_obss_color_collision_offload_enabled( |
| 2022 | hdd_ctx->psoc, cfg->obss_color_collision_offloaded); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2023 | if (QDF_IS_STATUS_ERROR(status)) |
| 2024 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2025 | } |
| 2026 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2027 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2028 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2029 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2030 | struct hdd_ap_ctx *ap_ctx; |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2031 | bool dfs_disable_channel_switch = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2032 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2033 | if (!hdd_ctx) { |
| 2034 | hdd_info("Couldn't get hdd_ctx"); |
| 2035 | return true; |
| 2036 | } |
| 2037 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2038 | ucfg_mlme_get_dfs_disable_channel_switch(hdd_ctx->psoc, |
| 2039 | &dfs_disable_channel_switch); |
| 2040 | if (dfs_disable_channel_switch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2041 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2042 | hdd_ctx, dfs_disable_channel_switch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2043 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2044 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2045 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2046 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2047 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2048 | |
| 2049 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2050 | QDF_P2P_GO_MODE == adapter->device_mode) && |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2051 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2052 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2053 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2054 | true; |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 2055 | hdd_info("tx blocked for vdev: %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2056 | adapter->vdev_id); |
bings | 6fb9bf6 | 2018-07-05 14:01:53 +0800 | [diff] [blame] | 2057 | if (adapter->txrx_vdev) |
| 2058 | cdp_fc_vdev_flush( |
| 2059 | cds_get_context(QDF_MODULE_ID_SOC), |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2060 | adapter->txrx_vdev); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2061 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2062 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2063 | |
| 2064 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2065 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2066 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2067 | bool hdd_is_valid_mac_address(const uint8_t *mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2068 | { |
| 2069 | int xdigit = 0; |
| 2070 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2071 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2072 | while (*mac_addr) { |
| 2073 | if (isxdigit(*mac_addr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2074 | xdigit++; |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2075 | } else if (':' == *mac_addr) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2076 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2077 | break; |
| 2078 | |
| 2079 | ++separator; |
| 2080 | } else { |
| 2081 | /* Invalid MAC found */ |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2082 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2083 | } |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2084 | ++mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2085 | } |
| 2086 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2087 | } |
| 2088 | |
| 2089 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2090 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2091 | * @dev: Handle to struct net_device to be updated. |
| 2092 | * |
| 2093 | * Return: None |
| 2094 | */ |
| 2095 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2096 | { |
| 2097 | dev->header_ops = NULL; |
| 2098 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2099 | dev->hard_header_len = ETH_HLEN; |
| 2100 | dev->mtu = ETH_DATA_LEN; |
| 2101 | dev->addr_len = ETH_ALEN; |
| 2102 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2103 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2104 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2105 | |
| 2106 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2107 | } |
| 2108 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2109 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2110 | /** |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2111 | * hdd_mon_turn_off_ps_and_wow() - Update monitor mode struct net_device. |
| 2112 | * @hdd_ctx: Pointer to HDD context. |
| 2113 | * |
| 2114 | * Return: None |
| 2115 | */ |
| 2116 | static void hdd_mon_turn_off_ps_and_wow(struct hdd_context *hdd_ctx) |
| 2117 | { |
| 2118 | ucfg_pmo_set_power_save_mode(hdd_ctx->psoc, PS_NOT_SUPPORTED); |
| 2119 | ucfg_pmo_set_wow_enable(hdd_ctx->psoc, PMO_WOW_DISABLE_BOTH); |
| 2120 | } |
| 2121 | |
| 2122 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2123 | * __hdd__mon_open() - HDD Open function |
| 2124 | * @dev: Pointer to net_device structure |
| 2125 | * |
| 2126 | * This is called in response to ifconfig up |
| 2127 | * |
| 2128 | * Return: 0 for success; non-zero for failure |
| 2129 | */ |
| 2130 | static int __hdd_mon_open(struct net_device *dev) |
| 2131 | { |
| 2132 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2133 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2134 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2135 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2136 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2137 | |
| 2138 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2139 | if (ret) |
| 2140 | return ret; |
| 2141 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2142 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2143 | |
| 2144 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 2145 | ret = hdd_psoc_idle_restart(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2146 | if (ret) { |
| 2147 | hdd_err("Failed to start WLAN modules return"); |
| 2148 | return ret; |
| 2149 | } |
| 2150 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2151 | |
| 2152 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2153 | ret = hdd_start_adapter(adapter); |
| 2154 | if (ret) { |
| 2155 | hdd_err("Failed to start adapter :%d", |
| 2156 | adapter->device_mode); |
| 2157 | return ret; |
| 2158 | } |
| 2159 | hdd_err("hdd_start_adapters() successful !"); |
| 2160 | } |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2161 | hdd_mon_turn_off_ps_and_wow(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2162 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2163 | } |
| 2164 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2165 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2166 | |
| 2167 | if (!ret) |
| 2168 | ret = hdd_enable_monitor_mode(dev); |
| 2169 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2170 | return ret; |
| 2171 | } |
| 2172 | |
| 2173 | /** |
| 2174 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2175 | * @dev: Pointer to net_device structure |
| 2176 | * |
| 2177 | * This is called in response to ifconfig up |
| 2178 | * |
| 2179 | * Return: 0 for success; non-zero for failure |
| 2180 | */ |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2181 | static int hdd_mon_open(struct net_device *net_dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2182 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2183 | int errno; |
| 2184 | struct osif_vdev_sync *vdev_sync; |
| 2185 | |
| 2186 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 2187 | if (errno) |
| 2188 | return errno; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2189 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2190 | errno = __hdd_mon_open(net_dev); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2191 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2192 | osif_vdev_sync_trans_stop(vdev_sync); |
| 2193 | |
| 2194 | return errno; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2195 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2196 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2197 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2198 | static QDF_STATUS |
| 2199 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2200 | { |
| 2201 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2202 | QDF_STATUS status; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2203 | uint32_t chnl_sel_logic_conc = 0; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2204 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2205 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2206 | |
| 2207 | if (!hdd_ctx) { |
| 2208 | hdd_err("HDD context is NULL"); |
| 2209 | return QDF_STATUS_E_FAILURE; |
| 2210 | } |
| 2211 | |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2212 | /* |
| 2213 | * ROME platform doesn't support any DBS related commands in FW, |
| 2214 | * so if driver sends wmi command with dual_mac_config with all set to |
| 2215 | * 0 then FW wouldn't respond back and driver would timeout on waiting |
| 2216 | * for response. Check if FW supports DBS to eliminate ROME vs |
| 2217 | * NON-ROME platform. |
| 2218 | */ |
| 2219 | if (!policy_mgr_find_if_fw_supports_dbs(hdd_ctx->psoc)) |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2220 | return QDF_STATUS_SUCCESS; |
| 2221 | |
| 2222 | cfg.scan_config = 0; |
| 2223 | cfg.fw_mode_config = 0; |
| 2224 | 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] | 2225 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc)) { |
| 2226 | status = |
| 2227 | ucfg_policy_mgr_get_chnl_select_plcy(hdd_ctx->psoc, |
| 2228 | &chnl_sel_logic_conc); |
| 2229 | if (status != QDF_STATUS_SUCCESS) { |
| 2230 | hdd_err("can't get chnl sel policy, use def"); |
| 2231 | return status; |
| 2232 | } |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2233 | } |
| 2234 | status = |
| 2235 | ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 2236 | &dual_mac_feature); |
| 2237 | if (status != QDF_STATUS_SUCCESS) { |
| 2238 | hdd_err("ucfg_policy_mgr_get_dual_mac_feature failed, use def"); |
| 2239 | return status; |
| 2240 | } |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2241 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2242 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2243 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2244 | hdd_ctx->psoc, &cfg.scan_config, |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2245 | &cfg.fw_mode_config, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2246 | dual_mac_feature, |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2247 | chnl_sel_logic_conc); |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2248 | |
| 2249 | if (status != QDF_STATUS_SUCCESS) { |
| 2250 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2251 | status); |
| 2252 | return status; |
| 2253 | } |
| 2254 | } |
| 2255 | |
| 2256 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2257 | cfg.scan_config, cfg.fw_mode_config); |
| 2258 | |
| 2259 | status = sme_soc_set_dual_mac_config(cfg); |
| 2260 | if (status != QDF_STATUS_SUCCESS) { |
| 2261 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2262 | return status; |
| 2263 | } |
| 2264 | |
| 2265 | return QDF_STATUS_SUCCESS; |
| 2266 | } |
| 2267 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2268 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2269 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2270 | * @adapter: pointer to HDD adapter |
| 2271 | * |
| 2272 | * This function is called to start the device specific adapter for |
| 2273 | * the mode passed in the adapter's device_mode. |
| 2274 | * |
| 2275 | * Return: 0 for success; non-zero for failure |
| 2276 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2277 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2278 | { |
| 2279 | |
| 2280 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2281 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2282 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2283 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2284 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2285 | |
| 2286 | switch (device_mode) { |
| 2287 | case QDF_P2P_CLIENT_MODE: |
| 2288 | case QDF_P2P_DEVICE_MODE: |
| 2289 | case QDF_OCB_MODE: |
| 2290 | case QDF_STA_MODE: |
| 2291 | case QDF_MONITOR_MODE: |
| 2292 | ret = hdd_start_station_adapter(adapter); |
| 2293 | if (ret) |
| 2294 | goto err_start_adapter; |
Alok Kumar | 81e1d73 | 2018-09-04 11:10:36 +0530 | [diff] [blame] | 2295 | |
| 2296 | hdd_nud_ignore_tracking(adapter, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2297 | break; |
| 2298 | case QDF_P2P_GO_MODE: |
| 2299 | case QDF_SAP_MODE: |
| 2300 | ret = hdd_start_ap_adapter(adapter); |
| 2301 | if (ret) |
| 2302 | goto err_start_adapter; |
| 2303 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2304 | case QDF_IBSS_MODE: |
| 2305 | /* |
| 2306 | * For IBSS interface is initialized as part of |
| 2307 | * hdd_init_station_mode() |
| 2308 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2309 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2310 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2311 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2312 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2313 | default: |
| 2314 | hdd_err("Invalid session type %d", device_mode); |
| 2315 | QDF_ASSERT(0); |
| 2316 | goto err_start_adapter; |
| 2317 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2318 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2319 | if (hdd_set_fw_params(adapter)) |
| 2320 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2321 | |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 2322 | if (adapter->vdev_id != WLAN_UMAC_VDEV_ID_MAX) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2323 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2324 | if (ret < 0) { |
| 2325 | hdd_err("Failed to register frames - ret %d", ret); |
| 2326 | goto err_start_adapter; |
| 2327 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2328 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2329 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2330 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2331 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2332 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2333 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2334 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2335 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2336 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2337 | err_start_adapter: |
| 2338 | return -EINVAL; |
| 2339 | } |
| 2340 | |
| 2341 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2342 | * hdd_enable_power_management() - API to Enable Power Management |
| 2343 | * |
| 2344 | * API invokes Bus Interface Layer power management functionality |
| 2345 | * |
| 2346 | * Return: None |
| 2347 | */ |
| 2348 | static void hdd_enable_power_management(void) |
| 2349 | { |
| 2350 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2351 | |
| 2352 | if (!hif_ctx) { |
| 2353 | hdd_err("Bus Interface Context is Invalid"); |
| 2354 | return; |
| 2355 | } |
| 2356 | |
| 2357 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2358 | } |
| 2359 | |
| 2360 | /** |
| 2361 | * hdd_disable_power_management() - API to disable Power Management |
| 2362 | * |
| 2363 | * API disable Bus Interface Layer Power management functionality |
| 2364 | * |
| 2365 | * Return: None |
| 2366 | */ |
| 2367 | static void hdd_disable_power_management(void) |
| 2368 | { |
| 2369 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2370 | |
| 2371 | if (!hif_ctx) { |
| 2372 | hdd_err("Bus Interface Context is Invalid"); |
| 2373 | return; |
| 2374 | } |
| 2375 | |
| 2376 | hif_disable_power_management(hif_ctx); |
| 2377 | } |
| 2378 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2379 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2380 | { |
| 2381 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2382 | size_t target_hw_name_len; |
| 2383 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2384 | uint8_t *buf; |
| 2385 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2386 | |
| 2387 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2388 | if (!hif_sc) { |
| 2389 | hdd_err("HIF context is NULL"); |
| 2390 | return; |
| 2391 | } |
| 2392 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2393 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2394 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2395 | &target_hw_name); |
| 2396 | |
| 2397 | if (hdd_ctx->target_hw_name) |
| 2398 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2399 | |
| 2400 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2401 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2402 | if (hdd_ctx->target_hw_name) |
| 2403 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2404 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2405 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2406 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2407 | if (buf) { |
| 2408 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2409 | hdd_info("%s", buf); |
| 2410 | qdf_mem_free(buf); |
| 2411 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2412 | } |
| 2413 | |
| 2414 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2415 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2416 | * @hdd_ctx: Pointer to hdd context |
| 2417 | * |
| 2418 | * Return: none |
| 2419 | */ |
| 2420 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2421 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2422 | { |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2423 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM] = {0}; |
| 2424 | qdf_size_t out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2425 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2426 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2427 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2428 | if (!hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2429 | return; |
| 2430 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2431 | if (!hdd_ctx->config) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2432 | /* Do nothing if hdd_ctx is invalid */ |
| 2433 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2434 | return; |
| 2435 | } |
| 2436 | |
| 2437 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2438 | |
| 2439 | if (!cds_ctx) { |
| 2440 | hdd_err("Invalid CDS Context"); |
| 2441 | return; |
| 2442 | } |
| 2443 | |
| 2444 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2445 | switch (i) { |
| 2446 | case OL_TX_WMM_AC_BE: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2447 | qdf_uint8_array_parse( |
| 2448 | cfg_get(hdd_ctx->psoc, |
| 2449 | CFG_DP_ENABLE_TX_SCHED_WRR_BE), |
| 2450 | tx_sched_wrr_param, |
| 2451 | sizeof(tx_sched_wrr_param), |
| 2452 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2453 | break; |
| 2454 | case OL_TX_WMM_AC_BK: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2455 | qdf_uint8_array_parse( |
| 2456 | cfg_get(hdd_ctx->psoc, |
| 2457 | CFG_DP_ENABLE_TX_SCHED_WRR_BK), |
| 2458 | tx_sched_wrr_param, |
| 2459 | sizeof(tx_sched_wrr_param), |
| 2460 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2461 | break; |
| 2462 | case OL_TX_WMM_AC_VI: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2463 | qdf_uint8_array_parse( |
| 2464 | cfg_get(hdd_ctx->psoc, |
| 2465 | CFG_DP_ENABLE_TX_SCHED_WRR_VI), |
| 2466 | tx_sched_wrr_param, |
| 2467 | sizeof(tx_sched_wrr_param), |
| 2468 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2469 | break; |
| 2470 | case OL_TX_WMM_AC_VO: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2471 | qdf_uint8_array_parse( |
| 2472 | cfg_get(hdd_ctx->psoc, |
| 2473 | CFG_DP_ENABLE_TX_SCHED_WRR_VO), |
| 2474 | tx_sched_wrr_param, |
| 2475 | sizeof(tx_sched_wrr_param), |
| 2476 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2477 | break; |
| 2478 | default: |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2479 | break; |
| 2480 | } |
| 2481 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2482 | if (out_size == TX_SCHED_WRR_PARAMS_NUM) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2483 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2484 | tx_sched_wrr_param[0]; |
| 2485 | cds_ctx->ac_specs[i].credit_threshold = |
| 2486 | tx_sched_wrr_param[1]; |
| 2487 | cds_ctx->ac_specs[i].send_limit = |
| 2488 | tx_sched_wrr_param[2]; |
| 2489 | cds_ctx->ac_specs[i].credit_reserve = |
| 2490 | tx_sched_wrr_param[3]; |
| 2491 | cds_ctx->ac_specs[i].discard_weight = |
| 2492 | tx_sched_wrr_param[4]; |
| 2493 | } |
| 2494 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2495 | out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2496 | } |
| 2497 | } |
| 2498 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2499 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2500 | const size_t version_len, uint8_t *version) |
| 2501 | { |
| 2502 | uint32_t size; |
| 2503 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2504 | |
| 2505 | if (!hdd_ctx) { |
| 2506 | hdd_err("Invalid context, HDD context is null"); |
| 2507 | return 0; |
| 2508 | } |
| 2509 | |
Ashish Kumar Dhanotiya | 7353f88 | 2018-05-15 12:50:19 +0530 | [diff] [blame] | 2510 | if (!version || version_len == 0) { |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2511 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2512 | return 0; |
| 2513 | } |
| 2514 | |
| 2515 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2516 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2517 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2518 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2519 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2520 | |
| 2521 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2522 | "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] | 2523 | QWLAN_VERSIONSTR, |
| 2524 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2525 | hdd_ctx->target_hw_name, |
| 2526 | hdd_ctx->hw_bd_info.bdf_version, |
| 2527 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2528 | hdd_ctx->hw_bd_info.customer_id, |
| 2529 | hdd_ctx->hw_bd_info.project_id, |
| 2530 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2531 | |
| 2532 | return size; |
| 2533 | } |
| 2534 | |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2535 | int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, |
| 2536 | struct sap_config *sap_config) |
| 2537 | { |
| 2538 | uint8_t preamble = 0, nss = 0, rix = 0; |
| 2539 | int ret; |
| 2540 | mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle; |
| 2541 | |
| 2542 | if (!sap_config) { |
| 2543 | if (!sme_is_feature_supported_by_fw(DOT11AX)) { |
| 2544 | hdd_err("Target does not support 11ax"); |
| 2545 | return -EIO; |
| 2546 | } |
| 2547 | } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax && |
| 2548 | sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) { |
| 2549 | hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d", |
| 2550 | sap_config->SapHw_mode, sap_config->channel); |
| 2551 | return -EIO; |
| 2552 | } |
| 2553 | |
| 2554 | if (set_value != 0xff) { |
| 2555 | rix = RC_2_RATE_IDX_11AX(set_value); |
| 2556 | preamble = WMI_RATE_PREAMBLE_HE; |
| 2557 | nss = HT_RC_2_STREAMS_11AX(set_value); |
| 2558 | |
| 2559 | set_value = hdd_assemble_rate_code(preamble, nss, rix); |
| 2560 | } else { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2561 | ret = sme_set_auto_rate_he_ltf(mac_handle, adapter->vdev_id, |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2562 | QCA_WLAN_HE_LTF_AUTO); |
| 2563 | } |
| 2564 | |
| 2565 | hdd_info("SET_11AX_RATE val %d rix %d preamble %x nss %d", |
| 2566 | set_value, rix, preamble, nss); |
| 2567 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2568 | ret = wma_cli_set_command(adapter->vdev_id, |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2569 | WMI_VDEV_PARAM_FIXED_RATE, |
| 2570 | set_value, VDEV_CMD); |
| 2571 | |
| 2572 | return ret; |
| 2573 | } |
| 2574 | |
| 2575 | int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate) |
| 2576 | { |
| 2577 | int set_value; |
| 2578 | |
| 2579 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 2580 | set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble); |
| 2581 | else |
| 2582 | set_value = (preamble << 6) | (nss << 4) | rate; |
| 2583 | |
| 2584 | return set_value; |
| 2585 | } |
| 2586 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2587 | #ifdef FEATURE_WLAN_WAPI |
| 2588 | /** |
| 2589 | * hdd_wapi_security_sta_exist() - return wapi security sta exist or not |
| 2590 | * |
| 2591 | * This API returns the wapi security station exist or not |
| 2592 | * |
| 2593 | * Return: true - wapi security station exist |
| 2594 | */ |
| 2595 | static bool hdd_wapi_security_sta_exist(void) |
| 2596 | { |
| 2597 | struct hdd_adapter *adapter = NULL; |
| 2598 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2599 | |
| 2600 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2601 | if ((adapter->device_mode == QDF_STA_MODE) && |
| 2602 | adapter->wapi_info.wapi_mode && |
| 2603 | (adapter->wapi_info.wapi_auth_mode != WAPI_AUTH_MODE_OPEN)) |
| 2604 | return true; |
| 2605 | } |
| 2606 | return false; |
| 2607 | } |
| 2608 | #else |
| 2609 | static bool hdd_wapi_security_sta_exist(void) |
| 2610 | { |
| 2611 | return false; |
| 2612 | } |
| 2613 | #endif |
| 2614 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2615 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2616 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2617 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2618 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2619 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2620 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2621 | |
| 2622 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2623 | if (!adapter) { |
| 2624 | hdd_err("Adapter is NULL"); |
| 2625 | return PM_MAX_NUM_OF_MODE; |
| 2626 | } |
| 2627 | |
| 2628 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2629 | adapter->device_mode); |
| 2630 | } |
| 2631 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2632 | static void hdd_register_policy_manager_callback( |
| 2633 | struct wlan_objmgr_psoc *psoc) |
| 2634 | { |
| 2635 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2636 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2637 | qdf_mem_zero(&hdd_cbacks, sizeof(hdd_cbacks)); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2638 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2639 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2640 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2641 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2642 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2643 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2644 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2645 | hdd_cbacks.hdd_wapi_security_sta_exist = |
| 2646 | hdd_wapi_security_sta_exist; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2647 | if (QDF_STATUS_SUCCESS != |
| 2648 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2649 | hdd_err("HDD callback registration with policy manager failed"); |
| 2650 | } |
| 2651 | } |
| 2652 | #else |
| 2653 | static void hdd_register_policy_manager_callback( |
| 2654 | struct wlan_objmgr_psoc *psoc) |
| 2655 | { |
| 2656 | } |
| 2657 | #endif |
| 2658 | |
Nachiket Kukade | 2fb1fdb | 2019-01-08 15:35:27 +0530 | [diff] [blame] | 2659 | #ifdef WLAN_FEATURE_NAN |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2660 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2661 | { |
| 2662 | struct nan_callbacks cb_obj = {0}; |
| 2663 | |
| 2664 | cb_obj.ndi_open = hdd_ndi_open; |
| 2665 | cb_obj.ndi_close = hdd_ndi_close; |
| 2666 | cb_obj.ndi_start = hdd_ndi_start; |
| 2667 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2668 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2669 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2670 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2671 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2672 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2673 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2674 | os_if_nan_register_hdd_callbacks(hdd_ctx->psoc, &cb_obj); |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2675 | } |
jiad | ff1ac13 | 2018-11-26 16:27:48 +0800 | [diff] [blame] | 2676 | #else |
| 2677 | static inline void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
| 2678 | { |
| 2679 | } |
| 2680 | #endif |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2681 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2682 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2683 | /** |
| 2684 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2685 | * @hdd_ctx: the global HDD context |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2686 | * @is_ssr: true if SSR is in progress |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2687 | * |
| 2688 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2689 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2690 | * |
| 2691 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2692 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2693 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2694 | * fixed. |
| 2695 | * |
| 2696 | * Return: None |
| 2697 | */ |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2698 | 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] | 2699 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2700 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2701 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2702 | wlan_objmgr_psoc_check_for_peer_leaks(hdd_ctx->psoc); |
| 2703 | wlan_objmgr_psoc_check_for_vdev_leaks(hdd_ctx->psoc); |
| 2704 | wlan_objmgr_psoc_check_for_pdev_leaks(hdd_ctx->psoc); |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2705 | |
| 2706 | /* many adapter resources are not freed by design during SSR */ |
| 2707 | if (is_ssr) |
| 2708 | return; |
| 2709 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2710 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2711 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2712 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2713 | } |
| 2714 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2715 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2716 | #else |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2717 | static inline void hdd_check_for_leaks(struct hdd_context *hdd_ctx, bool is_ssr) |
| 2718 | { } |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2719 | |
| 2720 | #define hdd_debug_domain_set(domain) |
| 2721 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2722 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2723 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2724 | * hdd_update_country_code - Update country code |
| 2725 | * @hdd_ctx: HDD context |
| 2726 | * |
| 2727 | * Update country code based on module parameter country_code |
| 2728 | * |
| 2729 | * Return: 0 on success and errno on failure |
| 2730 | */ |
| 2731 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2732 | { |
| 2733 | if (!country_code) |
| 2734 | return 0; |
| 2735 | |
| 2736 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2737 | } |
| 2738 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2739 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2740 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2741 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2742 | qdf_device_t qdf_dev; |
| 2743 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2744 | bool unint = false; |
| 2745 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2746 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2747 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2748 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2749 | if (!qdf_dev) { |
| 2750 | hdd_err("QDF Device Context is Invalid return"); |
| 2751 | return -EINVAL; |
| 2752 | } |
| 2753 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 2754 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2755 | |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2756 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2757 | hdd_debug("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2758 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2759 | return 0; |
| 2760 | } |
| 2761 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2762 | switch (hdd_ctx->driver_status) { |
| 2763 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2764 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2765 | unint = true; |
| 2766 | /* Fall through dont add break here */ |
| 2767 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2768 | hdd_info("Wlan transitioning (CLOSED -> ENABLED)"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2769 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2770 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2771 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2772 | if (!reinit && !unint) { |
| 2773 | ret = pld_power_on(qdf_dev->dev); |
| 2774 | if (ret) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2775 | hdd_err("Failed to power up device; errno:%d", |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2776 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2777 | goto release_lock; |
| 2778 | } |
| 2779 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2780 | |
| 2781 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2782 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2783 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2784 | qdf_dev->bus_type, |
| 2785 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2786 | HIF_ENABLE_TYPE_PROBE); |
| 2787 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2788 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2789 | goto power_down; |
| 2790 | } |
| 2791 | |
| 2792 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2793 | if (!hif_ctx) { |
| 2794 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2795 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2796 | goto power_down; |
| 2797 | } |
| 2798 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2799 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2800 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2801 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2802 | status); |
| 2803 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2804 | goto hif_close; |
| 2805 | } |
| 2806 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 2807 | if (hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) { |
| 2808 | status = epping_open(); |
| 2809 | if (status) { |
| 2810 | hdd_err("Failed to open in epping mode: %d", |
| 2811 | status); |
| 2812 | ret = -EINVAL; |
| 2813 | goto cds_free; |
| 2814 | } |
| 2815 | |
| 2816 | status = epping_enable(qdf_dev->dev, false); |
| 2817 | if (status) { |
| 2818 | hdd_err("Failed to enable in epping mode : %d", |
| 2819 | status); |
| 2820 | epping_close(); |
| 2821 | goto cds_free; |
| 2822 | } |
| 2823 | |
| 2824 | hdd_info("epping mode enabled"); |
| 2825 | break; |
| 2826 | } |
| 2827 | |
jitiphil | 4c256a3 | 2018-09-07 08:51:52 +0530 | [diff] [blame] | 2828 | ucfg_ipa_component_config_update(hdd_ctx->psoc); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2829 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2830 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2831 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2832 | status = hdd_component_psoc_open(hdd_ctx->psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2833 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2834 | hdd_err("Failed to Open legacy components; status: %d", |
| 2835 | status); |
| 2836 | ret = qdf_status_to_os_return(status); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 2837 | goto cds_free; |
| 2838 | } |
| 2839 | |
| 2840 | ret = hdd_update_config(hdd_ctx); |
| 2841 | if (ret) { |
| 2842 | hdd_err("Failed to update configuration; errno: %d", |
| 2843 | ret); |
| 2844 | goto cds_free; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2845 | } |
| 2846 | |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 2847 | status = wbuff_module_init(); |
| 2848 | if (QDF_IS_STATUS_ERROR(status)) |
| 2849 | hdd_err("WBUFF init unsuccessful; status: %d", status); |
| 2850 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2851 | status = cds_open(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2852 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2853 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2854 | ret = qdf_status_to_os_return(status); |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 2855 | goto psoc_close; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2856 | } |
| 2857 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 2858 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 2859 | |
Manjunathappa Prakash | b6b4ff1 | 2018-06-04 12:32:33 -0700 | [diff] [blame] | 2860 | if (hdd_ctx->config->rx_thread_affinity_mask) |
| 2861 | cds_set_rx_thread_cpu_mask( |
| 2862 | hdd_ctx->config->rx_thread_affinity_mask); |
| 2863 | |
| 2864 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2865 | ret = hdd_update_components_config(hdd_ctx); |
| 2866 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2867 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2868 | ret); |
| 2869 | goto close; |
| 2870 | } |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2871 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2872 | status = cds_dp_open(hdd_ctx->psoc); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2873 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2874 | hdd_err("Failed to Open cds post open; status: %d", |
| 2875 | status); |
| 2876 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2877 | goto close; |
| 2878 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2879 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2880 | ret = hdd_register_cb(hdd_ctx); |
| 2881 | if (ret) { |
| 2882 | hdd_err("Failed to register HDD callbacks!"); |
| 2883 | goto cds_txrx_free; |
| 2884 | } |
| 2885 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2886 | /* |
| 2887 | * NAN compoenet requires certian operations like, open adapter, |
| 2888 | * close adapter, etc. to be initiated by HDD, for those |
| 2889 | * register HDD callbacks with UMAC's NAN componenet. |
| 2890 | */ |
| 2891 | hdd_nan_register_callbacks(hdd_ctx); |
| 2892 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2893 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2894 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2895 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2896 | ret = qdf_status_to_os_return(status); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2897 | goto deregister_cb; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2898 | } |
| 2899 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2900 | hdd_register_policy_manager_callback( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2901 | hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2902 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2903 | hdd_sysfs_create_driver_root_obj(); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2904 | hdd_sysfs_create_version_interface(hdd_ctx->psoc); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2905 | hdd_sysfs_create_powerstats_interface(); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2906 | hdd_update_hw_sw_info(hdd_ctx); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2907 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2908 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2909 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2910 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2911 | break; |
| 2912 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2913 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2914 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2915 | if (ret) { |
| 2916 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2917 | goto destroy_driver_sysfs; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2918 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2919 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2920 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2921 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2922 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2923 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2924 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2925 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2926 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2927 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2928 | goto release_lock; |
| 2929 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2930 | |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2931 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 2932 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 2933 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2934 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2935 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2936 | return 0; |
| 2937 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2938 | destroy_driver_sysfs: |
| 2939 | hdd_sysfs_destroy_powerstats_interface(); |
| 2940 | hdd_sysfs_destroy_version_interface(); |
| 2941 | hdd_sysfs_destroy_driver_root_obj(); |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2942 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2943 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2944 | deregister_cb: |
| 2945 | hdd_deregister_cb(hdd_ctx); |
| 2946 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2947 | cds_txrx_free: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2948 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2949 | |
| 2950 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 2951 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2952 | dispatcher_pdev_close(hdd_ctx->pdev); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2953 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 2954 | } |
| 2955 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2956 | cds_dp_close(hdd_ctx->psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2957 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2958 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2959 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2960 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2961 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2962 | cds_close(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2963 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 2964 | psoc_close: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2965 | hdd_component_psoc_close(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2966 | cds_deinit_ini_config(); |
| 2967 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2968 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2969 | ol_cds_free(); |
| 2970 | |
| 2971 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2972 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2973 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2974 | power_down: |
| 2975 | if (!reinit && !unint) |
| 2976 | pld_power_off(qdf_dev->dev); |
| 2977 | release_lock: |
Abhinav Kumar | 7ae9b7b | 2017-12-19 15:11:54 +0530 | [diff] [blame] | 2978 | if (hdd_ctx->target_hw_name) { |
| 2979 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2980 | hdd_ctx->target_hw_name = NULL; |
| 2981 | } |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2982 | |
| 2983 | hdd_check_for_leaks(hdd_ctx, reinit); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2984 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2985 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2986 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2987 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2988 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2989 | } |
| 2990 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2991 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2992 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2993 | { |
| 2994 | int ret = os_if_wifi_pos_register_nl(); |
| 2995 | |
| 2996 | if (ret) |
| 2997 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2998 | |
| 2999 | return ret; |
| 3000 | } |
| 3001 | |
| 3002 | static int hdd_deactivate_wifi_pos(void) |
| 3003 | { |
| 3004 | int ret = os_if_wifi_pos_deregister_nl(); |
| 3005 | |
| 3006 | if (ret) |
| 3007 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 3008 | |
| 3009 | return ret; |
| 3010 | } |
| 3011 | |
| 3012 | /** |
| 3013 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 3014 | * @hdd_ctx: hdd context |
| 3015 | * |
| 3016 | * Return: status of operation |
| 3017 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3018 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3019 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3020 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3021 | uint16_t neighbor_scan_max_chan_time; |
| 3022 | uint16_t neighbor_scan_min_chan_time; |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3023 | |
| 3024 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 3025 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 3026 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 3027 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 3028 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 3029 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3030 | ucfg_mlme_get_neighbor_scan_max_chan_time(psoc, |
| 3031 | &neighbor_scan_max_chan_time); |
| 3032 | ucfg_mlme_get_neighbor_scan_min_chan_time(psoc, |
| 3033 | &neighbor_scan_min_chan_time); |
| 3034 | wifi_pos_set_dwell_time_min(psoc, neighbor_scan_min_chan_time); |
| 3035 | wifi_pos_set_dwell_time_max(psoc, neighbor_scan_max_chan_time); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3036 | } |
| 3037 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3038 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3039 | { |
| 3040 | return oem_activate_service(hdd_ctx); |
| 3041 | } |
| 3042 | |
| 3043 | static int hdd_deactivate_wifi_pos(void) |
| 3044 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 3045 | return oem_deactivate_service(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3046 | } |
| 3047 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3048 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3049 | { |
| 3050 | } |
| 3051 | #endif |
| 3052 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3053 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3054 | * __hdd_open() - HDD Open function |
| 3055 | * @dev: Pointer to net_device structure |
| 3056 | * |
| 3057 | * This is called in response to ifconfig up |
| 3058 | * |
| 3059 | * Return: 0 for success; non-zero for failure |
| 3060 | */ |
| 3061 | static int __hdd_open(struct net_device *dev) |
| 3062 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3063 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3064 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3065 | int ret; |
| 3066 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3067 | hdd_enter_dev(dev); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3068 | |
| 3069 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3070 | TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3071 | adapter->vdev_id, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3072 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 3073 | /* Nothing to be done if device is unloading */ |
| 3074 | if (cds_is_driver_unloading()) { |
| 3075 | hdd_err("Driver is unloading can not open the hdd"); |
| 3076 | return -EBUSY; |
| 3077 | } |
| 3078 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 3079 | if (cds_is_driver_recovering()) { |
| 3080 | hdd_err("WLAN is currently recovering; Please try again."); |
| 3081 | return -EBUSY; |
| 3082 | } |
| 3083 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3084 | /* |
| 3085 | * This scenario can be hit in cases where in the wlan driver after |
| 3086 | * registering the netdevices and there is a failure in driver |
| 3087 | * initialization. So return error gracefully because the netdevices |
| 3088 | * will be de-registered as part of the load failure. |
| 3089 | */ |
| 3090 | |
| 3091 | if (!cds_is_driver_loaded()) { |
| 3092 | hdd_err("Failed to start the wlan driver!!"); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3093 | return -EIO; |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3094 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3095 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 3096 | ret = hdd_psoc_idle_restart(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3097 | if (ret) { |
| 3098 | hdd_err("Failed to start WLAN modules return"); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3099 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3100 | } |
| 3101 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3102 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3103 | ret = hdd_start_adapter(adapter); |
| 3104 | if (ret) { |
| 3105 | hdd_err("Failed to start adapter :%d", |
| 3106 | adapter->device_mode); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3107 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3108 | } |
| 3109 | } |
| 3110 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3111 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3112 | 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] | 3113 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3114 | /* Enable TX queues only when we are connected */ |
| 3115 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3116 | WLAN_START_ALL_NETIF_QUEUE, |
| 3117 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3118 | } |
| 3119 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3120 | /* Enable carrier and transmit queues for NDI */ |
| 3121 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3122 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3123 | wlan_hdd_netif_queue_control(adapter, |
| 3124 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3125 | WLAN_CONTROL_PATH); |
| 3126 | } |
| 3127 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3128 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3129 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3130 | |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3131 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3132 | } |
| 3133 | |
| 3134 | /** |
| 3135 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3136 | * @net_dev: Pointer to net_device structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3137 | * |
| 3138 | * This is called in response to ifconfig up |
| 3139 | * |
| 3140 | * Return: 0 for success; non-zero for failure |
| 3141 | */ |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3142 | static int hdd_open(struct net_device *net_dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3143 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3144 | int errno; |
| 3145 | struct osif_vdev_sync *vdev_sync; |
| 3146 | |
| 3147 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 3148 | if (errno) |
| 3149 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3150 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3151 | errno = __hdd_open(net_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3152 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3153 | osif_vdev_sync_trans_stop(vdev_sync); |
| 3154 | |
| 3155 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3156 | } |
| 3157 | |
| 3158 | /** |
| 3159 | * __hdd_stop() - HDD stop function |
| 3160 | * @dev: Pointer to net_device structure |
| 3161 | * |
| 3162 | * This is called in response to ifconfig down |
| 3163 | * |
| 3164 | * Return: 0 for success; non-zero for failure |
| 3165 | */ |
| 3166 | static int __hdd_stop(struct net_device *dev) |
| 3167 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3168 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3169 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3170 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3171 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3172 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3173 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3174 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3175 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3176 | TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3177 | adapter->vdev_id, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3178 | |
| 3179 | ret = wlan_hdd_validate_context(hdd_ctx); |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3180 | if (ret) { |
| 3181 | set_bit(DOWN_DURING_SSR, &adapter->event_flags); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3182 | return ret; |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3183 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3184 | |
| 3185 | /* Nothing to be done if the interface is not opened */ |
| 3186 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3187 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3188 | return -ENODEV; |
| 3189 | } |
| 3190 | |
| 3191 | /* Make sure the interface is marked as closed */ |
| 3192 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3193 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3194 | mac_handle = hdd_ctx->mac_handle; |
| 3195 | |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3196 | hdd_debug("Disabling Auto Power save timer"); |
| 3197 | sme_ps_disable_auto_ps_timer( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3198 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3199 | adapter->vdev_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3200 | |
| 3201 | /* |
| 3202 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3203 | * be called on that interface |
| 3204 | */ |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 3205 | hdd_debug("Disabling queues, adapter device mode: %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 3206 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3207 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3208 | wlan_hdd_netif_queue_control(adapter, |
| 3209 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3210 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3211 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3212 | if (adapter->device_mode == QDF_STA_MODE) |
| 3213 | hdd_lpass_notify_stop(hdd_ctx); |
| 3214 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3215 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3216 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3217 | * bursty in nature and depends on the need to transfer. The service |
| 3218 | * layer may down the interface after the usage and up again when |
| 3219 | * required. In some sense, the NDI is expected to be available |
| 3220 | * (like SAP) iface until NDI delete request is issued by the service |
| 3221 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3222 | * interface (NDI). |
| 3223 | */ |
| 3224 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3225 | return 0; |
| 3226 | |
| 3227 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3228 | * The interface is marked as down for outside world (aka kernel) |
| 3229 | * But the driver is pretty much alive inside. The driver needs to |
| 3230 | * tear down the existing connection on the netdev (session) |
| 3231 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3232 | * for this interface. The call also needs to wait until the above |
| 3233 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3234 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3235 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3236 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3237 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3238 | |
| 3239 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3240 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3241 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3242 | if (!hdd_is_any_interface_open(hdd_ctx)) |
| 3243 | hdd_psoc_idle_timer_start(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3244 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3245 | hdd_exit(); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3246 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3247 | return 0; |
| 3248 | } |
| 3249 | |
| 3250 | /** |
| 3251 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3252 | * @dev: pointer to net_device structure |
| 3253 | * |
| 3254 | * This is called in response to ifconfig down |
| 3255 | * |
| 3256 | * Return: 0 for success and error number for failure |
| 3257 | */ |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3258 | static int hdd_stop(struct net_device *net_dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3259 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3260 | int errno; |
| 3261 | struct osif_vdev_sync *vdev_sync; |
| 3262 | |
| 3263 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 3264 | if (errno) |
| 3265 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3266 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3267 | errno = __hdd_stop(net_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3268 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3269 | osif_vdev_sync_trans_stop(vdev_sync); |
| 3270 | |
| 3271 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3272 | } |
| 3273 | |
| 3274 | /** |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3275 | * hdd_uninit() - HDD uninit function |
| 3276 | * @dev: Pointer to net_device structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3277 | * |
| 3278 | * This is called during the netdev unregister to uninitialize all data |
| 3279 | * associated with the device |
| 3280 | * |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3281 | * This function must be protected by a transition |
| 3282 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3283 | * Return: None |
| 3284 | */ |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3285 | static void hdd_uninit(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3286 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3287 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3288 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3289 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3290 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3291 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3292 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 3293 | hdd_err("Invalid magic"); |
| 3294 | goto exit; |
| 3295 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3296 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3297 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3298 | if (!hdd_ctx) { |
| 3299 | hdd_err("NULL hdd_ctx"); |
| 3300 | goto exit; |
| 3301 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3302 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3303 | if (dev != adapter->dev) |
| 3304 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3305 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3306 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3307 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3308 | /* after uninit our adapter structure will no longer be valid */ |
| 3309 | adapter->dev = NULL; |
| 3310 | adapter->magic = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3311 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3312 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3313 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3314 | } |
| 3315 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3316 | static int hdd_open_cesium_nl_sock(void) |
| 3317 | { |
| 3318 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3319 | struct netlink_kernel_cfg cfg = { |
| 3320 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3321 | .input = NULL |
| 3322 | }; |
| 3323 | #endif |
| 3324 | int ret = 0; |
| 3325 | |
| 3326 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3327 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3328 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3329 | THIS_MODULE, |
| 3330 | #endif |
| 3331 | &cfg); |
| 3332 | #else |
| 3333 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3334 | WLAN_NLINK_MCAST_GRP_ID, |
| 3335 | NULL, NULL, THIS_MODULE); |
| 3336 | #endif |
| 3337 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3338 | if (!cesium_nl_srv_sock) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3339 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3340 | ret = -ECONNREFUSED; |
| 3341 | } |
| 3342 | |
| 3343 | return ret; |
| 3344 | } |
| 3345 | |
| 3346 | static void hdd_close_cesium_nl_sock(void) |
| 3347 | { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3348 | if (cesium_nl_srv_sock) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3349 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3350 | cesium_nl_srv_sock = NULL; |
| 3351 | } |
| 3352 | } |
| 3353 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3354 | void hdd_update_dynamic_mac(struct hdd_context *hdd_ctx, |
| 3355 | struct qdf_mac_addr *curr_mac_addr, |
| 3356 | struct qdf_mac_addr *new_mac_addr) |
| 3357 | { |
| 3358 | uint8_t i; |
| 3359 | |
| 3360 | hdd_enter(); |
| 3361 | |
| 3362 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3363 | if (!qdf_mem_cmp( |
| 3364 | curr_mac_addr->bytes, |
| 3365 | &hdd_ctx->dynamic_mac_list[i].dynamic_mac.bytes[0], |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3366 | sizeof(struct qdf_mac_addr))) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3367 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[i].dynamic_mac, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3368 | new_mac_addr->bytes, |
| 3369 | sizeof(struct qdf_mac_addr)); |
| 3370 | break; |
| 3371 | } |
| 3372 | } |
| 3373 | |
| 3374 | hdd_exit(); |
| 3375 | } |
| 3376 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3377 | /** |
| 3378 | * __hdd_set_mac_address() - set the user specified mac address |
| 3379 | * @dev: Pointer to the net device. |
| 3380 | * @addr: Pointer to the sockaddr. |
| 3381 | * |
| 3382 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3383 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3384 | * |
| 3385 | * Return: 0 for success, non zero for failure |
| 3386 | */ |
| 3387 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3388 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3389 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3390 | struct hdd_adapter *adapter_temp; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3391 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3392 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3393 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3394 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3395 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3396 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3397 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3398 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3399 | if (netif_running(dev)) { |
| 3400 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3401 | return -EBUSY; |
| 3402 | } |
| 3403 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3404 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3405 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3406 | if (0 != ret) |
| 3407 | return ret; |
| 3408 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3409 | 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] | 3410 | adapter_temp = hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes); |
| 3411 | if (adapter_temp) { |
| 3412 | if (!qdf_str_cmp(adapter_temp->dev->name, dev->name)) |
| 3413 | return 0; |
| 3414 | hdd_err("%s adapter exist with same address " MAC_ADDRESS_STR, |
| 3415 | adapter_temp->dev->name, |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3416 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 3417 | return -EINVAL; |
| 3418 | } |
| 3419 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 3420 | qdf_ret_status = wlan_hdd_validate_mac_address(&mac_addr); |
| 3421 | if (QDF_IS_STATUS_ERROR(qdf_ret_status)) |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3422 | return -EINVAL; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3423 | |
Ashish Kumar Dhanotiya | 8bfef12 | 2018-04-18 16:48:27 +0530 | [diff] [blame] | 3424 | hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ", |
| 3425 | MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3426 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3427 | hdd_update_dynamic_mac(hdd_ctx, &adapter->mac_addr, &mac_addr); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3428 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3429 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3430 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3431 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3432 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3433 | } |
| 3434 | |
| 3435 | /** |
| 3436 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3437 | * function from SSR |
| 3438 | * @net_dev: pointer to net_device structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3439 | * @addr: Pointer to the sockaddr |
| 3440 | * |
| 3441 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3442 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3443 | * |
| 3444 | * Return: 0 for success. |
| 3445 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3446 | 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] | 3447 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3448 | struct osif_vdev_sync *vdev_sync; |
| 3449 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3450 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3451 | errno = osif_vdev_sync_op_start(net_dev, &vdev_sync); |
| 3452 | if (errno) |
| 3453 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3454 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3455 | errno = __hdd_set_mac_address(net_dev, addr); |
| 3456 | |
| 3457 | osif_vdev_sync_op_stop(vdev_sync); |
| 3458 | |
| 3459 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3460 | } |
| 3461 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3462 | 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] | 3463 | { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3464 | int i, j; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3465 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3466 | i = qdf_ffz(hdd_ctx->derived_intf_addr_mask); |
| 3467 | if (i < 0 || i >= hdd_ctx->num_derived_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3468 | return NULL; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3469 | qdf_atomic_set_bit(i, &hdd_ctx->derived_intf_addr_mask); |
| 3470 | hdd_info("Assigning MAC from derived list" MAC_ADDRESS_STR, |
| 3471 | MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3472 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3473 | /* Copy the mac in dynamic mac list at first free position */ |
| 3474 | for (j = 0; j < QDF_MAX_CONCURRENCY_PERSONA; j++) { |
| 3475 | if (qdf_is_macaddr_zero(&hdd_ctx-> |
| 3476 | dynamic_mac_list[j].dynamic_mac)) |
| 3477 | break; |
| 3478 | } |
| 3479 | if (j == QDF_MAX_CONCURRENCY_PERSONA) { |
| 3480 | hdd_err("Max interfaces are up"); |
| 3481 | return NULL; |
| 3482 | } |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 3483 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3484 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[j].dynamic_mac.bytes, |
| 3485 | &hdd_ctx->derived_mac_addr[i].bytes, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3486 | sizeof(struct qdf_mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3487 | hdd_ctx->dynamic_mac_list[j].is_provisioned_mac = false; |
| 3488 | hdd_ctx->dynamic_mac_list[j].bit_position = i; |
| 3489 | |
| 3490 | return hdd_ctx->derived_mac_addr[i].bytes; |
| 3491 | } |
| 3492 | |
| 3493 | static uint8_t *wlan_hdd_get_provisioned_intf_addr(struct hdd_context *hdd_ctx) |
| 3494 | { |
| 3495 | int i, j; |
| 3496 | |
| 3497 | i = qdf_ffz(hdd_ctx->provisioned_intf_addr_mask); |
| 3498 | if (i < 0 || i >= hdd_ctx->num_provisioned_addr) |
| 3499 | return NULL; |
| 3500 | qdf_atomic_set_bit(i, &hdd_ctx->provisioned_intf_addr_mask); |
| 3501 | hdd_info("Assigning MAC from provisioned list" MAC_ADDRESS_STR, |
| 3502 | MAC_ADDR_ARRAY(hdd_ctx->provisioned_mac_addr[i].bytes)); |
| 3503 | |
| 3504 | /* Copy the mac in dynamic mac list at first free position */ |
| 3505 | for (j = 0; j < QDF_MAX_CONCURRENCY_PERSONA; j++) { |
| 3506 | if (qdf_is_macaddr_zero(&hdd_ctx-> |
| 3507 | dynamic_mac_list[j].dynamic_mac)) |
| 3508 | break; |
| 3509 | } |
| 3510 | if (j == QDF_MAX_CONCURRENCY_PERSONA) { |
| 3511 | hdd_err("Max interfaces are up"); |
| 3512 | return NULL; |
| 3513 | } |
| 3514 | |
| 3515 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[j].dynamic_mac.bytes, |
| 3516 | &hdd_ctx->provisioned_mac_addr[i].bytes, |
| 3517 | sizeof(struct qdf_mac_addr)); |
| 3518 | hdd_ctx->dynamic_mac_list[j].is_provisioned_mac = true; |
| 3519 | hdd_ctx->dynamic_mac_list[j].bit_position = i; |
| 3520 | return hdd_ctx->provisioned_mac_addr[i].bytes; |
| 3521 | } |
| 3522 | |
| 3523 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx, |
| 3524 | enum QDF_OPMODE interface_type) |
| 3525 | { |
| 3526 | uint8_t *mac_addr = NULL; |
| 3527 | |
| 3528 | if (qdf_atomic_test_bit(interface_type, |
| 3529 | (unsigned long *) |
| 3530 | (&hdd_ctx->config->provisioned_intf_pool))) |
| 3531 | mac_addr = wlan_hdd_get_provisioned_intf_addr(hdd_ctx); |
| 3532 | |
| 3533 | if ((!mac_addr) && |
| 3534 | (qdf_atomic_test_bit(interface_type, |
| 3535 | (unsigned long *) |
| 3536 | (&hdd_ctx->config->derived_intf_pool)))) |
| 3537 | mac_addr = wlan_hdd_get_derived_intf_addr(hdd_ctx); |
| 3538 | |
| 3539 | if (!mac_addr) |
| 3540 | hdd_err("MAC is not available in both the lists"); |
| 3541 | return mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3542 | } |
| 3543 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3544 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3545 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3546 | { |
| 3547 | int i; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3548 | int mac_pos_in_mask; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3549 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3550 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3551 | if (!memcmp(releaseAddr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3552 | hdd_ctx->dynamic_mac_list[i].dynamic_mac.bytes, |
| 3553 | QDF_MAC_ADDR_SIZE)) { |
| 3554 | mac_pos_in_mask = |
| 3555 | hdd_ctx->dynamic_mac_list[i].bit_position; |
| 3556 | if (hdd_ctx->dynamic_mac_list[i].is_provisioned_mac) { |
| 3557 | qdf_atomic_clear_bit( |
| 3558 | mac_pos_in_mask, |
| 3559 | &hdd_ctx-> |
| 3560 | provisioned_intf_addr_mask); |
| 3561 | hdd_info("Releasing MAC from provisioned list"); |
| 3562 | hdd_info( |
| 3563 | MAC_ADDRESS_STR, |
| 3564 | MAC_ADDR_ARRAY(releaseAddr)); |
| 3565 | } else { |
| 3566 | qdf_atomic_clear_bit( |
| 3567 | mac_pos_in_mask, &hdd_ctx-> |
| 3568 | derived_intf_addr_mask); |
| 3569 | hdd_info("Releasing MAC from derived list"); |
| 3570 | hdd_info(MAC_ADDRESS_STR, |
| 3571 | MAC_ADDR_ARRAY(releaseAddr)); |
| 3572 | } |
| 3573 | qdf_zero_macaddr(&hdd_ctx-> |
| 3574 | dynamic_mac_list[i].dynamic_mac); |
| 3575 | hdd_ctx->dynamic_mac_list[i].is_provisioned_mac = |
| 3576 | false; |
| 3577 | hdd_ctx->dynamic_mac_list[i].bit_position = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3578 | break; |
| 3579 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3580 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3581 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3582 | if (i == QDF_MAX_CONCURRENCY_PERSONA) |
| 3583 | hdd_err("Releasing non existing MAC" MAC_ADDRESS_STR, |
| 3584 | MAC_ADDR_ARRAY(releaseAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3585 | } |
| 3586 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3587 | /** |
| 3588 | * __hdd_set_multicast_list() - set the multicast address list |
| 3589 | * @dev: Pointer to the WLAN device. |
| 3590 | * @skb: Pointer to OS packet (sk_buff). |
| 3591 | * |
| 3592 | * This funciton sets the multicast address list. |
| 3593 | * |
| 3594 | * Return: None |
| 3595 | */ |
| 3596 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3597 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3598 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3599 | int i = 0, errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3600 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3601 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3602 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3603 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3604 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3605 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3606 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3607 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3608 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3609 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3610 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 3611 | if (errno) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3612 | goto out; |
| 3613 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3614 | errno = hdd_validate_adapter(adapter); |
| 3615 | if (errno) |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3616 | goto out; |
| 3617 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3618 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3619 | hdd_err("%s: Driver module is closed", __func__); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3620 | goto out; |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3621 | } |
| 3622 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3623 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 3624 | if (!mc_list_request) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3625 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3626 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3627 | /* Delete already configured multicast address list */ |
| 3628 | if (adapter->mc_addr_list.mc_cnt > 0) { |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3629 | hdd_debug("clear previously configured MC address list"); |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3630 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3631 | pmo_mc_list_change_notify); |
| 3632 | } |
| 3633 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3634 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3635 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3636 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3637 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3638 | } else { |
| 3639 | mc_count = netdev_mc_count(dev); |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 3640 | if (mc_count > ucfg_pmo_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3641 | 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] | 3642 | ucfg_pmo_max_mc_addr_supported(psoc)); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3643 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3644 | pmo_mc_list_change_notify); |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3645 | adapter->mc_addr_list.mc_cnt = 0; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3646 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3647 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3648 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3649 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3650 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3651 | if (i == mc_count) |
| 3652 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3653 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3654 | 0, ETH_ALEN); |
| 3655 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3656 | ha->addr, ETH_ALEN); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3657 | hdd_debug("mlist[%d] = %pM", i, |
| 3658 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3659 | i++; |
| 3660 | } |
| 3661 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3662 | |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3663 | adapter->mc_addr_list.mc_cnt = mc_count; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3664 | mc_list_request->psoc = psoc; |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3665 | mc_list_request->vdev_id = adapter->vdev_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3666 | mc_list_request->count = mc_count; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3667 | |
| 3668 | errno = hdd_cache_mc_addr_list(mc_list_request); |
| 3669 | if (errno) { |
| 3670 | 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] | 3671 | adapter->vdev_id, errno); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3672 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3673 | } |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3674 | |
| 3675 | hdd_enable_mc_addr_filtering(adapter, pmo_mc_list_change_notify); |
| 3676 | |
| 3677 | free_req: |
| 3678 | qdf_mem_free(mc_list_request); |
| 3679 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3680 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3681 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3682 | } |
| 3683 | |
| 3684 | /** |
| 3685 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3686 | * @net_dev: pointer to net_device |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3687 | * |
| 3688 | * Return: none |
| 3689 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3690 | static void hdd_set_multicast_list(struct net_device *net_dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3691 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3692 | struct osif_vdev_sync *vdev_sync; |
| 3693 | |
| 3694 | if (osif_vdev_sync_op_start(net_dev, &vdev_sync)) |
| 3695 | return; |
| 3696 | |
| 3697 | __hdd_set_multicast_list(net_dev); |
| 3698 | |
| 3699 | osif_vdev_sync_op_stop(vdev_sync); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3700 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3701 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3702 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3703 | .ndo_open = hdd_open, |
| 3704 | .ndo_stop = hdd_stop, |
| 3705 | .ndo_uninit = hdd_uninit, |
| 3706 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3707 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3708 | .ndo_get_stats = hdd_get_stats, |
| 3709 | .ndo_do_ioctl = hdd_ioctl, |
| 3710 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3711 | .ndo_select_queue = hdd_select_queue, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3712 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3713 | }; |
| 3714 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3715 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3716 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3717 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3718 | .ndo_open = hdd_mon_open, |
| 3719 | .ndo_stop = hdd_stop, |
| 3720 | .ndo_get_stats = hdd_get_stats, |
| 3721 | }; |
| 3722 | |
| 3723 | /** |
| 3724 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3725 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3726 | * Return: None |
| 3727 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3728 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3729 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3730 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3731 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3732 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3733 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3734 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3735 | #else |
| 3736 | void hdd_set_station_ops(struct net_device *dev) |
| 3737 | { |
| 3738 | dev->netdev_ops = &wlan_drv_ops; |
| 3739 | } |
| 3740 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3741 | |
| 3742 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3743 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3744 | * @hdd_ctx: global hdd context |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3745 | * @mac_addr: mac address to assign to the interface |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3746 | * @name: User-visible name of the interface |
| 3747 | * |
| 3748 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3749 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3750 | * |
| 3751 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3752 | */ |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3753 | static struct hdd_adapter * |
| 3754 | hdd_alloc_station_adapter(struct hdd_context *hdd_ctx, tSirMacAddr mac_addr, |
| 3755 | unsigned char name_assign_type, const char *name) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3756 | { |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3757 | struct net_device *dev; |
| 3758 | struct hdd_adapter *adapter; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3759 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3760 | QDF_STATUS qdf_status; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3761 | |
| 3762 | /* cfg80211 initialization and registration */ |
| 3763 | dev = alloc_netdev_mq(sizeof(*adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3764 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3765 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3766 | #endif |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3767 | (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE ? |
| 3768 | hdd_mon_mode_ether_setup : ether_setup), |
| 3769 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3770 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3771 | if (!dev) { |
| 3772 | hdd_err("Failed to allocate new net_device '%s'", name); |
| 3773 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3774 | } |
| 3775 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3776 | adapter = netdev_priv(dev); |
| 3777 | |
| 3778 | qdf_mem_zero(adapter, sizeof(*adapter)); |
| 3779 | sta_ctx = &adapter->session.station; |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 3780 | qdf_mem_set(sta_ctx->conn_info.sta_id, |
| 3781 | sizeof(sta_ctx->conn_info.sta_id), |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3782 | HDD_WLAN_INVALID_STA_ID); |
| 3783 | adapter->dev = dev; |
| 3784 | adapter->hdd_ctx = hdd_ctx; |
| 3785 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 3786 | adapter->vdev_id = WLAN_UMAC_VDEV_ID_MAX; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3787 | |
| 3788 | qdf_status = qdf_event_create(&adapter->qdf_session_open_event); |
| 3789 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3790 | goto free_net_dev; |
| 3791 | |
| 3792 | qdf_status = qdf_event_create(&adapter->qdf_session_close_event); |
| 3793 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3794 | goto free_net_dev; |
| 3795 | |
| 3796 | adapter->offloads_configured = false; |
| 3797 | adapter->is_link_up_service_needed = false; |
| 3798 | adapter->disconnection_in_progress = false; |
| 3799 | adapter->send_mode_change = true; |
| 3800 | |
| 3801 | /* Init the net_device structure */ |
| 3802 | strlcpy(dev->name, name, IFNAMSIZ); |
| 3803 | |
| 3804 | qdf_mem_copy(dev->dev_addr, mac_addr, sizeof(tSirMacAddr)); |
| 3805 | qdf_mem_copy(adapter->mac_addr.bytes, mac_addr, sizeof(tSirMacAddr)); |
| 3806 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 3807 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3808 | hdd_set_station_ops(adapter->dev); |
| 3809 | |
| 3810 | hdd_dev_setup_destructor(dev); |
| 3811 | dev->ieee80211_ptr = &adapter->wdev; |
| 3812 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
| 3813 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 3814 | adapter->wdev.netdev = dev; |
| 3815 | |
| 3816 | /* set dev's parent to underlying device */ |
| 3817 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
| 3818 | hdd_wmm_init(adapter); |
| 3819 | spin_lock_init(&adapter->pause_map_lock); |
| 3820 | adapter->start_time = qdf_system_ticks(); |
| 3821 | adapter->last_time = adapter->start_time; |
| 3822 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3823 | return adapter; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3824 | |
| 3825 | free_net_dev: |
| 3826 | free_netdev(adapter->dev); |
| 3827 | |
| 3828 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3829 | } |
| 3830 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3831 | 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] | 3832 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3833 | struct net_device *dev = adapter->dev; |
| 3834 | int ret; |
| 3835 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3836 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3837 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3838 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3839 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3840 | |
| 3841 | ret = dev_alloc_name(dev, dev->name); |
| 3842 | if (ret < 0) { |
| 3843 | hdd_err( |
| 3844 | "unable to get dev name: %s, err = 0x%x", |
| 3845 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3846 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3847 | } |
| 3848 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3849 | |
| 3850 | ret = register_netdevice(dev); |
| 3851 | if (ret) { |
| 3852 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3853 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3854 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3855 | } |
| 3856 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3857 | ret = register_netdev(dev); |
| 3858 | if (ret) { |
| 3859 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3860 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3861 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3862 | } |
| 3863 | } |
| 3864 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3865 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3866 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3867 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3868 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3869 | } |
| 3870 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3871 | QDF_STATUS hdd_sme_open_session_callback(uint8_t vdev_id, |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3872 | QDF_STATUS qdf_status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3873 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3874 | struct hdd_adapter *adapter; |
| 3875 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3876 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3877 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3878 | if (!hdd_ctx) { |
| 3879 | hdd_err("Invalid HDD_CTX"); |
| 3880 | return QDF_STATUS_E_FAILURE; |
| 3881 | } |
| 3882 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3883 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3884 | if (!adapter) { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3885 | hdd_err("NULL adapter for %d", vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3886 | return QDF_STATUS_E_INVAL; |
| 3887 | } |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3888 | |
| 3889 | if (qdf_status == QDF_STATUS_SUCCESS) |
| 3890 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3891 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3892 | qdf_event_set(&adapter->qdf_session_open_event); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3893 | hdd_debug("session %d opened", adapter->vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3894 | |
| 3895 | return QDF_STATUS_SUCCESS; |
| 3896 | } |
| 3897 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3898 | QDF_STATUS hdd_sme_close_session_callback(uint8_t vdev_id) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3899 | { |
| 3900 | struct hdd_adapter *adapter; |
| 3901 | struct hdd_context *hdd_ctx; |
| 3902 | |
| 3903 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3904 | if (!hdd_ctx) { |
| 3905 | hdd_err("Invalid HDD_CTX"); |
| 3906 | return QDF_STATUS_E_FAILURE; |
| 3907 | } |
| 3908 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3909 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3910 | if (!adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3911 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3912 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3913 | } |
| 3914 | |
| 3915 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3916 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3917 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3918 | } |
| 3919 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3920 | /* |
| 3921 | * For NAN Data interface, the close session results in the final |
| 3922 | * indication to the userspace |
| 3923 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3924 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3925 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3926 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3927 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3928 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3929 | /* |
| 3930 | * We can be blocked while waiting for scheduled work to be |
| 3931 | * flushed, and the adapter structure can potentially be freed, in |
| 3932 | * which case the magic will have been reset. So make sure the |
| 3933 | * magic is still good, and hence the adapter structure is still |
| 3934 | * valid, before signaling completion |
| 3935 | */ |
| 3936 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3937 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3938 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3939 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3940 | } |
| 3941 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3942 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3943 | { |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3944 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3945 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3946 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3947 | vdev = hdd_objmgr_get_vdev(adapter); |
| 3948 | if (!vdev) |
| 3949 | return -EINVAL; |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3950 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3951 | status = pmo_vdev_ready(vdev); |
| 3952 | if (QDF_IS_STATUS_ERROR(status)) { |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 3953 | hdd_objmgr_put_vdev(vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3954 | return qdf_status_to_os_return(status); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3955 | } |
| 3956 | |
| 3957 | status = ucfg_reg_11d_vdev_created_update(vdev); |
| 3958 | if (QDF_IS_STATUS_ERROR(status)) { |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 3959 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3960 | return qdf_status_to_os_return(status); |
| 3961 | } |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3962 | |
| 3963 | if (wma_capability_enhanced_mcast_filter()) |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3964 | status = ucfg_pmo_enhanced_mc_filter_enable(vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3965 | else |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3966 | status = ucfg_pmo_enhanced_mc_filter_disable(vdev); |
| 3967 | |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 3968 | hdd_objmgr_put_vdev(vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3969 | |
| 3970 | return qdf_status_to_os_return(status); |
| 3971 | } |
| 3972 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3973 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3974 | { |
| 3975 | QDF_STATUS status; |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3976 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3977 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3978 | uint8_t vdev_id; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3979 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3980 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3981 | vdev_id = adapter->vdev_id; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3982 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3983 | |
| 3984 | /* vdev created sanity check */ |
| 3985 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3986 | hdd_err("vdev %u does not exist", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3987 | return -EINVAL; |
| 3988 | } |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 3989 | |
Abhishek Singh | 628bb6f | 2019-03-26 14:52:40 +0530 | [diff] [blame] | 3990 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3991 | |
| 3992 | /* |
| 3993 | * if this is the last active connection check & stop the |
| 3994 | * opportunistic timer first |
| 3995 | */ |
| 3996 | if ((policy_mgr_get_connection_count(hdd_ctx->psoc) == 1 && |
| 3997 | policy_mgr_mode_specific_connection_count(hdd_ctx->psoc, |
| 3998 | policy_mgr_convert_device_mode_to_qdf_type( |
| 3999 | adapter->device_mode), NULL) == 1) || |
| 4000 | !policy_mgr_get_connection_count(hdd_ctx->psoc)) |
| 4001 | policy_mgr_check_and_stop_opportunistic_timer(hdd_ctx->psoc, |
| 4002 | adapter->vdev_id); |
| 4003 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4004 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4005 | if (!vdev) |
| 4006 | return -EINVAL; |
Ashish Kumar Dhanotiya | 68ee2e4 | 2018-11-19 21:15:14 +0530 | [diff] [blame] | 4007 | |
| 4008 | ucfg_pmo_del_wow_pattern(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4009 | status = ucfg_reg_11d_vdev_delete_update(vdev); |
Abhishek Singh | 935e477 | 2018-11-21 14:14:10 +0530 | [diff] [blame] | 4010 | ucfg_scan_vdev_set_disable(vdev, REASON_VDEV_DOWN); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4011 | hdd_objmgr_put_vdev(vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4012 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4013 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4014 | qdf_event_reset(&adapter->qdf_session_close_event); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4015 | status = sme_close_session(hdd_ctx->mac_handle, adapter->vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4016 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4017 | hdd_err("failed to close sme session; status:%d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4018 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4019 | } |
| 4020 | |
| 4021 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4022 | status = qdf_wait_for_event_completion( |
| 4023 | &adapter->qdf_session_close_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4024 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4025 | |
| 4026 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4027 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4028 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4029 | if (adapter->device_mode == QDF_NDI_MODE) |
| 4030 | hdd_ndp_session_end_handler(adapter); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4031 | |
| 4032 | if (status == QDF_STATUS_E_TIMEOUT) |
| 4033 | hdd_err("timed out waiting for sme close session"); |
| 4034 | else if (adapter->qdf_session_close_event.force_set) |
| 4035 | hdd_info("SSR occurred during sme close session"); |
| 4036 | else |
| 4037 | hdd_err("failed to wait for sme close session; status:%u", |
| 4038 | status); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4039 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4040 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4041 | release_vdev: |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4042 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4043 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4044 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4045 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4046 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4047 | return errno; |
| 4048 | } |
| 4049 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4050 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4051 | |
| 4052 | return 0; |
| 4053 | } |
| 4054 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4055 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 4056 | struct sme_session_params *session_param, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4057 | csr_roam_complete_cb callback, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4058 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4059 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4060 | uint32_t type; |
| 4061 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4062 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4063 | |
| 4064 | /* determine vdev (sub)type */ |
| 4065 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4066 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4067 | hdd_err("failed to get vdev type: %d", status); |
| 4068 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4069 | } |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4070 | session_param->sme_session_id = adapter->vdev_id; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4071 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 4072 | session_param->type_of_persona = type; |
| 4073 | session_param->subtype_of_persona = sub_type; |
| 4074 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 4075 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 4076 | session_param->callback = callback; |
| 4077 | session_param->callback_ctx = callback_ctx; |
| 4078 | |
| 4079 | return 0; |
| 4080 | } |
| 4081 | |
gaurank kathpalia | 6c4b50c | 2019-02-28 14:07:48 +0530 | [diff] [blame] | 4082 | void |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4083 | hdd_store_nss_chains_cfg_in_vdev(struct hdd_adapter *adapter) |
| 4084 | { |
| 4085 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 4086 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4087 | |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4088 | /* Populate the nss chain params from ini for this vdev type */ |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4089 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 4090 | adapter->device_mode, |
| 4091 | hdd_ctx->num_rf_chains); |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4092 | |
| 4093 | /* Store the nss chain config into the vdev */ |
| 4094 | sme_store_nss_chains_cfg_in_vdev(adapter->vdev, &vdev_ini_cfg); |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4095 | } |
gaurank kathpalia | 6982d47 | 2018-10-31 21:54:15 +0530 | [diff] [blame] | 4096 | |
| 4097 | bool hdd_is_vdev_in_conn_state(struct hdd_adapter *adapter) |
| 4098 | { |
| 4099 | switch (adapter->device_mode) { |
| 4100 | case QDF_STA_MODE: |
| 4101 | case QDF_P2P_CLIENT_MODE: |
| 4102 | case QDF_P2P_DEVICE_MODE: |
| 4103 | return hdd_conn_is_connected( |
| 4104 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)); |
| 4105 | case QDF_SAP_MODE: |
| 4106 | case QDF_P2P_GO_MODE: |
| 4107 | return (test_bit(SOFTAP_BSS_STARTED, |
| 4108 | &adapter->event_flags)); |
| 4109 | default: |
| 4110 | hdd_err("Device mode %d invalid", adapter->device_mode); |
| 4111 | return 0; |
| 4112 | } |
| 4113 | |
| 4114 | return 0; |
| 4115 | } |
| 4116 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4117 | int hdd_vdev_create(struct hdd_adapter *adapter, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4118 | csr_roam_complete_cb callback, void *ctx) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4119 | { |
| 4120 | QDF_STATUS status; |
| 4121 | int errno; |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4122 | bool bval; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4123 | struct hdd_context *hdd_ctx; |
| 4124 | struct sme_session_params sme_session_params = {0}; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4125 | struct wlan_objmgr_vdev *vdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4126 | |
| 4127 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4128 | |
| 4129 | /* do vdev create via objmgr */ |
| 4130 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 4131 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4132 | if (errno) { |
| 4133 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 4134 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4135 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4136 | |
| 4137 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4138 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 4139 | if (QDF_STATUS_SUCCESS != status) { |
| 4140 | hdd_err("failed to reinit session open event"); |
| 4141 | return -EINVAL; |
| 4142 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4143 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 4144 | callback, ctx); |
| 4145 | if (errno) { |
| 4146 | hdd_err("failed to populating SME params"); |
| 4147 | goto objmgr_vdev_destroy_procedure; |
| 4148 | } |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4149 | status = sme_open_session(hdd_ctx->mac_handle, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4150 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4151 | hdd_err("failed to open sme session: %d", status); |
| 4152 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4153 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4154 | } |
| 4155 | |
| 4156 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4157 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4158 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4159 | if (QDF_STATUS_SUCCESS != status) { |
| 4160 | if (adapter->qdf_session_open_event.force_set) { |
| 4161 | /* |
| 4162 | * SSR/PDR has caused shutdown, which has forcefully |
| 4163 | * set the event. Return without the closing session. |
| 4164 | */ |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 4165 | adapter->vdev_id = WLAN_UMAC_VDEV_ID_MAX; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4166 | hdd_err("Session open event forcefully set"); |
| 4167 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4168 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 4169 | |
| 4170 | if (QDF_STATUS_E_TIMEOUT == status) |
| 4171 | hdd_err("Session failed to open within timeout period"); |
| 4172 | else |
| 4173 | hdd_err("Failed to wait for session open event(status-%d)", |
| 4174 | status); |
| 4175 | errno = -ETIMEDOUT; |
| 4176 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4177 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4178 | } |
| 4179 | |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 4180 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 4181 | hdd_err("Session failed to open due to vdev create failure"); |
| 4182 | errno = -EINVAL; |
| 4183 | goto objmgr_vdev_destroy_procedure; |
| 4184 | } |
| 4185 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4186 | /* firmware ready for component communication, raise vdev_ready event */ |
| 4187 | errno = hdd_vdev_ready(adapter); |
| 4188 | if (errno) { |
| 4189 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4190 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4191 | } |
| 4192 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4193 | if (adapter->device_mode == QDF_STA_MODE) { |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4194 | bval = false; |
| 4195 | status = ucfg_mlme_get_rtt_mac_randomization(hdd_ctx->psoc, |
| 4196 | &bval); |
| 4197 | if (QDF_IS_STATUS_ERROR(status)) |
| 4198 | hdd_err("unable to get RTT MAC randomization value"); |
| 4199 | |
| 4200 | hdd_debug("setting RTT mac randomization param: %d", bval); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4201 | errno = sme_cli_set_command(adapter->vdev_id, |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4202 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4203 | bval, |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4204 | VDEV_CMD); |
| 4205 | if (0 != errno) |
| 4206 | hdd_err("RTT mac randomization param set failed %d", |
| 4207 | errno); |
| 4208 | } |
| 4209 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4210 | if (adapter->device_mode == QDF_STA_MODE || |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4211 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
| 4212 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4213 | if (!vdev) |
| 4214 | goto hdd_vdev_destroy_procedure; |
| 4215 | 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] | 4216 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4217 | } |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4218 | |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4219 | hdd_store_nss_chains_cfg_in_vdev(adapter); |
| 4220 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4221 | hdd_info("vdev %d created successfully", adapter->vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4222 | |
| 4223 | return 0; |
| 4224 | |
| 4225 | /* |
| 4226 | * Due to legacy constraints, we need to destroy in the same order as |
| 4227 | * create. So, split error handling into 2 cases to accommodate. |
| 4228 | */ |
| 4229 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4230 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4231 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4232 | |
| 4233 | return errno; |
| 4234 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4235 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4236 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 4237 | |
| 4238 | return errno; |
| 4239 | } |
| 4240 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4241 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4242 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4243 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4244 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4245 | QDF_STATUS status; |
| 4246 | int ret_val; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4247 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4248 | bool bval = false; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4249 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4250 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4251 | mac_handle = hdd_ctx->mac_handle; |
| 4252 | sme_set_curr_device_mode(mac_handle, adapter->device_mode); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4253 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4254 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4255 | hdd_err("unable to get vht_enable2x2"); |
| 4256 | sme_set_pdev_ht_vht_ies(mac_handle, bval); |
| 4257 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4258 | sme_set_vdev_ies_per_band(mac_handle, adapter->vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4259 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 4260 | hdd_roam_profile_init(adapter); |
| 4261 | hdd_register_wext(adapter->dev); |
| 4262 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4263 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4264 | |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 4265 | qdf_mem_set(sta_ctx->conn_info.sta_id, |
| 4266 | sizeof(sta_ctx->conn_info.sta_id), |
| 4267 | HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4268 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4269 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4270 | status = sme_config_fast_roaming(mac_handle, adapter->vdev_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4271 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4272 | /* Set the default operation channel */ |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 4273 | sta_ctx->conn_info.channel = |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 4274 | hdd_ctx->config->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4275 | |
| 4276 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 4277 | sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4278 | |
| 4279 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4280 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4281 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4282 | status, status); |
| 4283 | goto error_init_txrx; |
| 4284 | } |
| 4285 | |
| 4286 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4287 | |
| 4288 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4289 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4290 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4291 | status, status); |
| 4292 | goto error_wmm_init; |
| 4293 | } |
| 4294 | |
| 4295 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4296 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4297 | ret_val = sme_cli_set_command(adapter->vdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4298 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4299 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4300 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4301 | if (ret_val) |
| 4302 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4303 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4304 | /* |
| 4305 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4306 | * during that time, then as part of SSR init, do not enable |
| 4307 | * the LRO again. Keep the LRO state same as before SSR. |
| 4308 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 4309 | if (cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 4310 | cfg_dp_lro_enable) && |
| 4311 | !(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4312 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4313 | |
Rakshith Suresh Patkar | 9f5c586 | 2019-02-04 16:23:02 +0530 | [diff] [blame] | 4314 | if (cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 4315 | cfg_dp_enable_ip_tcp_udp_checksum_offload)) |
| 4316 | adapter->dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 4317 | adapter->dev->features |= NETIF_F_RXCSUM; |
| 4318 | |
| 4319 | hdd_set_tso_flags(hdd_ctx, adapter->dev); |
| 4320 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4321 | /* rcpi info initialization */ |
| 4322 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4323 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4324 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4325 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4326 | error_wmm_init: |
| 4327 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4328 | hdd_deinit_tx_rx(adapter); |
| 4329 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4330 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4331 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4332 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4333 | return status; |
| 4334 | } |
| 4335 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4336 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4337 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4338 | * @hdd_ctx: global hdd context |
| 4339 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4340 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4341 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4342 | * |
| 4343 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4344 | * |
| 4345 | * Return: None. |
| 4346 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4347 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4348 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4349 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4350 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4351 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4352 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4353 | if (adapter->dev) { |
| 4354 | if (rtnl_held) |
| 4355 | adapter->dev->wireless_handlers = NULL; |
| 4356 | else { |
| 4357 | rtnl_lock(); |
| 4358 | adapter->dev->wireless_handlers = NULL; |
| 4359 | rtnl_unlock(); |
| 4360 | } |
| 4361 | } |
| 4362 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4363 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4364 | hdd_deinit_tx_rx(adapter); |
| 4365 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4366 | } |
| 4367 | |
| 4368 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4369 | hdd_wmm_adapter_close(adapter); |
| 4370 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4371 | } |
| 4372 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4373 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4374 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4375 | } |
| 4376 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4377 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4378 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4379 | bool rtnl_held) |
| 4380 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4381 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4382 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4383 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4384 | case QDF_STA_MODE: |
| 4385 | case QDF_P2P_CLIENT_MODE: |
| 4386 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4387 | case QDF_IBSS_MODE: |
| 4388 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4389 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4390 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4391 | break; |
| 4392 | } |
| 4393 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4394 | case QDF_SAP_MODE: |
| 4395 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4396 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4397 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4398 | break; |
| 4399 | } |
| 4400 | |
| 4401 | default: |
| 4402 | break; |
| 4403 | } |
| 4404 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4405 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4406 | } |
| 4407 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4408 | static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx, |
| 4409 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4410 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4411 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4412 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4413 | |
| 4414 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4415 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4416 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4417 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4418 | return; |
| 4419 | } |
| 4420 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4421 | hdd_nud_deinit_tracking(adapter); |
| 4422 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4423 | hdd_apf_context_destroy(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4424 | qdf_spinlock_destroy(&adapter->vdev_lock); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4425 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4426 | wlan_hdd_debugfs_csr_deinit(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 4427 | if (adapter->device_mode == QDF_STA_MODE) |
| 4428 | hdd_sysfs_destroy_adapter_root_obj(adapter); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4429 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4430 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4431 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4432 | /* |
| 4433 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4434 | * the driver is almost closed and cannot handle either control |
| 4435 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4436 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4437 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4438 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4439 | * the interface is closed and restricts any operations on that |
| 4440 | */ |
| 4441 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4442 | |
| 4443 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4444 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4445 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4446 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4447 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4448 | /* |
| 4449 | * Note that the adapter is no longer valid at this point |
| 4450 | * since the memory has been reclaimed |
| 4451 | */ |
| 4452 | } |
| 4453 | } |
| 4454 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4455 | 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] | 4456 | tSirMacAddr mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4457 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4458 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4459 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4460 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4461 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 4462 | mac_addr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4463 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4464 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4465 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4466 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4467 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4468 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4469 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4470 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4471 | /** |
| 4472 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4473 | * @hdd_ctx: HDD Context |
| 4474 | * @adapter: HDD Adapter |
| 4475 | * |
| 4476 | * This function set the FW Debug log level based on the INI. |
| 4477 | * |
| 4478 | * Return: None |
| 4479 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4480 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4481 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4482 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4483 | QDF_STATUS status; |
| 4484 | uint16_t enable_fw_log_level, enable_fw_log_type; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4485 | int ret; |
| 4486 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4487 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4488 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4489 | 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] | 4490 | return; |
| 4491 | } |
| 4492 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4493 | /* Enable FW logs based on INI configuration */ |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4494 | status = ucfg_fwol_get_enable_fw_log_type(hdd_ctx->psoc, |
| 4495 | &enable_fw_log_type); |
| 4496 | if (QDF_IS_STATUS_ERROR(status)) |
| 4497 | return; |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4498 | ret = sme_cli_set_command(adapter->vdev_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4499 | WMI_DBGLOG_TYPE, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4500 | enable_fw_log_type, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4501 | DBG_CMD); |
| 4502 | if (ret != 0) |
| 4503 | hdd_err("Failed to enable FW log type ret %d", |
| 4504 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4505 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4506 | status = ucfg_fwol_get_enable_fw_log_level(hdd_ctx->psoc, |
| 4507 | &enable_fw_log_level); |
| 4508 | if (QDF_IS_STATUS_ERROR(status)) |
| 4509 | return; |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4510 | ret = sme_cli_set_command(adapter->vdev_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4511 | WMI_DBGLOG_LOG_LEVEL, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4512 | enable_fw_log_level, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4513 | DBG_CMD); |
| 4514 | if (ret != 0) |
| 4515 | hdd_err("Failed to enable FW log level ret %d", |
| 4516 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4517 | |
lifeng | faa83cb | 2018-11-24 01:53:56 +0800 | [diff] [blame] | 4518 | sme_enable_fw_module_log_level(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4519 | adapter->vdev_id); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4520 | } |
| 4521 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4522 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4523 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4524 | { |
| 4525 | } |
| 4526 | |
| 4527 | #endif |
| 4528 | |
| 4529 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4530 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4531 | * @adapter: HDD adapter |
| 4532 | * |
| 4533 | * Return: 0 on success or errno on failure |
| 4534 | */ |
| 4535 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4536 | { |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4537 | QDF_STATUS status; |
| 4538 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4539 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4540 | bool enable2x2 = false, enable_bt_chain_sep = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4541 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
| 4542 | |
| 4543 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 4544 | &dual_mac_feature); |
| 4545 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4546 | hdd_err("unable to get dual mac feature"); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4547 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4548 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &enable2x2); |
| 4549 | if (QDF_IS_STATUS_ERROR(status)) |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4550 | hdd_err("unable to get vht_enable2x2"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4551 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4552 | status = ucfg_mlme_get_bt_chain_separation_flag(hdd_ctx->psoc, |
| 4553 | &enable_bt_chain_sep); |
| 4554 | if (QDF_IS_STATUS_ERROR(status)) |
| 4555 | hdd_debug("unable to get BT chain separation. using default"); |
| 4556 | |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4557 | hdd_debug("enable2x2: %d, lte_coex: %d, disable_DBS: %d", |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4558 | enable2x2, hdd_ctx->lte_coex_ant_share, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4559 | dual_mac_feature); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4560 | hdd_debug("enable_bt_chain_separation %d", enable_bt_chain_sep); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4561 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4562 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4563 | HW_MODE_DBS_NONE, |
| 4564 | CDS_BAND_ALL); |
| 4565 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4566 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4567 | return qdf_status_to_os_return(status); |
| 4568 | } |
| 4569 | |
| 4570 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4571 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4572 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4573 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4574 | hdd_debug("firmware not capable. skip chain mask programming"); |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4575 | return 0; |
| 4576 | } |
| 4577 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4578 | if (enable2x2 && !enable_bt_chain_sep) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4579 | hdd_debug("2x2 enabled. skip chain mask programming"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4580 | return 0; |
| 4581 | } |
| 4582 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4583 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4584 | hdd_debug("DBS enabled(%d). skip chain mask programming", |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4585 | dual_mac_feature); |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4586 | return 0; |
| 4587 | } |
| 4588 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4589 | if (hdd_ctx->lte_coex_ant_share) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4590 | hdd_debug("lte ant sharing enabled. skip chainmask programming"); |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4591 | return 0; |
| 4592 | } |
| 4593 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4594 | status = ucfg_mlme_configure_chain_mask(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4595 | adapter->vdev_id); |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4596 | if (status != QDF_STATUS_SUCCESS) |
| 4597 | goto error; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4598 | |
| 4599 | return 0; |
| 4600 | |
| 4601 | error: |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4602 | hdd_err("WMI PDEV set param failed"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4603 | return -EINVAL; |
| 4604 | } |
| 4605 | |
| 4606 | /** |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4607 | * hdd_send_coex_config_params() - Send coex config params to FW |
| 4608 | * @hdd_ctx: HDD context |
| 4609 | * @adapter: Primary adapter context |
| 4610 | * |
| 4611 | * This function is used to send all coex config related params to FW |
| 4612 | * |
| 4613 | * Return: 0 on success and -EINVAL on failure |
| 4614 | */ |
| 4615 | static int hdd_send_coex_config_params(struct hdd_context *hdd_ctx, |
| 4616 | struct hdd_adapter *adapter) |
| 4617 | { |
| 4618 | struct coex_config_params coex_cfg_params = {0}; |
| 4619 | struct wlan_fwol_coex_config config = {0}; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 4620 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4621 | QDF_STATUS status; |
| 4622 | |
| 4623 | if (!hdd_ctx) { |
| 4624 | hdd_err("hdd_ctx is invalid"); |
| 4625 | goto err; |
| 4626 | } |
| 4627 | |
| 4628 | if (!adapter) { |
| 4629 | hdd_err("adapter is invalid"); |
| 4630 | goto err; |
| 4631 | } |
| 4632 | |
| 4633 | if (!psoc) { |
| 4634 | hdd_err("HDD psoc is invalid"); |
| 4635 | goto err; |
| 4636 | } |
| 4637 | |
| 4638 | status = ucfg_fwol_get_coex_config_params(psoc, &config); |
| 4639 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4640 | hdd_err("Unable to get coex config params"); |
| 4641 | goto err; |
| 4642 | } |
| 4643 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4644 | coex_cfg_params.vdev_id = adapter->vdev_id; |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4645 | coex_cfg_params.config_type = WMI_COEX_CONFIG_TX_POWER; |
| 4646 | coex_cfg_params.config_arg1 = config.max_tx_power_for_btc; |
| 4647 | |
| 4648 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4649 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4650 | hdd_err("Failed to send coex Tx power"); |
| 4651 | goto err; |
| 4652 | } |
| 4653 | |
| 4654 | coex_cfg_params.config_type = WMI_COEX_CONFIG_HANDOVER_RSSI; |
| 4655 | coex_cfg_params.config_arg1 = config.wlan_low_rssi_threshold; |
| 4656 | |
| 4657 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4658 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4659 | hdd_err("Failed to send coex handover RSSI"); |
| 4660 | goto err; |
| 4661 | } |
| 4662 | |
| 4663 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BTC_MODE; |
| 4664 | coex_cfg_params.config_arg1 = config.btc_mode; |
| 4665 | |
| 4666 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4667 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4668 | hdd_err("Failed to send coex BTC mode"); |
| 4669 | goto err; |
| 4670 | } |
| 4671 | |
| 4672 | coex_cfg_params.config_type = WMI_COEX_CONFIG_ANTENNA_ISOLATION; |
| 4673 | coex_cfg_params.config_arg1 = config.antenna_isolation; |
| 4674 | |
| 4675 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4676 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4677 | hdd_err("Failed to send coex antenna isolation"); |
| 4678 | goto err; |
| 4679 | } |
| 4680 | |
| 4681 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_LOW_RSSI_THRESHOLD; |
| 4682 | coex_cfg_params.config_arg1 = config.bt_low_rssi_threshold; |
| 4683 | |
| 4684 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4685 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4686 | hdd_err("Failed to send coex BT low RSSI threshold"); |
| 4687 | goto err; |
| 4688 | } |
| 4689 | |
| 4690 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_INTERFERENCE_LEVEL; |
| 4691 | coex_cfg_params.config_arg1 = config.bt_interference_low_ll; |
| 4692 | coex_cfg_params.config_arg2 = config.bt_interference_low_ul; |
| 4693 | coex_cfg_params.config_arg3 = config.bt_interference_medium_ll; |
| 4694 | coex_cfg_params.config_arg4 = config.bt_interference_medium_ul; |
| 4695 | coex_cfg_params.config_arg5 = config.bt_interference_high_ll; |
| 4696 | coex_cfg_params.config_arg6 = config.bt_interference_high_ul; |
| 4697 | |
| 4698 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4699 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4700 | hdd_err("Failed to send coex BT interference level"); |
| 4701 | goto err; |
| 4702 | } |
stonez | c9936cb | 2019-03-11 16:41:22 +0800 | [diff] [blame] | 4703 | |
| 4704 | if (wlan_hdd_mpta_helper_enable(&coex_cfg_params, &config)) |
| 4705 | goto err; |
| 4706 | |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4707 | return 0; |
| 4708 | err: |
| 4709 | return -EINVAL; |
| 4710 | } |
| 4711 | |
| 4712 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4713 | * hdd_set_fw_params() - Set parameters to firmware |
| 4714 | * @adapter: HDD adapter |
| 4715 | * |
| 4716 | * This function Sets various parameters to fw once the |
| 4717 | * adapter is started. |
| 4718 | * |
| 4719 | * Return: 0 on success or errno on failure |
| 4720 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4721 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4722 | { |
| 4723 | int ret; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4724 | uint16_t upper_brssi_thresh, lower_brssi_thresh, rts_profile; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4725 | bool enable_dtim_1chrx; |
| 4726 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4727 | struct hdd_context *hdd_ctx; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4728 | bool bval = false; |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4729 | uint8_t max_amsdu_len, enable_tx_sch_delay; |
| 4730 | uint32_t dtim_sel_diversity, enable_secondary_rate; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4731 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4732 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4733 | |
| 4734 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4735 | if (!hdd_ctx) |
| 4736 | return -EINVAL; |
| 4737 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4738 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4739 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4740 | return 0; |
| 4741 | } |
| 4742 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4743 | ret = -1; |
| 4744 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_lprx_enable(hdd_ctx->psoc, |
| 4745 | &bval))) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4746 | ret = sme_cli_set_command(adapter->vdev_id, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4747 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4748 | bval, PDEV_CMD); |
| 4749 | } |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4750 | if (ret) { |
| 4751 | hdd_err("Failed to set LPRx"); |
| 4752 | goto error; |
| 4753 | } |
| 4754 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 4755 | ucfg_mlme_get_dtim_selection_diversity(hdd_ctx->psoc, |
| 4756 | &dtim_sel_diversity); |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4757 | |
| 4758 | ret = sme_cli_set_command( |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4759 | adapter->vdev_id, |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4760 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 4761 | dtim_sel_diversity, PDEV_CMD); |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4762 | if (ret) { |
| 4763 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4764 | goto error; |
| 4765 | } |
| 4766 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4767 | ret = -1; |
| 4768 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_enable_tx_sch_delay( |
| 4769 | hdd_ctx->psoc, &enable_tx_sch_delay))) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4770 | ret = sme_cli_set_command(adapter->vdev_id, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4771 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4772 | enable_tx_sch_delay, PDEV_CMD); |
| 4773 | } |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4774 | if (ret) { |
| 4775 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4776 | goto error; |
| 4777 | } |
| 4778 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4779 | ret = -1; |
| 4780 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_enable_secondary_rate( |
| 4781 | hdd_ctx->psoc, &enable_secondary_rate))) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4782 | ret = sme_cli_set_command(adapter->vdev_id, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4783 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4784 | enable_secondary_rate, PDEV_CMD); |
| 4785 | } |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4786 | if (ret) { |
| 4787 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4788 | goto error; |
| 4789 | } |
| 4790 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4791 | if (adapter->device_mode == QDF_STA_MODE) { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4792 | status = ucfg_get_upper_brssi_thresh(hdd_ctx->psoc, |
| 4793 | &upper_brssi_thresh); |
| 4794 | if (QDF_IS_STATUS_ERROR(status)) |
| 4795 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4796 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4797 | sme_set_smps_cfg(adapter->vdev_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4798 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4799 | upper_brssi_thresh); |
| 4800 | |
| 4801 | status = ucfg_get_lower_brssi_thresh(hdd_ctx->psoc, |
| 4802 | &lower_brssi_thresh); |
| 4803 | if (QDF_IS_STATUS_ERROR(status)) |
| 4804 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4805 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4806 | sme_set_smps_cfg(adapter->vdev_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4807 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4808 | lower_brssi_thresh); |
| 4809 | |
| 4810 | status = ucfg_get_enable_dtim_1chrx(hdd_ctx->psoc, |
| 4811 | &enable_dtim_1chrx); |
| 4812 | if (QDF_IS_STATUS_ERROR(status)) |
| 4813 | return -EINVAL; |
| 4814 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4815 | sme_set_smps_cfg(adapter->vdev_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4816 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4817 | enable_dtim_1chrx); |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4818 | } |
| 4819 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4820 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4821 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4822 | hdd_err("unable to get vht_enable2x2"); |
| 4823 | |
| 4824 | if (bval) { |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4825 | hdd_debug("configuring 2x2 mode fw params"); |
| 4826 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4827 | ret = sme_set_cck_tx_fir_override(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4828 | adapter->vdev_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4829 | if (ret) { |
| 4830 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4831 | ret); |
| 4832 | goto error; |
| 4833 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4834 | |
| 4835 | if (hdd_configure_chain_mask(adapter)) |
| 4836 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4837 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4838 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4839 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4840 | hdd_debug("configuring 1x1 mode fw params"); |
| 4841 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4842 | /* |
| 4843 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4844 | * we are passing two value |
| 4845 | * as param_id << 29 | param_value. |
| 4846 | * Below param_value = 0(disable) |
| 4847 | */ |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4848 | ret = sme_cli_set_command(adapter->vdev_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4849 | WMI_STA_SMPS_PARAM_CMDID, |
| 4850 | HDD_DTIM_1CHAIN_RX_ID << |
| 4851 | HDD_SMPS_PARAM_VALUE_S, |
| 4852 | VDEV_CMD); |
| 4853 | if (ret) { |
| 4854 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4855 | goto error; |
| 4856 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4857 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4858 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4859 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4860 | |
| 4861 | if (hdd_configure_chain_mask(adapter)) |
| 4862 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4863 | } |
| 4864 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4865 | ret = sme_set_enable_mem_deep_sleep(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4866 | adapter->vdev_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4867 | if (ret) { |
| 4868 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4869 | goto error; |
| 4870 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4871 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4872 | status = ucfg_fwol_get_rts_profile(hdd_ctx->psoc, &rts_profile); |
| 4873 | if (QDF_IS_STATUS_ERROR(status)) |
| 4874 | return -EINVAL; |
| 4875 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4876 | ret = sme_cli_set_command(adapter->vdev_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4877 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4878 | rts_profile, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4879 | VDEV_CMD); |
| 4880 | if (ret) { |
| 4881 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4882 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4883 | } |
| 4884 | |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4885 | status = ucfg_mlme_get_max_amsdu_num(hdd_ctx->psoc, &max_amsdu_len); |
| 4886 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4887 | hdd_err("Failed to get Max AMSDU Num"); |
| 4888 | goto error; |
| 4889 | } |
| 4890 | |
| 4891 | hdd_debug("SET AMSDU num %d", max_amsdu_len); |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4892 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4893 | ret = wma_cli_set_command(adapter->vdev_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4894 | GEN_VDEV_PARAM_AMSDU, |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4895 | max_amsdu_len, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4896 | GEN_CMD); |
| 4897 | if (ret != 0) { |
| 4898 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4899 | goto error; |
| 4900 | } |
| 4901 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4902 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4903 | |
| 4904 | ret = hdd_send_coex_config_params(hdd_ctx, adapter); |
| 4905 | if (ret) { |
| 4906 | hdd_warn("Error initializing coex config params"); |
| 4907 | goto error; |
| 4908 | } |
| 4909 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4910 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4911 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4912 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4913 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4914 | error: |
| 4915 | return -EINVAL; |
| 4916 | } |
| 4917 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4918 | /** |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4919 | * hdd_init_completion() - Initialize Completion Variables |
| 4920 | * @adapter: HDD adapter |
| 4921 | * |
| 4922 | * This function Initialize the completion variables for |
| 4923 | * a particular adapter |
| 4924 | * |
| 4925 | * Return: None |
| 4926 | */ |
| 4927 | static void hdd_init_completion(struct hdd_adapter *adapter) |
| 4928 | { |
| 4929 | init_completion(&adapter->disconnect_comp_var); |
| 4930 | init_completion(&adapter->roaming_comp_var); |
| 4931 | init_completion(&adapter->linkup_event_var); |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4932 | init_completion(&adapter->sta_authorized_event); |
| 4933 | init_completion(&adapter->offchannel_tx_event); |
| 4934 | init_completion(&adapter->tx_action_cnf_event); |
| 4935 | init_completion(&adapter->ibss_peer_info_comp); |
| 4936 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
| 4937 | } |
| 4938 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 4939 | static void hdd_reset_locally_admin_bit(struct hdd_context *hdd_ctx, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 4940 | tSirMacAddr mac_addr) |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 4941 | { |
| 4942 | int i; |
| 4943 | /* |
| 4944 | * Reset locally administered bit for dynamic_mac_list |
| 4945 | * also as while releasing the MAC address for any |
| 4946 | * interface mac will be compared with dynamic mac list |
| 4947 | */ |
| 4948 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
| 4949 | if (!qdf_mem_cmp( |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 4950 | mac_addr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 4951 | &hdd_ctx-> |
| 4952 | dynamic_mac_list[i].dynamic_mac.bytes[0], |
| 4953 | sizeof(struct qdf_mac_addr))) { |
| 4954 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT( |
| 4955 | hdd_ctx-> |
| 4956 | dynamic_mac_list[i].dynamic_mac.bytes); |
| 4957 | break; |
| 4958 | } |
| 4959 | } |
| 4960 | /* |
| 4961 | * Reset locally administered bit if the device mode is |
| 4962 | * STA |
| 4963 | */ |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 4964 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(mac_addr); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 4965 | hdd_debug("locally administered bit reset in sta mode: " |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 4966 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 4967 | } |
| 4968 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 4969 | static void wlan_hdd_cfg80211_scan_block_cb(struct work_struct *work) |
| 4970 | { |
| 4971 | struct hdd_adapter *adapter = |
| 4972 | container_of(work, struct hdd_adapter, scan_block_work); |
| 4973 | struct osif_vdev_sync *vdev_sync; |
| 4974 | |
| 4975 | if (osif_vdev_sync_op_start(adapter->dev, &vdev_sync)) |
| 4976 | return; |
| 4977 | |
| 4978 | wlan_hdd_cfg80211_scan_block(adapter); |
| 4979 | |
| 4980 | osif_vdev_sync_op_stop(vdev_sync); |
| 4981 | } |
| 4982 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4983 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4984 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4985 | * @hdd_ctx: global hdd context |
| 4986 | * @session_type: type of the interface to be created |
| 4987 | * @iface_name: User-visible name of the interface |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 4988 | * @mac_addr: MAC address to assign to the interface |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4989 | * @name_assign_type: the name of assign type of the netdev |
| 4990 | * @rtnl_held: the rtnl lock hold flag |
| 4991 | * |
| 4992 | * This function open and setup the hdd adpater according to the device |
| 4993 | * type request, assign the name, the mac address assigned, and then prepared |
| 4994 | * the hdd related parameters, queue, lock and ready to start. |
| 4995 | * |
| 4996 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4997 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4998 | 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] | 4999 | const char *iface_name, tSirMacAddr mac_addr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5000 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5001 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5002 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5003 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5004 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5005 | |
| 5006 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 5007 | /* |
| 5008 | * Max limit reached on the number of vdevs configured by the |
| 5009 | * host. Return error |
| 5010 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5011 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 5012 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5013 | return NULL; |
| 5014 | } |
| 5015 | |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5016 | status = wlan_hdd_validate_mac_address((struct qdf_mac_addr *)mac_addr); |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5017 | if (QDF_IS_STATUS_ERROR(status)) { |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5018 | /* Not received valid mac_addr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5019 | 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] | 5020 | return NULL; |
| 5021 | } |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5022 | |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5023 | status = hdd_check_for_existing_macaddr(hdd_ctx, mac_addr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5024 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5025 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 5026 | " already exists", |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5027 | MAC_ADDR_ARRAY(mac_addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5028 | return NULL; |
| 5029 | } |
| 5030 | |
| 5031 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5032 | case QDF_STA_MODE: |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5033 | if (!hdd_ctx->config->mac_provision) { |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5034 | hdd_reset_locally_admin_bit(hdd_ctx, mac_addr); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5035 | /* |
| 5036 | * After resetting locally administered bit |
| 5037 | * again check if the new mac address is already |
| 5038 | * exists. |
| 5039 | */ |
| 5040 | status = hdd_check_for_existing_macaddr(hdd_ctx, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5041 | mac_addr); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5042 | if (QDF_STATUS_E_FAILURE == status) { |
| 5043 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 5044 | " already exists", |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5045 | MAC_ADDR_ARRAY(mac_addr)); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5046 | return NULL; |
| 5047 | } |
| 5048 | } |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 5049 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5050 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5051 | case QDF_P2P_CLIENT_MODE: |
| 5052 | case QDF_P2P_DEVICE_MODE: |
| 5053 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 5054 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5055 | case QDF_MONITOR_MODE: |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5056 | adapter = hdd_alloc_station_adapter(hdd_ctx, mac_addr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5057 | name_assign_type, |
| 5058 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5059 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5060 | if (!adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5061 | hdd_err("failed to allocate adapter for session %d", |
| 5062 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5063 | return NULL; |
| 5064 | } |
| 5065 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5066 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5067 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5068 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5069 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5070 | else if (QDF_MONITOR_MODE == session_type) |
| 5071 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5072 | else |
| 5073 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5074 | |
| 5075 | adapter->device_mode = session_type; |
| 5076 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5077 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5078 | /* |
| 5079 | * Workqueue which gets scheduled in IPv4 notification |
| 5080 | * callback |
| 5081 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5082 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5083 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5084 | |
| 5085 | #ifdef WLAN_NS_OFFLOAD |
| 5086 | /* |
| 5087 | * Workqueue which gets scheduled in IPv6 |
| 5088 | * notification callback. |
| 5089 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5090 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5091 | hdd_ipv6_notifier_work_queue); |
| 5092 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5093 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5094 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5095 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5096 | |
| 5097 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5098 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5099 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5100 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5101 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5102 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5103 | hdd_nud_init_tracking(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 5104 | if (adapter->device_mode == QDF_STA_MODE || |
| 5105 | adapter->device_mode == QDF_P2P_DEVICE_MODE) |
| 5106 | hdd_sysfs_create_adapter_root_obj(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5107 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 5108 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 5109 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5110 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5111 | case QDF_P2P_GO_MODE: |
| 5112 | case QDF_SAP_MODE: |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5113 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, mac_addr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5114 | name_assign_type, |
| 5115 | (uint8_t *) iface_name); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5116 | if (!adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5117 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5118 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5119 | return NULL; |
| 5120 | } |
| 5121 | |
| 5122 | adapter->wdev.iftype = |
| 5123 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5124 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5125 | NL80211_IFTYPE_P2P_GO; |
| 5126 | adapter->device_mode = session_type; |
| 5127 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 5128 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5129 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5130 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5131 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5132 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5133 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5134 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5135 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5136 | |
| 5137 | /* |
| 5138 | * Workqueue which gets scheduled in IPv4 notification |
| 5139 | * callback |
| 5140 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5141 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5142 | hdd_ipv4_notifier_work_queue); |
| 5143 | |
| 5144 | #ifdef WLAN_NS_OFFLOAD |
| 5145 | /* |
| 5146 | * Workqueue which gets scheduled in IPv6 |
| 5147 | * notification callback. |
| 5148 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5149 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5150 | hdd_ipv6_notifier_work_queue); |
| 5151 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5152 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5153 | case QDF_FTM_MODE: |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5154 | adapter = hdd_alloc_station_adapter(hdd_ctx, mac_addr, |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5155 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 5156 | iface_name); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5157 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5158 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 5159 | return NULL; |
| 5160 | } |
| 5161 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5162 | adapter->device_mode = session_type; |
| 5163 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5164 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5165 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5166 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5167 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5168 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5169 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5170 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5171 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5172 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5173 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5174 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5175 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5176 | return NULL; |
| 5177 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5178 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5179 | qdf_spinlock_create(&adapter->vdev_lock); |
| 5180 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5181 | hdd_init_completion(adapter); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5182 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 5183 | qdf_list_create(&adapter->blocked_scan_request_q, WLAN_MAX_SCAN_COUNT); |
| 5184 | qdf_mutex_create(&adapter->blocked_scan_request_q_lock); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5185 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5186 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5187 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5188 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5189 | } |
| 5190 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5191 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5192 | if (adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5193 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5194 | adapter = NULL; |
| 5195 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5196 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5197 | return NULL; |
| 5198 | } |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 5199 | hdd_apf_context_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5200 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5201 | if (QDF_STATUS_SUCCESS == status) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5202 | policy_mgr_set_concurrency_mode(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5203 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5204 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5205 | /* Adapter successfully added. Increment the vdev count */ |
| 5206 | hdd_ctx->current_intf_count++; |
| 5207 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5208 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5209 | hdd_ctx->current_intf_count); |
| 5210 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 5211 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5212 | } |
| 5213 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 5214 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 5215 | hdd_err("Interface %s wow debug_fs init failed", |
| 5216 | netdev_name(adapter->dev)); |
| 5217 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 5218 | hdd_register_hl_netdev_fc_timer(adapter, |
| 5219 | hdd_tx_resume_timer_expired_handler); |
| 5220 | |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 5221 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 5222 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5223 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 5224 | if (adapter->device_mode == QDF_STA_MODE) |
| 5225 | wlan_hdd_debugfs_csr_init(adapter); |
| 5226 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5227 | return adapter; |
| 5228 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5229 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5230 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 5231 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5232 | |
| 5233 | return NULL; |
| 5234 | } |
| 5235 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5236 | static void __hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5237 | struct hdd_adapter *adapter, |
| 5238 | bool rtnl_held) |
| 5239 | { |
| 5240 | qdf_list_destroy(&adapter->blocked_scan_request_q); |
| 5241 | qdf_mutex_destroy(&adapter->blocked_scan_request_q_lock); |
| 5242 | policy_mgr_clear_concurrency_mode(hdd_ctx->psoc, adapter->device_mode); |
| 5243 | |
| 5244 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5245 | |
| 5246 | if (hdd_ctx->current_intf_count != 0) |
| 5247 | hdd_ctx->current_intf_count--; |
| 5248 | } |
| 5249 | |
| 5250 | void hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5251 | struct hdd_adapter *adapter, |
| 5252 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5253 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5254 | /* |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5255 | * Stop the global bus bandwidth timer while touching the adapter list |
| 5256 | * to avoid bad memory access by the timer handler. |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5257 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5258 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5259 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5260 | hdd_remove_adapter(hdd_ctx, adapter); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5261 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5262 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5263 | /* conditionally restart the bw timer */ |
| 5264 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5265 | } |
| 5266 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5267 | 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] | 5268 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5269 | struct hdd_adapter *adapter; |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5270 | struct osif_vdev_sync *vdev_sync; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5271 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5272 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5273 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5274 | while (QDF_IS_STATUS_SUCCESS(hdd_remove_front_adapter(hdd_ctx, |
| 5275 | &adapter))) { |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5276 | vdev_sync = osif_vdev_sync_unregister(adapter->dev); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5277 | if (vdev_sync) |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5278 | osif_vdev_sync_wait_for_ops(vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5279 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5280 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
| 5281 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5282 | |
| 5283 | if (vdev_sync) |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5284 | osif_vdev_sync_destroy(vdev_sync); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5285 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5286 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5287 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5288 | } |
| 5289 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5290 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5291 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5292 | struct qdf_mac_addr *bssid = NULL; |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5293 | tSirUpdateIE update_ie; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5294 | mac_handle_t mac_handle; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5295 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5296 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5297 | case QDF_STA_MODE: |
| 5298 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5299 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5300 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5301 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 5302 | bssid = &sta_ctx->conn_info.bssid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5303 | break; |
| 5304 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5305 | case QDF_SAP_MODE: |
| 5306 | case QDF_P2P_GO_MODE: |
| 5307 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5308 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5309 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5310 | break; |
| 5311 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5312 | case QDF_FTM_MODE: |
| 5313 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5314 | default: |
| 5315 | /* |
| 5316 | * wlan_hdd_reset_prob_rspies should not have been called |
| 5317 | * for these kind of devices |
| 5318 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5319 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5320 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5321 | return; |
| 5322 | } |
| 5323 | |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5324 | qdf_copy_macaddr(&update_ie.bssid, bssid); |
| 5325 | update_ie.smeSessionId = adapter->vdev_id; |
| 5326 | update_ie.ieBufferlength = 0; |
| 5327 | update_ie.pAdditionIEBuffer = NULL; |
| 5328 | update_ie.append = true; |
| 5329 | update_ie.notify = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5330 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 5331 | if (sme_update_add_ie(mac_handle, |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5332 | &update_ie, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5333 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5334 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5335 | } |
| 5336 | } |
| 5337 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5338 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 5339 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5340 | { |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5341 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 5342 | struct hdd_station_ctx *sta_ctx; |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5343 | struct sap_context *sap_ctx; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5344 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5345 | union iwreq_data wrqu; |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5346 | tSirUpdateIE update_ie; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5347 | unsigned long rc; |
Jeff Johnson | 8f8ceb9 | 2019-03-24 08:16:55 -0700 | [diff] [blame] | 5348 | struct sap_config *sap_config; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5349 | mac_handle_t mac_handle; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5350 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5351 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5352 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5353 | |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 5354 | if (adapter->vdev_id != WLAN_UMAC_VDEV_ID_MAX) |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 5355 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5356 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5357 | hdd_nud_ignore_tracking(adapter, true); |
| 5358 | hdd_nud_reset_tracking(adapter); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5359 | hdd_nud_flush_work(adapter); |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5360 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5361 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5362 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5363 | wlan_hdd_netif_queue_control(adapter, |
| 5364 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5365 | WLAN_CONTROL_PATH); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5366 | |
| 5367 | mac_handle = hdd_ctx->mac_handle; |
| 5368 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5369 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5370 | case QDF_STA_MODE: |
| 5371 | case QDF_P2P_CLIENT_MODE: |
| 5372 | case QDF_IBSS_MODE: |
| 5373 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5374 | case QDF_NDI_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5375 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5376 | |
| 5377 | if (adapter->device_mode == QDF_NDI_MODE || |
| 5378 | hdd_conn_is_connected(sta_ctx) || |
| 5379 | hdd_is_connecting(sta_ctx)) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5380 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5381 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5382 | roam_profile = hdd_roam_profile(adapter); |
| 5383 | /* For NDI do not use roam_profile */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5384 | if (adapter->device_mode == QDF_NDI_MODE) |
| 5385 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5386 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5387 | adapter->vdev_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5388 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5389 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5390 | eCSR_BSS_TYPE_START_IBSS) |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5391 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5392 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5393 | adapter->vdev_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5394 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Abhinav Kumar | 19a7a40 | 2018-07-12 17:36:57 +0530 | [diff] [blame] | 5395 | else if (adapter->device_mode == QDF_STA_MODE) |
| 5396 | wlan_hdd_disconnect(adapter, |
| 5397 | eCSR_DISCONNECT_REASON_DEAUTH); |
| 5398 | else |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5399 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5400 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5401 | adapter->vdev_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5402 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5403 | /* success implies disconnect is queued */ |
| 5404 | if (QDF_IS_STATUS_SUCCESS(status) && |
| 5405 | adapter->device_mode != QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5406 | rc = wait_for_completion_timeout( |
| 5407 | &adapter->disconnect_comp_var, |
| 5408 | msecs_to_jiffies |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 5409 | (SME_DISCONNECT_TIMEOUT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5410 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5411 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5412 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5413 | if (QDF_IS_STATUS_ERROR(status)) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5414 | hdd_warn("failed to post disconnect"); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5415 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5416 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5417 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5418 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5419 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5420 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5421 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5422 | |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5423 | wlan_hdd_scan_abort(adapter); |
Wu Gao | 4a1ec8c | 2018-07-23 19:18:40 +0800 | [diff] [blame] | 5424 | wlan_hdd_cleanup_actionframe(adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5425 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5426 | hdd_clear_fils_connection_info(adapter); |
Ashish Kumar Dhanotiya | 3651083 | 2019-02-20 22:13:25 +0530 | [diff] [blame] | 5427 | |
| 5428 | status = sme_roam_del_pmkid_from_cache(mac_handle, |
| 5429 | adapter->vdev_id, |
| 5430 | NULL, true); |
| 5431 | if (QDF_IS_STATUS_ERROR(status)) |
| 5432 | hdd_err("Cannot flush PMKIDCache"); |
| 5433 | |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5434 | hdd_deregister_tx_flow_control(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5435 | |
| 5436 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5437 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5438 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5439 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5440 | #endif |
| 5441 | #endif |
| 5442 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5443 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5444 | struct wlan_objmgr_vdev *vdev; |
| 5445 | |
| 5446 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5447 | if (vdev) { |
| 5448 | wlan_cfg80211_sched_scan_stop(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5449 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5450 | } |
| 5451 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5452 | |
Pragaspathi Thilagaraj | e6f37e0 | 2019-01-04 12:24:33 +0530 | [diff] [blame] | 5453 | /* |
| 5454 | * During vdev destroy, if any STA is in connecting state the |
| 5455 | * roam command will be in active queue and thus vdev destroy is |
| 5456 | * queued in pending queue. In case STA tries to connect to |
| 5457 | * multiple BSSID and fails to connect, due to auth/assoc |
| 5458 | * timeouts it may take more than vdev destroy time to get |
| 5459 | * completed. On vdev destroy timeout vdev is moved to logically |
| 5460 | * deleted state. Once connection is completed, vdev destroy is |
| 5461 | * activated and to release the self-peer ref count it try to |
| 5462 | * get the ref of the vdev, which fails as vdev is logically |
| 5463 | * deleted and this leads to peer ref leak. So before vdev |
| 5464 | * destroy is queued abort any STA ongoing connection to avoid |
| 5465 | * vdev destroy timeout. |
| 5466 | */ |
| 5467 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5468 | hdd_abort_ongoing_sta_connection(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5469 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5470 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5471 | break; |
| 5472 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5473 | case QDF_MONITOR_MODE: |
| 5474 | wlan_hdd_scan_abort(adapter); |
| 5475 | hdd_deregister_tx_flow_control(adapter); |
| 5476 | hdd_vdev_destroy(adapter); |
| 5477 | break; |
| 5478 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5479 | case QDF_SAP_MODE: |
Will Huang | 7049bae | 2018-08-13 17:25:02 +0800 | [diff] [blame] | 5480 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5481 | cds_flush_delayed_work(&adapter->acs_pending_work); |
| 5482 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5483 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5484 | |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5485 | wlan_hdd_scan_abort(adapter); |
gaurank kathpalia | b7a9f70 | 2019-02-15 18:09:58 +0530 | [diff] [blame] | 5486 | /* Diassociate with all the peers before stop ap post */ |
| 5487 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) |
| 5488 | wlan_hdd_del_station(adapter); |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5489 | sap_config = &adapter->session.ap.sap_config; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5490 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 5491 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 5492 | ucfg_ipa_flush(hdd_ctx->pdev); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5493 | |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5494 | /* don't flush pre-cac destroy if we are destroying pre-cac */ |
| 5495 | sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(adapter); |
| 5496 | if (!wlan_sap_is_pre_cac_context(sap_ctx)) |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5497 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5498 | |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5499 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5500 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5501 | case QDF_P2P_GO_MODE: |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5502 | cds_flush_work(&adapter->sap_stop_bss_work); |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5503 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5504 | wlan_hdd_undo_acs(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5505 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5506 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5507 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5508 | |
| 5509 | hdd_deregister_tx_flow_control(adapter); |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5510 | hdd_destroy_acs_timer(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5511 | |
Pragaspathi Thilagaraj | e6f37e0 | 2019-01-04 12:24:33 +0530 | [diff] [blame] | 5512 | /** |
| 5513 | * During vdev destroy, If any STA is in connecting state the |
| 5514 | * roam command will be in active queue and thus vdev destroy is |
| 5515 | * queued in pending queue. In case STA is tries to connected to |
| 5516 | * multiple BSSID and fails to connect, due to auth/assoc |
| 5517 | * timeouts it may take more than vdev destroy time to get |
| 5518 | * completes. If vdev destroy timeout vdev is moved to logically |
| 5519 | * deleted state. Once connection is completed, vdev destroy is |
| 5520 | * activated and to release the self-peer ref count it try to |
| 5521 | * get the ref of the vdev, which fails as vdev is logically |
| 5522 | * deleted and this leads to peer ref leak. So before vdev |
| 5523 | * destroy is queued abort any STA ongoing connection to avoid |
| 5524 | * vdev destroy timeout. |
| 5525 | */ |
| 5526 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5527 | hdd_abort_ongoing_sta_connection(hdd_ctx); |
| 5528 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5529 | mutex_lock(&hdd_ctx->sap_lock); |
| 5530 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5531 | status = wlansap_stop_bss( |
| 5532 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5533 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5534 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5535 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5536 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5537 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5538 | qdf_stop_bss_event); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5539 | status = qdf_wait_for_event_completion( |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5540 | &hostapd_state->qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 5541 | SME_CMD_STOP_BSS_TIMEOUT); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5542 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5543 | hdd_err("failure waiting for wlansap_stop_bss %d", |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5544 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5545 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5546 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5547 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5548 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5549 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5550 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5551 | adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5552 | adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5553 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5554 | adapter->device_mode, |
| 5555 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5556 | |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5557 | qdf_copy_macaddr(&update_ie.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5558 | &adapter->mac_addr); |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5559 | update_ie.smeSessionId = adapter->vdev_id; |
| 5560 | update_ie.ieBufferlength = 0; |
| 5561 | update_ie.pAdditionIEBuffer = NULL; |
| 5562 | update_ie.append = false; |
| 5563 | update_ie.notify = false; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5564 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5565 | /* Probe bcn reset */ |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5566 | status = sme_update_add_ie(mac_handle, &update_ie, |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5567 | eUPDATE_IE_PROBE_BCN); |
| 5568 | if (status == QDF_STATUS_E_FAILURE) |
| 5569 | hdd_err("Could not pass PROBE_RSP_BCN to PE"); |
| 5570 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5571 | /* Assoc resp reset */ |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5572 | status = sme_update_add_ie(mac_handle, &update_ie, |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5573 | eUPDATE_IE_ASSOC_RESP); |
| 5574 | if (status == QDF_STATUS_E_FAILURE) |
| 5575 | hdd_err("Could not pass ASSOC_RSP to PE"); |
| 5576 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5577 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5578 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5579 | } |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5580 | clear_bit(SOFTAP_INIT_DONE, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5581 | qdf_mem_free(adapter->session.ap.beacon); |
| 5582 | adapter->session.ap.beacon = NULL; |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5583 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5584 | /* |
| 5585 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5586 | */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5587 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5588 | if (vdev) { |
| 5589 | if (policy_mgr_is_dnsc_set(vdev)) |
| 5590 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5591 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5592 | } |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5593 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5594 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5595 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5596 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5597 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5598 | #endif |
| 5599 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5600 | |
| 5601 | hdd_vdev_destroy(adapter); |
| 5602 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5603 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5604 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5605 | case QDF_OCB_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5606 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5607 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5608 | cds_get_context(QDF_MODULE_ID_TXRX), |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 5609 | sta_ctx->conn_info.sta_id[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5610 | hdd_deregister_tx_flow_control(adapter); |
| 5611 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5612 | break; |
| 5613 | default: |
| 5614 | break; |
| 5615 | } |
| 5616 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 5617 | hdd_deregister_hl_netdev_fc_timer(adapter); |
| 5618 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5619 | if (adapter->scan_info.default_scan_ies) { |
| 5620 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5621 | adapter->scan_info.default_scan_ies = NULL; |
| 5622 | } |
| 5623 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5624 | hdd_exit(); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5625 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5626 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5627 | } |
| 5628 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5629 | /** |
| 5630 | * hdd_deinit_all_adapters - deinit all adapters |
| 5631 | * @hdd_ctx: HDD context |
| 5632 | * @rtnl_held: True if RTNL lock held |
| 5633 | * |
| 5634 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5635 | 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] | 5636 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5637 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5638 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5639 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5640 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5641 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5642 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5643 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5644 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5645 | } |
| 5646 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5647 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5648 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5649 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5650 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5651 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5652 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5653 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5654 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5655 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5656 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5657 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5658 | hdd_exit(); |
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 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5661 | } |
| 5662 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5663 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5664 | struct hdd_adapter *adapter) |
| 5665 | { |
| 5666 | switch (adapter->device_mode) { |
| 5667 | case QDF_STA_MODE: |
| 5668 | case QDF_P2P_CLIENT_MODE: |
| 5669 | case QDF_IBSS_MODE: |
| 5670 | case QDF_P2P_DEVICE_MODE: |
| 5671 | case QDF_NDI_MODE: |
| 5672 | wlan_hdd_scan_abort(adapter); |
| 5673 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5674 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5675 | struct wlan_objmgr_vdev *vdev; |
| 5676 | |
| 5677 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5678 | if (vdev) { |
| 5679 | wlan_cfg80211_sched_scan_stop(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5680 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5681 | } |
| 5682 | } |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5683 | break; |
| 5684 | case QDF_P2P_GO_MODE: |
| 5685 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5686 | break; |
| 5687 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5688 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5689 | wlan_hdd_undo_acs(adapter); |
| 5690 | break; |
| 5691 | default: |
| 5692 | break; |
| 5693 | } |
| 5694 | } |
| 5695 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5696 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5697 | /** |
| 5698 | * hdd_adapter_abort_tx_flow() - Abort the tx flow control |
| 5699 | * @pAdapter: pointer to hdd_adapter_t |
| 5700 | * |
| 5701 | * Resume tx and stop the tx flow control timer if the tx is paused |
| 5702 | * and the flow control timer is running. This function is called by |
| 5703 | * SSR to avoid the inconsistency of tx status before and after SSR. |
| 5704 | * |
| 5705 | * Return: void |
| 5706 | */ |
| 5707 | static void hdd_adapter_abort_tx_flow(struct hdd_adapter *adapter) |
| 5708 | { |
| 5709 | if (adapter->hdd_stats.tx_rx_stats.is_txflow_paused && |
| 5710 | QDF_TIMER_STATE_RUNNING == |
| 5711 | qdf_mc_timer_get_current_state( |
| 5712 | &adapter->tx_flow_control_timer)) { |
| 5713 | hdd_tx_resume_timer_expired_handler(adapter); |
| 5714 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 5715 | } |
| 5716 | } |
| 5717 | #endif |
| 5718 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5719 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5720 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5721 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5722 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 2d04461 | 2019-02-26 20:08:43 -0800 | [diff] [blame] | 5723 | struct qdf_mac_addr peer_macaddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5724 | int sta_id; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5725 | bool value; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5726 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5727 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5728 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5729 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5730 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5731 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5732 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5733 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5734 | qdf_opmode_str(adapter->device_mode), |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5735 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5736 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5737 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5738 | hdd_adapter_abort_tx_flow(adapter); |
| 5739 | #endif |
| 5740 | |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5741 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5742 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5743 | /* Stop tdls timers */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5744 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5745 | if (vdev) { |
| 5746 | hdd_notify_tdls_reset_adapter(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5747 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5748 | } |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5749 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5750 | } |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 5751 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5752 | if (value && |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5753 | adapter->device_mode == QDF_SAP_MODE) { |
| 5754 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5755 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5756 | WLAN_CONTROL_PATH); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5757 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5758 | cds_flush_delayed_work( |
| 5759 | &adapter->acs_pending_work); |
| 5760 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5761 | } |
| 5762 | |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5763 | if (test_bit(SOFTAP_BSS_STARTED, |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5764 | &adapter->event_flags)) { |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5765 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5766 | clear_bit(SOFTAP_BSS_STARTED, |
| 5767 | &adapter->event_flags); |
| 5768 | } |
| 5769 | |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5770 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5771 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5772 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5773 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5774 | } |
Nijun Gong | 104ccc7 | 2018-08-07 10:43:56 +0800 | [diff] [blame] | 5775 | /* |
| 5776 | * Clear fc flag if it was set before SSR to avoid TX queues |
| 5777 | * permanently stopped after SSR. |
| 5778 | * Here WLAN_START_ALL_NETIF_QUEUE will actually not start any |
| 5779 | * queue since it's blocked by reason WLAN_CONTROL_PATH. |
| 5780 | */ |
| 5781 | if (adapter->pause_map & (1 << WLAN_DATA_FLOW_CONTROL)) |
| 5782 | wlan_hdd_netif_queue_control(adapter, |
| 5783 | WLAN_START_ALL_NETIF_QUEUE, |
| 5784 | WLAN_DATA_FLOW_CONTROL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5785 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5786 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5787 | |
| 5788 | hdd_deinit_tx_rx(adapter); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5789 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5790 | adapter->device_mode, adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5791 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5792 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5793 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5794 | hdd_wmm_adapter_close(adapter); |
| 5795 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5796 | } |
| 5797 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5798 | if (adapter->device_mode == QDF_STA_MODE) |
| 5799 | hdd_clear_fils_connection_info(adapter); |
| 5800 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5801 | if (adapter->device_mode == QDF_SAP_MODE) { |
Jingxiang Ge | ec11359 | 2018-08-09 15:40:39 +0800 | [diff] [blame] | 5802 | wlansap_cleanup_cac_timer( |
| 5803 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5804 | /* |
| 5805 | * If adapter is SAP, set session ID to invalid |
| 5806 | * since SAP session will be cleanup during SSR. |
| 5807 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5808 | wlansap_set_invalid_session( |
| 5809 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5810 | } |
| 5811 | |
Abhishek Singh | 8f4aa18 | 2019-03-06 10:29:24 +0530 | [diff] [blame] | 5812 | /* Release vdev ref count to avoid vdev object leak */ |
| 5813 | if (adapter->device_mode == QDF_P2P_GO_MODE || |
| 5814 | adapter->device_mode == QDF_SAP_MODE) |
| 5815 | wlansap_release_vdev_ref( |
| 5816 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5817 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5818 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5819 | if (adapter->device_mode == QDF_STA_MODE || |
| 5820 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5821 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 2d04461 | 2019-02-26 20:08:43 -0800 | [diff] [blame] | 5822 | qdf_copy_macaddr(&peer_macaddr, |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 5823 | &sta_ctx->conn_info.bssid); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5824 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5825 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
Wu Gao | 6b81fc5 | 2018-05-24 19:27:27 +0800 | [diff] [blame] | 5826 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5827 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5828 | if (adapter->sta_info[sta_id].in_use) { |
| 5829 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5830 | sta_id); |
| 5831 | hdd_softap_deregister_sta(adapter, |
| 5832 | sta_id); |
| 5833 | adapter->sta_info[sta_id].in_use = 0; |
| 5834 | } |
| 5835 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5836 | } |
| 5837 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5838 | hdd_nud_ignore_tracking(adapter, true); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5839 | hdd_nud_reset_tracking(adapter); |
| 5840 | hdd_nud_flush_work(adapter); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5841 | |
| 5842 | if (adapter->device_mode != QDF_SAP_MODE && |
| 5843 | adapter->device_mode != QDF_P2P_GO_MODE && |
| 5844 | adapter->device_mode != QDF_FTM_MODE) |
| 5845 | hdd_set_disconnect_status(adapter, false); |
| 5846 | |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5847 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5848 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5849 | hdd_softap_deinit_tx_rx(adapter); |
Tiger Yu | 8c38770 | 2018-07-06 16:56:42 +0800 | [diff] [blame] | 5850 | hdd_deregister_tx_flow_control(adapter); |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5851 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5852 | /* Destroy vdev which will be recreated during reinit. */ |
| 5853 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5854 | } |
| 5855 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5856 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5857 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5858 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5859 | } |
| 5860 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5861 | bool hdd_is_any_interface_open(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5862 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5863 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5864 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5865 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5866 | hdd_info("FTM mode, don't close the module"); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5867 | return true; |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5868 | } |
| 5869 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5870 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5871 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5872 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5873 | return true; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5874 | } |
| 5875 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5876 | return false; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5877 | } |
| 5878 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5879 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5880 | { |
| 5881 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5882 | return true; |
| 5883 | else |
| 5884 | return false; |
| 5885 | } |
| 5886 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5887 | #if defined CFG80211_CONNECT_BSS || \ |
| 5888 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5889 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5890 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5891 | /** |
| 5892 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5893 | * @timeout_reason: reason for connect timeout |
| 5894 | * |
| 5895 | * This function is used to convert host timeout |
| 5896 | * reason enum to kernel specific enum. |
| 5897 | * |
| 5898 | * Return: nl timeout enum |
| 5899 | */ |
| 5900 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5901 | tSirResultCodes timeout_reason) |
| 5902 | { |
| 5903 | switch (timeout_reason) { |
| 5904 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5905 | return NL80211_TIMEOUT_SCAN; |
| 5906 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5907 | return NL80211_TIMEOUT_AUTH; |
| 5908 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5909 | return NL80211_TIMEOUT_ASSOC; |
| 5910 | default: |
| 5911 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5912 | } |
| 5913 | } |
| 5914 | |
| 5915 | /** |
| 5916 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5917 | * @dev: network device |
| 5918 | * @bssid: bssid to which we want to associate |
| 5919 | * @timeout_reason: reason for connect timeout |
| 5920 | * |
| 5921 | * This API is used to send connection timeout reason to supplicant |
| 5922 | * |
| 5923 | * Return: void |
| 5924 | */ |
| 5925 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5926 | const u8 *bssid, |
| 5927 | tSirResultCodes timeout_reason) |
| 5928 | { |
| 5929 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5930 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5931 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5932 | |
| 5933 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5934 | nl_timeout_reason); |
| 5935 | } |
| 5936 | |
| 5937 | /** |
| 5938 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5939 | * @dev: network device |
| 5940 | * @bssid: bssid to which we want to associate |
| 5941 | * @req_ie: Request Information Element |
| 5942 | * @req_ie_len: len of the req IE |
| 5943 | * @resp_ie: Response IE |
| 5944 | * @resp_ie_len: len of ht response IE |
| 5945 | * @status: status |
| 5946 | * @gfp: Kernel Flag |
| 5947 | * @timeout_reason: reason for connect timeout |
| 5948 | * |
| 5949 | * Return: void |
| 5950 | */ |
| 5951 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5952 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5953 | size_t req_ie_len, const u8 *resp_ie, |
| 5954 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5955 | tSirResultCodes timeout_reason) |
| 5956 | { |
| 5957 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5958 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5959 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5960 | |
| 5961 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5962 | resp_ie, resp_ie_len, status, gfp, |
| 5963 | nl_timeout_reason); |
| 5964 | } |
| 5965 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5966 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5967 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5968 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5969 | const u8 *bssid, |
| 5970 | tSirResultCodes timeout_reason) |
| 5971 | { |
| 5972 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5973 | } |
| 5974 | #endif |
| 5975 | |
| 5976 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5977 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5978 | size_t req_ie_len, const u8 *resp_ie, |
| 5979 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5980 | tSirResultCodes timeout_reason) |
| 5981 | { |
| 5982 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5983 | resp_ie, resp_ie_len, status, gfp); |
| 5984 | } |
| 5985 | #endif |
| 5986 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5987 | /** |
| 5988 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5989 | * @dev: network device |
| 5990 | * @bssid: bssid to which we want to associate |
| 5991 | * @req_ie: Request Information Element |
| 5992 | * @req_ie_len: len of the req IE |
| 5993 | * @resp_ie: Response IE |
| 5994 | * @resp_ie_len: len of ht response IE |
| 5995 | * @status: status |
| 5996 | * @gfp: Kernel Flag |
| 5997 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5998 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5999 | * |
| 6000 | * The API is a wrapper to send connection status to supplicant |
| 6001 | * |
| 6002 | * Return: Void |
| 6003 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6004 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 6005 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6006 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6007 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6008 | size_t req_ie_len, const u8 *resp_ie, |
| 6009 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6010 | bool connect_timeout, |
| 6011 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6012 | { |
| 6013 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6014 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6015 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6016 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6017 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6018 | } |
| 6019 | #else |
| 6020 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6021 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6022 | size_t req_ie_len, const u8 *resp_ie, |
| 6023 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6024 | bool connect_timeout, |
| 6025 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6026 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6027 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6028 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6029 | } |
| 6030 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6031 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6032 | #if defined(WLAN_FEATURE_FILS_SK) |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6033 | #if (defined(CFG80211_CONNECT_DONE) || \ |
| 6034 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) && \ |
| 6035 | (LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0)) |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6036 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 6037 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6038 | /** |
| 6039 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 6040 | * @fils_params: connect response to supplicant |
| 6041 | * @fils_kek: FILS kek |
| 6042 | * @fils_kek_len: FILS kek length |
| 6043 | * @pmk: FILS PMK |
| 6044 | * @pmk_len: FILS PMK length |
| 6045 | * @pmkid: PMKID |
| 6046 | * @fils_seq_num: FILS Seq number |
| 6047 | * |
| 6048 | * Return: None |
| 6049 | */ |
| 6050 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6051 | *fils_params, const uint8_t *fils_kek, |
| 6052 | size_t fils_kek_len, const uint8_t *pmk, |
| 6053 | size_t pmk_len, const uint8_t *pmkid, |
| 6054 | uint16_t fils_seq_num) |
| 6055 | { |
| 6056 | /* Increament seq number to be used for next FILS */ |
| 6057 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 6058 | fils_params->update_erp_next_seq_num = true; |
| 6059 | fils_params->fils_kek = fils_kek; |
| 6060 | fils_params->fils_kek_len = fils_kek_len; |
| 6061 | fils_params->pmk = pmk; |
| 6062 | fils_params->pmk_len = pmk_len; |
| 6063 | fils_params->pmkid = pmkid; |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6064 | hdd_debug("FILS erp_next_seq_num:%d", |
| 6065 | fils_params->fils_erp_next_seq_num); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6066 | } |
| 6067 | #else |
| 6068 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6069 | *fils_params, const uint8_t |
| 6070 | *fils_kek, size_t fils_kek_len, |
| 6071 | const uint8_t *pmk, size_t pmk_len, |
| 6072 | const uint8_t *pmkid, |
| 6073 | uint16_t fils_seq_num) |
| 6074 | { } |
| 6075 | #endif |
| 6076 | |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6077 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) |
| 6078 | /** |
| 6079 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 6080 | * @fils_params: connect response to supplicant |
| 6081 | * @fils_kek: FILS kek |
| 6082 | * @fils_kek_len: FILS kek length |
| 6083 | * @pmk: FILS PMK |
| 6084 | * @pmk_len: FILS PMK length |
| 6085 | * @pmkid: PMKID |
| 6086 | * @fils_seq_num: FILS Seq number |
| 6087 | * |
| 6088 | * Return: None |
| 6089 | */ |
| 6090 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6091 | *fils_params, const uint8_t *fils_kek, |
| 6092 | size_t fils_kek_len, const uint8_t *pmk, |
| 6093 | size_t pmk_len, const uint8_t *pmkid, |
| 6094 | uint16_t fils_seq_num) |
| 6095 | { |
| 6096 | /* Increament seq number to be used for next FILS */ |
| 6097 | fils_params->fils.erp_next_seq_num = fils_seq_num + 1; |
| 6098 | fils_params->fils.update_erp_next_seq_num = true; |
| 6099 | fils_params->fils.kek = fils_kek; |
| 6100 | fils_params->fils.kek_len = fils_kek_len; |
| 6101 | fils_params->fils.pmk = pmk; |
| 6102 | fils_params->fils.pmk_len = pmk_len; |
| 6103 | fils_params->fils.pmkid = pmkid; |
| 6104 | hdd_debug("FILS erp_next_seq_num:%d", |
| 6105 | fils_params->fils.erp_next_seq_num); |
| 6106 | } |
| 6107 | #endif /* CFG80211_CONNECT_DONE */ |
| 6108 | |
| 6109 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 6110 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 6111 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6112 | void hdd_update_hlp_info(struct net_device *dev, |
| 6113 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6114 | { |
| 6115 | struct sk_buff *skb; |
| 6116 | uint16_t skb_len; |
| 6117 | struct llc_snap_hdr_t *llc_hdr; |
| 6118 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6119 | uint8_t *hlp_data; |
| 6120 | uint16_t hlp_data_len; |
| 6121 | struct fils_join_rsp_params *roam_fils_params |
| 6122 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6123 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6124 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6125 | if (!roam_fils_params) { |
| 6126 | hdd_err("FILS Roam Param NULL"); |
| 6127 | return; |
| 6128 | } |
| 6129 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 6130 | if (!roam_fils_params->hlp_data_len) { |
Jianmin Zhu | cc6b3d0 | 2019-03-07 14:19:34 +0800 | [diff] [blame] | 6131 | hdd_debug("FILS HLP Data NULL, len %d", |
| 6132 | roam_fils_params->hlp_data_len); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6133 | return; |
| 6134 | } |
| 6135 | |
| 6136 | hlp_data = roam_fils_params->hlp_data; |
| 6137 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 6138 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6139 | /* Calculate skb length */ |
| 6140 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 6141 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 6142 | if (!skb) { |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6143 | hdd_err("HLP packet nbuf alloc fails"); |
| 6144 | return; |
| 6145 | } |
| 6146 | |
| 6147 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 6148 | QDF_MAC_ADDR_SIZE); |
| 6149 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 6150 | QDF_MAC_ADDR_SIZE); |
| 6151 | |
| 6152 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 6153 | if (IS_SNAP(llc_hdr)) { |
| 6154 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6155 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6156 | } |
| 6157 | |
| 6158 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 6159 | |
| 6160 | /* |
| 6161 | * This HLP packet is formed from HLP info encapsulated |
| 6162 | * in assoc response frame which is AEAD encrypted. |
| 6163 | * Hence, this checksum validation can be set unnecessary. |
| 6164 | * i.e. network layer need not worry about checksum. |
| 6165 | */ |
| 6166 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 6167 | |
| 6168 | status = hdd_rx_packet_cbk(padapter, skb); |
| 6169 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6170 | hdd_err("Sending HLP packet fails"); |
| 6171 | return; |
| 6172 | } |
| 6173 | hdd_debug("send HLP packet to netif successfully"); |
| 6174 | } |
| 6175 | |
| 6176 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6177 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 6178 | * @dev: network device |
| 6179 | * @bssid: bssid to which we want to associate |
| 6180 | * @bss: cfg80211 bss info |
| 6181 | * @roam_info: information about connected bss |
| 6182 | * @req_ie: Request Information Element |
| 6183 | * @req_ie_len: len of the req IE |
| 6184 | * @resp_ie: Response IE |
| 6185 | * @resp_ie_len: len of ht response IE |
| 6186 | * @status: status |
| 6187 | * @gfp: allocation flags |
| 6188 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6189 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6190 | * |
| 6191 | * This API is used as wrapper to send FILS key/sequence number |
| 6192 | * params etc. to supplicant in case of FILS connection |
| 6193 | * |
| 6194 | * Return: None |
| 6195 | */ |
| 6196 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6197 | struct cfg80211_bss *bss, |
| 6198 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6199 | const u8 *req_ie, size_t req_ie_len, |
| 6200 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6201 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6202 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6203 | { |
| 6204 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6205 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6206 | struct fils_join_rsp_params *roam_fils_params = |
| 6207 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6208 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6209 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 6210 | |
| 6211 | if (!roam_fils_params) { |
| 6212 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 6213 | } else { |
| 6214 | fils_params.status = status; |
| 6215 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 6216 | fils_params.timeout_reason = |
| 6217 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6218 | fils_params.req_ie = req_ie; |
| 6219 | fils_params.req_ie_len = req_ie_len; |
| 6220 | fils_params.resp_ie = resp_ie; |
| 6221 | fils_params.resp_ie_len = resp_ie_len; |
| 6222 | fils_params.bss = bss; |
| 6223 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 6224 | roam_fils_params->kek_len, |
| 6225 | roam_fils_params->fils_pmk, |
| 6226 | roam_fils_params->fils_pmk_len, |
| 6227 | roam_fils_params->fils_pmkid, |
| 6228 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 6229 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6230 | } |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6231 | hdd_debug("FILS indicate connect status %d", fils_params.status); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6232 | |
| 6233 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 6234 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6235 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6236 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6237 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6238 | /* Clear all the FILS key info */ |
| 6239 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 6240 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 6241 | if (roam_fils_params) |
| 6242 | qdf_mem_free(roam_fils_params); |
| 6243 | roam_info->fils_join_rsp = NULL; |
| 6244 | } |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6245 | #else /* CFG80211_CONNECT_DONE */ |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6246 | static inline void |
| 6247 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6248 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6249 | const u8 *req_ie, size_t req_ie_len, |
| 6250 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 6251 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6252 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6253 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6254 | #endif |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6255 | #endif /* WLAN_FEATURE_FILS_SK */ |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6256 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6257 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 6258 | (defined(CFG80211_CONNECT_DONE) || \ |
| 6259 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6260 | /** |
| 6261 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 6262 | * supplicant. |
| 6263 | * @dev: network device |
| 6264 | * @bssid: bssid to which we want to associate |
| 6265 | * @bss: cfg80211 bss info |
| 6266 | * @roam_info: information about connected bss |
| 6267 | * @req_ie: Request Information Element |
| 6268 | * @req_ie_len: len of the req IE |
| 6269 | * @resp_ie: Response IE |
| 6270 | * @resp_ie_len: len of ht response IE |
| 6271 | * @status: status |
| 6272 | * @gfp: allocation flags |
| 6273 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6274 | * @timeout_reason: reason for connect timeout |
| 6275 | * |
| 6276 | * The API is a wrapper to send connection status to supplicant |
| 6277 | * |
| 6278 | * Return: 0 if success else failure |
| 6279 | */ |
| 6280 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 6281 | const u8 *bssid, |
| 6282 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6283 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6284 | size_t req_ie_len, const u8 *resp_ie, |
| 6285 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6286 | bool connect_timeout, |
| 6287 | tSirResultCodes timeout_reason) |
| 6288 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6289 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6290 | if (!roam_info || !roam_info->is_fils_connection) |
| 6291 | return -EINVAL; |
| 6292 | |
| 6293 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 6294 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6295 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6296 | return 0; |
| 6297 | } |
| 6298 | #else |
| 6299 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 6300 | const u8 *bssid, |
| 6301 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6302 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6303 | size_t req_ie_len, const u8 *resp_ie, |
| 6304 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6305 | bool connect_timeout, |
| 6306 | tSirResultCodes timeout_reason) |
| 6307 | { |
| 6308 | return -EINVAL; |
| 6309 | } |
| 6310 | #endif |
| 6311 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6312 | /** |
| 6313 | * hdd_connect_result() - API to send connection status to supplicant |
| 6314 | * @dev: network device |
| 6315 | * @bssid: bssid to which we want to associate |
| 6316 | * @roam_info: information about connected bss |
| 6317 | * @req_ie: Request Information Element |
| 6318 | * @req_ie_len: len of the req IE |
| 6319 | * @resp_ie: Response IE |
| 6320 | * @resp_ie_len: len of ht response IE |
| 6321 | * @status: status |
| 6322 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6323 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6324 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6325 | * |
| 6326 | * The API is a wrapper to send connection status to supplicant |
| 6327 | * and allow runtime suspend |
| 6328 | * |
| 6329 | * Return: Void |
| 6330 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6331 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6332 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6333 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6334 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6335 | bool connect_timeout, |
| 6336 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6337 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6338 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6339 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 6340 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6341 | |
| 6342 | if (WLAN_STATUS_SUCCESS == status) { |
| 6343 | struct ieee80211_channel *chan; |
| 6344 | int freq; |
| 6345 | int chan_no = roam_info->pBssDesc->channelId; |
| 6346 | |
| 6347 | if (chan_no <= 14) |
| 6348 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6349 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6350 | else |
| 6351 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6352 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6353 | |
| 6354 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
Abhishek Singh | 59cdca1 | 2019-03-08 13:48:20 +0530 | [diff] [blame] | 6355 | bss = wlan_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6356 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 6357 | roam_info->u.pConnectedProfile->SSID.length); |
| 6358 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6359 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6360 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 6361 | roam_info, req_ie, req_ie_len, resp_ie, |
| 6362 | resp_ie_len, status, gfp, connect_timeout, |
| 6363 | timeout_reason) != 0) { |
| 6364 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 6365 | req_ie_len, resp_ie, resp_ie_len, |
| 6366 | status, gfp, connect_timeout, timeout_reason); |
| 6367 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6368 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6369 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6370 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6371 | } |
| 6372 | #else |
| 6373 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6374 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6375 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6376 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6377 | bool connect_timeout, |
| 6378 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6379 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6380 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 6381 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6382 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6383 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 6384 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 6385 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6386 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6387 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6388 | } |
| 6389 | #endif |
| 6390 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6391 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6392 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 6393 | uint32_t bandwidth) |
| 6394 | { |
| 6395 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6396 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 6397 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 6398 | QDF_STATUS status; |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6399 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6400 | struct qdf_mac_addr bssid; |
| 6401 | struct csr_roam_profile roam_profile; |
| 6402 | struct ch_params ch_params; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6403 | eConnectionState connstate; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6404 | |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6405 | if (hdd_get_conparam() != QDF_GLOBAL_MONITOR_MODE && |
| 6406 | adapter->device_mode != QDF_STA_MODE) { |
| 6407 | 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] | 6408 | return -EINVAL; |
| 6409 | } |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6410 | if (adapter->device_mode == QDF_STA_MODE && |
Pragaspathi Thilagaraj | a889375 | 2019-02-06 19:58:59 +0530 | [diff] [blame] | 6411 | ucfg_mlme_is_change_channel_bandwidth_enabled(hdd_ctx->psoc)) { |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6412 | connstate = sta_ctx->conn_info.conn_state; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6413 | if (eConnectionState_Associated == connstate || |
| 6414 | eConnectionState_Connecting == connstate) { |
| 6415 | return -EINVAL; |
| 6416 | } |
| 6417 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6418 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 6419 | /* Validate Channel */ |
| 6420 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6421 | hdd_err("Channel %d Not supported", chan); |
| 6422 | return -EINVAL; |
| 6423 | } |
| 6424 | |
| 6425 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 6426 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 6427 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 6428 | return -EINVAL; |
| 6429 | } |
| 6430 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 6431 | (bandwidth != CH_WIDTH_MAX)) { |
| 6432 | hdd_err("Only BW20 possible on channel 14"); |
| 6433 | return -EINVAL; |
| 6434 | } |
| 6435 | } |
| 6436 | |
| 6437 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6438 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 6439 | (bandwidth != CH_WIDTH_MAX)) { |
| 6440 | hdd_err("Only BW20 possible on channel 165"); |
| 6441 | return -EINVAL; |
| 6442 | } |
| 6443 | } |
| 6444 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6445 | hdd_debug("Set monitor mode Channel %d", chan); |
| 6446 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 6447 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 6448 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 6449 | roam_profile.phyMode = ch_info->phy_mode; |
| 6450 | roam_profile.ch_params.ch_width = bandwidth; |
| 6451 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
Pragaspathi Thilagaraj | a889375 | 2019-02-06 19:58:59 +0530 | [diff] [blame] | 6452 | if (ucfg_mlme_is_change_channel_bandwidth_enabled(hdd_ctx->psoc) && |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6453 | (!sme_find_session_by_bssid(mac_handle, adapter->mac_addr.bytes))) { |
| 6454 | status = sme_create_mon_session(mac_handle, |
Rajeev Kumar Sirasanagandla | e3b5991 | 2018-08-24 15:53:31 +0530 | [diff] [blame] | 6455 | adapter->mac_addr.bytes, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6456 | adapter->vdev_id); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6457 | if (status != QDF_STATUS_SUCCESS) { |
| 6458 | hdd_err("Status: %d Failed to create session.", |
| 6459 | status); |
| 6460 | return qdf_status_to_os_return(status); |
| 6461 | } |
| 6462 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6463 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 6464 | QDF_MAC_ADDR_SIZE); |
| 6465 | |
| 6466 | ch_params.ch_width = bandwidth; |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6467 | wlan_reg_set_channel_params(hdd_ctx->pdev, chan, 0, &ch_params); |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6468 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 6469 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 6470 | return -EINVAL; |
| 6471 | } |
| 6472 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 6473 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 6474 | hdd_err("Failed to change hw mode"); |
| 6475 | return -EINVAL; |
| 6476 | } |
| 6477 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 6478 | status = sme_roam_channel_change_req(hdd_ctx->mac_handle, |
| 6479 | bssid, &ch_params, |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6480 | &roam_profile); |
| 6481 | if (status) { |
| 6482 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 6483 | status); |
| 6484 | } |
| 6485 | |
| 6486 | adapter->mon_chan = chan; |
| 6487 | adapter->mon_bandwidth = bandwidth; |
| 6488 | return qdf_status_to_os_return(status); |
| 6489 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6490 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6491 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6492 | #ifdef MSM_PLATFORM |
| 6493 | /** |
| 6494 | * hdd_stop_p2p_go() - call cfg80211 API to stop P2P GO |
| 6495 | * @adapter: pointer to adapter |
| 6496 | * |
| 6497 | * This function calls cfg80211 API to stop P2P GO |
| 6498 | * |
| 6499 | * Return: None |
| 6500 | */ |
| 6501 | static void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6502 | { |
| 6503 | hdd_debug("[SSR] send stop ap to supplicant"); |
| 6504 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 6505 | } |
| 6506 | |
| 6507 | static inline void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6508 | { |
| 6509 | } |
| 6510 | #else |
| 6511 | static inline void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6512 | { |
| 6513 | } |
| 6514 | |
| 6515 | /** |
| 6516 | * hdd_delete_sta() - call cfg80211 API to delete STA |
| 6517 | * @adapter: pointer to adapter |
| 6518 | * |
| 6519 | * This function calls cfg80211 API to delete STA |
| 6520 | * |
| 6521 | * Return: None |
| 6522 | */ |
| 6523 | static void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6524 | { |
| 6525 | struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT; |
| 6526 | |
| 6527 | hdd_debug("[SSR] send restart supplicant"); |
| 6528 | /* event supplicant to restart */ |
| 6529 | cfg80211_del_sta(adapter->dev, |
| 6530 | (const u8 *)&bcast_mac.bytes[0], |
| 6531 | GFP_KERNEL); |
| 6532 | } |
| 6533 | #endif |
| 6534 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6535 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6536 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6537 | struct hdd_adapter *adapter; |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6538 | eConnectionState conn_state; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6539 | bool value; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6540 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6541 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6542 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6543 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6544 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6545 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6546 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6547 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 6548 | qdf_opmode_str(adapter->device_mode), |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6549 | adapter->device_mode); |
| 6550 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6551 | hdd_wmm_init(adapter); |
| 6552 | |
| 6553 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6554 | case QDF_STA_MODE: |
| 6555 | case QDF_P2P_CLIENT_MODE: |
| 6556 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6557 | |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6558 | conn_state = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 6559 | ->conn_info.conn_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6560 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6561 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6562 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 6563 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6564 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6565 | /* Indicate disconnect event to supplicant |
| 6566 | * if associated previously |
| 6567 | */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6568 | if (eConnectionState_Associated == conn_state || |
| 6569 | eConnectionState_IbssConnected == conn_state || |
| 6570 | eConnectionState_NotConnected == conn_state || |
| 6571 | eConnectionState_IbssDisconnected == conn_state || |
| 6572 | eConnectionState_Disconnecting == conn_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6573 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6574 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6575 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6576 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6577 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 6578 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 6579 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 6580 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 6581 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6582 | |
| 6583 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 6584 | wlan_hdd_cfg80211_indicate_disconnect( |
| 6585 | adapter->dev, false, |
| 6586 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6587 | } else if (eConnectionState_Connecting == conn_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6588 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6589 | * Indicate connect failure to supplicant if we |
| 6590 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6591 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6592 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6593 | NULL, 0, NULL, 0, |
| 6594 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6595 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6596 | } |
| 6597 | |
| 6598 | hdd_register_tx_flow_control(adapter, |
| 6599 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6600 | hdd_tx_resume_cb, |
| 6601 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6602 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 6603 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6604 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6605 | break; |
| 6606 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6607 | case QDF_SAP_MODE: |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 6608 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6609 | &value); |
| 6610 | if (value) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6611 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6612 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6613 | break; |
| 6614 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6615 | case QDF_P2P_GO_MODE: |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6616 | hdd_delete_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6617 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6618 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6619 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6620 | hdd_set_mon_rx_cb(adapter->dev); |
| 6621 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6622 | adapter->mon_bandwidth); |
| 6623 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6624 | default: |
| 6625 | break; |
| 6626 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6627 | /* |
| 6628 | * Action frame registered in one adapter which will |
| 6629 | * applicable to all interfaces |
| 6630 | */ |
| 6631 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6632 | } |
| 6633 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6634 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6635 | if (!hdd_is_interface_up(adapter)) |
| 6636 | continue; |
| 6637 | |
| 6638 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 6639 | hdd_stop_p2p_go(adapter); |
| 6640 | } |
| 6641 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6642 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6643 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6644 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6645 | } |
| 6646 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6647 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6648 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6649 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6650 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6651 | qdf_list_node_t *node; |
| 6652 | |
| 6653 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6654 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6655 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6656 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6657 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6658 | |
| 6659 | if (QDF_IS_STATUS_ERROR(status)) |
| 6660 | return status; |
| 6661 | |
| 6662 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6663 | |
| 6664 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6665 | } |
| 6666 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6667 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6668 | struct hdd_adapter *current_adapter, |
| 6669 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6670 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6671 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6672 | qdf_list_node_t *node; |
| 6673 | |
| 6674 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6675 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6676 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6677 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6678 | ¤t_adapter->node, |
| 6679 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6680 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6681 | |
| 6682 | if (QDF_IS_STATUS_ERROR(status)) |
| 6683 | return status; |
| 6684 | |
| 6685 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6686 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6687 | return status; |
| 6688 | } |
| 6689 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6690 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6691 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6692 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6693 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6694 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6695 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6696 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6697 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6698 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6699 | return status; |
| 6700 | } |
| 6701 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6702 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6703 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6704 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6705 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6706 | qdf_list_node_t *node; |
| 6707 | |
| 6708 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6709 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6710 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6711 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6712 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6713 | |
| 6714 | if (QDF_IS_STATUS_ERROR(status)) |
| 6715 | return status; |
| 6716 | |
| 6717 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6718 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6719 | return status; |
| 6720 | } |
| 6721 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6722 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6723 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6724 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6725 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6726 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6727 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6728 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6729 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6730 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6731 | return status; |
| 6732 | } |
| 6733 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6734 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6735 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6736 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6737 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6738 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6739 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6740 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6741 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6742 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6743 | return status; |
| 6744 | } |
| 6745 | |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 6746 | struct hdd_adapter *hdd_get_adapter_by_rand_macaddr( |
| 6747 | struct hdd_context *hdd_ctx, tSirMacAddr mac_addr) |
| 6748 | { |
| 6749 | struct hdd_adapter *adapter; |
| 6750 | |
| 6751 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6752 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6753 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6754 | adapter->device_mode == QDF_P2P_DEVICE_MODE) && |
| 6755 | ucfg_p2p_check_random_mac(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6756 | adapter->vdev_id, mac_addr)) |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 6757 | return adapter; |
| 6758 | } |
| 6759 | |
| 6760 | return NULL; |
| 6761 | } |
| 6762 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6763 | 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] | 6764 | tSirMacAddr mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6765 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6766 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6767 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6768 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6769 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 6770 | mac_addr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6771 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6772 | } |
| 6773 | |
| 6774 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6775 | } |
| 6776 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6777 | 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] | 6778 | uint32_t vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6779 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6780 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6781 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6782 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6783 | if (adapter->vdev_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6784 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6785 | } |
| 6786 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6787 | return NULL; |
| 6788 | } |
| 6789 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6790 | 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] | 6791 | const char *iface_name) |
| 6792 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6793 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6794 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6795 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6796 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6797 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6798 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6799 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6800 | return NULL; |
| 6801 | } |
| 6802 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6803 | /** |
| 6804 | * hdd_get_adapter() - to get adapter matching the mode |
| 6805 | * @hdd_ctx: hdd context |
| 6806 | * @mode: adapter mode |
| 6807 | * |
| 6808 | * This routine will return the pointer to adapter matching |
| 6809 | * with the passed mode. |
| 6810 | * |
| 6811 | * Return: pointer to adapter or null |
| 6812 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6813 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6814 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6815 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6816 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6817 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6818 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6819 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6820 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6821 | } |
| 6822 | |
| 6823 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6824 | } |
| 6825 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 6826 | enum QDF_OPMODE hdd_get_device_mode(uint32_t vdev_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6827 | { |
| 6828 | struct hdd_context *hdd_ctx; |
| 6829 | struct hdd_adapter *adapter; |
| 6830 | |
| 6831 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6832 | if (!hdd_ctx) { |
| 6833 | hdd_err("Invalid HDD context"); |
| 6834 | return QDF_MAX_NO_OF_MODE; |
| 6835 | } |
| 6836 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 6837 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6838 | if (!adapter) { |
| 6839 | hdd_err("Invalid HDD adapter"); |
| 6840 | return QDF_MAX_NO_OF_MODE; |
| 6841 | } |
| 6842 | |
| 6843 | return adapter->device_mode; |
| 6844 | } |
| 6845 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6846 | /** |
| 6847 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6848 | * @hdd_ctx: Pointer to the HDD context. |
| 6849 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6850 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6851 | * QDF_STA_MODE, |
| 6852 | * QDF_P2P_CLIENT_MODE, |
| 6853 | * QDF_SAP_MODE, |
| 6854 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6855 | * |
| 6856 | * This API returns the operating channel of the requested device mode |
| 6857 | * |
| 6858 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6859 | * not connected. |
| 6860 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6861 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6862 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6863 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6864 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6865 | uint8_t operatingChannel = 0; |
| 6866 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6867 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6868 | if (mode == adapter->device_mode) { |
| 6869 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6870 | case QDF_STA_MODE: |
| 6871 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6872 | if (hdd_conn_is_connected |
| 6873 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6874 | (adapter))) { |
| 6875 | operatingChannel = |
| 6876 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6877 | (adapter))->conn_info. |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 6878 | channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6879 | } |
| 6880 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6881 | case QDF_SAP_MODE: |
| 6882 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6883 | /* softap connection info */ |
| 6884 | if (test_bit |
| 6885 | (SOFTAP_BSS_STARTED, |
| 6886 | &adapter->event_flags)) |
| 6887 | operatingChannel = |
| 6888 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6889 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6890 | break; |
| 6891 | default: |
| 6892 | break; |
| 6893 | } |
| 6894 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6895 | /* Found the device of interest. break the loop */ |
| 6896 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6897 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6898 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6899 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6900 | return operatingChannel; |
| 6901 | } |
| 6902 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6903 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6904 | hdd_ctx) |
| 6905 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6906 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6907 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6908 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6909 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6910 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6911 | if (adapter->device_mode == QDF_STA_MODE || |
| 6912 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6913 | adapter->device_mode == QDF_IBSS_MODE || |
| 6914 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6915 | adapter->device_mode == QDF_SAP_MODE || |
| 6916 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6917 | hdd_unregister_wext(adapter->dev); |
| 6918 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6919 | } |
| 6920 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6921 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6922 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6923 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6924 | } |
| 6925 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6926 | 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] | 6927 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6928 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6929 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6930 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6931 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6932 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6933 | if (adapter->device_mode == QDF_STA_MODE || |
| 6934 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6935 | adapter->device_mode == QDF_IBSS_MODE || |
| 6936 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6937 | adapter->device_mode == QDF_SAP_MODE || |
| 6938 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6939 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6940 | adapter->vdev_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6941 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6942 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6943 | } |
| 6944 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6945 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6946 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6947 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6948 | } |
| 6949 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6950 | /** |
| 6951 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6952 | * adapters |
| 6953 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6954 | * |
| 6955 | * return: QDF_STATUS_SUCCESS |
| 6956 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6957 | 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] | 6958 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6959 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6960 | int err; |
| 6961 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6962 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6963 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6964 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6965 | if (adapter->device_mode == QDF_STA_MODE || |
| 6966 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6967 | adapter->device_mode == QDF_IBSS_MODE || |
| 6968 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6969 | adapter->device_mode == QDF_SAP_MODE || |
| 6970 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6971 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6972 | if (err) |
| 6973 | hdd_err("Unable to stop scheduled scan"); |
| 6974 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6975 | } |
| 6976 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6977 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6978 | |
| 6979 | return QDF_STATUS_SUCCESS; |
| 6980 | } |
| 6981 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6982 | #ifdef WLAN_NS_OFFLOAD |
| 6983 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6984 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6985 | * @hdd_ctx: Pointer to hdd context |
| 6986 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6987 | * Unregister for IPv6 address change notifications. |
| 6988 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6989 | * Return: None |
| 6990 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6991 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6992 | { |
| 6993 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6994 | } |
| 6995 | |
| 6996 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6997 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6998 | * @hdd_ctx: Pointer to hdd context |
| 6999 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7000 | * Register for IPv6 address change notifications. |
| 7001 | * |
| 7002 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7003 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7004 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7005 | { |
| 7006 | int ret; |
| 7007 | |
| 7008 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 7009 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7010 | if (ret) { |
| 7011 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 7012 | goto out; |
| 7013 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7014 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7015 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7016 | out: |
| 7017 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7018 | } |
| 7019 | #else |
| 7020 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7021 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7022 | * @hdd_ctx: Pointer to hdd context |
| 7023 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7024 | * Unregister for IPv6 address change notifications. |
| 7025 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7026 | * Return: None |
| 7027 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7028 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7029 | { |
| 7030 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7031 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7032 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7033 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7034 | * @hdd_ctx: Pointer to hdd context |
| 7035 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7036 | * Register for IPv6 address change notifications. |
| 7037 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7038 | * Return: None |
| 7039 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7040 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7041 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7042 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7043 | } |
| 7044 | #endif |
| 7045 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7046 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 7047 | { |
| 7048 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 7049 | adapter->disconnection_in_progress = status; |
| 7050 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 7051 | hdd_debug("setting disconnection status: %d", status); |
| 7052 | } |
| 7053 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7054 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7055 | * hdd_register_notifiers - Register netdev notifiers. |
| 7056 | * @hdd_ctx: HDD context |
| 7057 | * |
| 7058 | * Register netdev notifiers like IPv4 and IPv6. |
| 7059 | * |
| 7060 | * Return: 0 on success and errno on failure |
| 7061 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7062 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7063 | { |
| 7064 | int ret; |
| 7065 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7066 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 7067 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7068 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7069 | |
| 7070 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 7071 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 7072 | if (ret) { |
| 7073 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 7074 | goto unregister_ip6_notifier; |
| 7075 | } |
| 7076 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7077 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 7078 | if (ret) { |
| 7079 | hdd_err("Failed to register netevent notifier: %d", |
| 7080 | ret); |
| 7081 | goto unregister_inetaddr_notifier; |
| 7082 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7083 | return 0; |
| 7084 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7085 | unregister_inetaddr_notifier: |
| 7086 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7087 | unregister_ip6_notifier: |
| 7088 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7089 | out: |
| 7090 | return ret; |
| 7091 | |
| 7092 | } |
| 7093 | |
| 7094 | /** |
| 7095 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 7096 | * @hdd_ctx: HDD context |
| 7097 | * |
| 7098 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 7099 | * |
| 7100 | * Return: None. |
| 7101 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7102 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7103 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7104 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7105 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 7106 | |
| 7107 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7108 | } |
| 7109 | |
| 7110 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7111 | * hdd_exit_netlink_services - Exit netlink services |
| 7112 | * @hdd_ctx: HDD context |
| 7113 | * |
| 7114 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7115 | * nl service. |
| 7116 | * |
| 7117 | * Return: None. |
| 7118 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7119 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7120 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7121 | spectral_scan_deactivate_service(); |
| 7122 | cnss_diag_deactivate_service(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7123 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7124 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7125 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7126 | |
| 7127 | nl_srv_exit(); |
| 7128 | } |
| 7129 | |
| 7130 | /** |
| 7131 | * hdd_init_netlink_services- Init netlink services |
| 7132 | * @hdd_ctx: HDD context |
| 7133 | * |
| 7134 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7135 | * nl service. |
| 7136 | * |
| 7137 | * Return: 0 on success and errno on failure. |
| 7138 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7139 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7140 | { |
| 7141 | int ret; |
| 7142 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7143 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7144 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7145 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7146 | goto out; |
| 7147 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7148 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7149 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 7150 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7151 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7152 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7153 | goto err_nl_srv; |
| 7154 | } |
| 7155 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7156 | ptt_sock_activate_svc(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7157 | |
| 7158 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 7159 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7160 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7161 | |
| 7162 | ret = cnss_diag_activate_service(); |
| 7163 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7164 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7165 | goto err_close_cesium; |
| 7166 | } |
| 7167 | |
Dustin Brown | 0152085 | 2019-02-27 12:14:16 -0800 | [diff] [blame] | 7168 | spectral_scan_activate_service(hdd_ctx); |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 7169 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7170 | return 0; |
| 7171 | |
| 7172 | err_close_cesium: |
| 7173 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7174 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7175 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7176 | err_nl_srv: |
| 7177 | nl_srv_exit(); |
| 7178 | out: |
| 7179 | return ret; |
| 7180 | } |
| 7181 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7182 | /** |
| 7183 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 7184 | * @hdd_ctx: HDD context. |
| 7185 | * |
| 7186 | * Destroy RX wakelock. |
| 7187 | * |
| 7188 | * Return: None. |
| 7189 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7190 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7191 | { |
| 7192 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 7193 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7194 | |
| 7195 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7196 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 7197 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7198 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7199 | * Create RX wakelock. |
| 7200 | * |
| 7201 | * Return: None. |
| 7202 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7203 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7204 | { |
| 7205 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 7206 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7207 | |
| 7208 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7209 | * hdd_context_deinit() - Deinitialize HDD context |
| 7210 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7211 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7212 | * Deinitialize HDD context along with all the feature specific contexts but |
| 7213 | * do not free hdd context itself. Caller of this API is supposed to free |
| 7214 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7215 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7216 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7217 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7218 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7219 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7220 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 7221 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7222 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7223 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7224 | hdd_sap_context_destroy(hdd_ctx); |
| 7225 | |
| 7226 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 7227 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7228 | hdd_scan_context_destroy(hdd_ctx); |
| 7229 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 7230 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7231 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7232 | return 0; |
| 7233 | } |
| 7234 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7235 | void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7236 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 7237 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 7238 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7239 | hdd_exit_netlink_services(hdd_ctx); |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 7240 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 7241 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7242 | hdd_context_deinit(hdd_ctx); |
| 7243 | |
Dustin Brown | db2df2e | 2018-10-31 15:29:24 -0700 | [diff] [blame] | 7244 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 7245 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7246 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7247 | hdd_ctx->config = NULL; |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 7248 | cfg_release(); |
| 7249 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7250 | wiphy_free(hdd_ctx->wiphy); |
| 7251 | } |
| 7252 | |
| 7253 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7254 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 7255 | * |
| 7256 | * This function is used to destroy bug report lock |
| 7257 | * |
| 7258 | * Return: None |
| 7259 | */ |
| 7260 | static void wlan_destroy_bug_report_lock(void) |
| 7261 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 7262 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7263 | |
| 7264 | p_cds_context = cds_get_global_context(); |
| 7265 | if (!p_cds_context) { |
| 7266 | hdd_err("cds context is NULL"); |
| 7267 | return; |
| 7268 | } |
| 7269 | |
| 7270 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 7271 | } |
| 7272 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7273 | #ifdef DISABLE_CHANNEL_LIST |
| 7274 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7275 | { |
| 7276 | qdf_mutex_destroy(&hdd_ctx->cache_channel_lock); |
| 7277 | } |
| 7278 | #else |
| 7279 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7280 | { |
| 7281 | } |
| 7282 | #endif |
| 7283 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 7284 | void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7285 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7286 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7287 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7288 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7289 | |
Arun Kumar Khandavalli | deda5a8 | 2019-03-11 15:32:19 +0530 | [diff] [blame^] | 7290 | hdd_debugfs_mws_coex_info_deinit(hdd_ctx); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 7291 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Dustin Brown | 6470aba | 2018-09-05 09:49:58 -0700 | [diff] [blame] | 7292 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7293 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7294 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7295 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7296 | if (QDF_TIMER_STATE_RUNNING == |
| 7297 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 7298 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7299 | } |
| 7300 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7301 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7302 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 7303 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7304 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7305 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7306 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7307 | hdd_ctx->last_acs_channel_list = NULL; |
| 7308 | hdd_ctx->num_of_channels = 0; |
| 7309 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7310 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7311 | |
| 7312 | /* |
| 7313 | * Powersave Offload Case |
| 7314 | * Disable Idle Power Save Mode |
| 7315 | */ |
| 7316 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 7317 | /* clear the scan queue in all the scenarios */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7318 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7319 | |
Dustin Brown | f688ea1 | 2019-03-19 17:02:32 -0700 | [diff] [blame] | 7320 | if (hdd_ctx->driver_status != DRIVER_MODULES_CLOSED) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7321 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 7322 | /* |
| 7323 | * Cancel any outstanding scan requests. We are about to close |
| 7324 | * all of our adapters, but an adapter structure is what SME |
| 7325 | * passes back to our callback function. Hence if there |
| 7326 | * are any outstanding scan requests then there is a |
| 7327 | * race condition between when the adapter is closed and |
| 7328 | * when the callback is invoked. We try to resolve that |
| 7329 | * race condition here by canceling any outstanding scans |
| 7330 | * before we close the adapters. |
| 7331 | * Note that the scans may be cancelled in an asynchronous |
| 7332 | * manner, so ideally there needs to be some kind of |
| 7333 | * synchronization. Rather than introduce a new |
| 7334 | * synchronization here, we will utilize the fact that we are |
| 7335 | * about to Request Full Power, and since that is synchronized, |
| 7336 | * the expectation is that by the time Request Full Power has |
| 7337 | * completed, all scans will be cancelled |
| 7338 | */ |
| 7339 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7340 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 7341 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 7342 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7343 | } |
| 7344 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 7345 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7346 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 7347 | |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 7348 | qdf_dp_trace_deinit(); |
| 7349 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 7350 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 7351 | |
Visweswara Tanuku | c029a20 | 2018-11-27 10:42:10 +0530 | [diff] [blame] | 7352 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 7353 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 7354 | hdd_driver_memdump_deinit(); |
| 7355 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 7356 | qdf_nbuf_deinit_replenish_timer(); |
| 7357 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7358 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 7359 | hdd_info("Release wakelock for monitor mode!"); |
| 7360 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 7361 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 7362 | } |
| 7363 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7364 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7365 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7366 | wlan_hdd_cache_chann_mutex_destroy(hdd_ctx); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7367 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 7368 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7369 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 7370 | hdd_close_all_adapters(hdd_ctx, false); |
| 7371 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 7372 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7373 | /* |
| 7374 | * If there is re_init failure wiphy would have already de-registered |
| 7375 | * check the wiphy status before un-registering again |
| 7376 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 7377 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7378 | wiphy_unregister(wiphy); |
| 7379 | wlan_hdd_cfg80211_deinit(wiphy); |
| 7380 | hdd_lpass_notify_stop(hdd_ctx); |
| 7381 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 7382 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7383 | hdd_exit_netlink_services(hdd_ctx); |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 7384 | qdf_delayed_work_destroy(&hdd_ctx->psoc_idle_timeout_work); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7385 | #ifdef FEATURE_WLAN_CH_AVOID |
| 7386 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 7387 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7388 | } |
| 7389 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7390 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7391 | /** |
| 7392 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7393 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7394 | * |
| 7395 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 7396 | * Then new ACS request will do a fresh scan without reusing the cached |
| 7397 | * scan information. |
| 7398 | * |
| 7399 | * Return: void |
| 7400 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 7401 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7402 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7403 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7404 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7405 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7406 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7407 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7408 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7409 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7410 | hdd_ctx->last_acs_channel_list = NULL; |
| 7411 | hdd_ctx->num_of_channels = 0; |
| 7412 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7413 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7414 | mac_handle = hdd_ctx->mac_handle; |
| 7415 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7416 | return; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7417 | sme_scan_flush_result(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7418 | } |
| 7419 | #endif |
| 7420 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7421 | /** |
| 7422 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 7423 | * @state: state |
| 7424 | * |
| 7425 | * This function notifies FW with modem power status |
| 7426 | * |
| 7427 | * Return: 0 if successful, error number otherwise |
| 7428 | */ |
| 7429 | int hdd_wlan_notify_modem_power_state(int state) |
| 7430 | { |
| 7431 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7432 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7433 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7434 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7435 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7436 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7437 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7438 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7439 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7440 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7441 | mac_handle = hdd_ctx->mac_handle; |
| 7442 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7443 | return -EINVAL; |
| 7444 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7445 | qdf_status = sme_notify_modem_power_state(mac_handle, state); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7446 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7447 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7448 | state); |
| 7449 | return -EINVAL; |
| 7450 | } |
| 7451 | return 0; |
| 7452 | } |
| 7453 | |
| 7454 | /** |
| 7455 | * |
| 7456 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 7457 | * @adapter - Pointer to the HDD |
| 7458 | * |
| 7459 | * Return: None |
| 7460 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7461 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7462 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7463 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7464 | |
| 7465 | /* |
| 7466 | * Send ready indication to the HDD. This will kick off the MAC |
| 7467 | * into a 'running' state and should kick off an initial scan. |
| 7468 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7469 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->mac_handle); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7470 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7471 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 7472 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7473 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7474 | } |
| 7475 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7476 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7477 | } |
| 7478 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 7479 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 7480 | { |
| 7481 | struct hdd_adapter *adapter; |
| 7482 | |
| 7483 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7484 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 7485 | return adapter; |
| 7486 | } |
| 7487 | |
| 7488 | return NULL; |
| 7489 | } |
| 7490 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7491 | /* wake lock APIs for HDD */ |
| 7492 | void hdd_prevent_suspend(uint32_t reason) |
| 7493 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7494 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7495 | } |
| 7496 | |
| 7497 | void hdd_allow_suspend(uint32_t reason) |
| 7498 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7499 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7500 | } |
| 7501 | |
| 7502 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 7503 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 7504 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 7505 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7506 | } |
| 7507 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7508 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7509 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7510 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7511 | return sme_init_chan_list(hdd_ctx->mac_handle, |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 7512 | hdd_ctx->reg.alpha2, |
| 7513 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7514 | } |
| 7515 | |
| 7516 | /** |
| 7517 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 7518 | * @hdd_ctx: Pointer to the hdd context |
| 7519 | * |
| 7520 | * HDD function to know if hardware supports 5GHz |
| 7521 | * |
| 7522 | * Return: true if hardware supports 5GHz |
| 7523 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7524 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7525 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7526 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7527 | return true; |
| 7528 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7529 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7530 | return true; |
| 7531 | else |
| 7532 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7533 | } |
| 7534 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7535 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7536 | { |
| 7537 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7538 | int ret_val; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7539 | uint32_t channel_bonding_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7540 | |
| 7541 | wiphy = hdd_ctx->wiphy; |
| 7542 | |
| 7543 | /* |
| 7544 | * The channel information in |
| 7545 | * wiphy needs to be initialized before wiphy registration |
| 7546 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7547 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7548 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7549 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7550 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7551 | } |
| 7552 | |
| 7553 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7554 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7555 | #else |
| 7556 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7557 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7558 | WIPHY_WOWLAN_DISCONNECT | |
| 7559 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7560 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7561 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7562 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7563 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7564 | |
| 7565 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7566 | WOW_MAX_FILTERS_PER_LIST); |
| 7567 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7568 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7569 | #endif |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7570 | ucfg_mlme_get_channel_bonding_24ghz(hdd_ctx->psoc, |
| 7571 | &channel_bonding_mode); |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7572 | if (hdd_ctx->obss_scan_offload) { |
| 7573 | hdd_debug("wmi_service_obss_scan supported"); |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7574 | } else if (channel_bonding_mode) { |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7575 | hdd_debug("enable wpa_supp obss_scan"); |
| 7576 | wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; |
| 7577 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7578 | |
| 7579 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7580 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7581 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7582 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7583 | return ret_val; |
| 7584 | } |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7585 | |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7586 | /* Check the kernel version for upstream commit aced43ce780dc5 that |
| 7587 | * has support for processing user cell_base hints when wiphy is |
| 7588 | * self managed or check the backport flag for the same. |
| 7589 | */ |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7590 | #if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \ |
| 7591 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7592 | hdd_send_wiphy_regd_sync_event(hdd_ctx); |
| 7593 | #endif |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7594 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7595 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7596 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7597 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7598 | } |
| 7599 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7600 | #ifdef MSM_PLATFORM |
| 7601 | /** |
| 7602 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7603 | * @hdd_ctx - handle to hdd context |
| 7604 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7605 | * |
| 7606 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7607 | * Stats show up in wlan driver logs. |
| 7608 | * |
| 7609 | * Returns: None |
| 7610 | */ |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7611 | static void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7612 | bool data_in_interval) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7613 | { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7614 | static uint32_t counter; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7615 | static bool data_in_time_period; |
| 7616 | ol_txrx_pdev_handle pdev; |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7617 | ol_txrx_soc_handle soc; |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7618 | uint32_t periodic_stats_disp_time = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7619 | |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7620 | ucfg_mlme_stats_get_periodic_display_time(hdd_ctx->psoc, |
| 7621 | &periodic_stats_disp_time); |
| 7622 | if (!periodic_stats_disp_time) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7623 | return; |
| 7624 | |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7625 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 7626 | if (!soc) { |
| 7627 | hdd_err("soc is NULL"); |
| 7628 | return; |
| 7629 | } |
| 7630 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7631 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7632 | if (!pdev) { |
| 7633 | hdd_err("pdev is NULL"); |
| 7634 | return; |
| 7635 | } |
| 7636 | |
| 7637 | counter++; |
| 7638 | if (data_in_interval) |
| 7639 | data_in_time_period = data_in_interval; |
| 7640 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7641 | if (counter * hdd_ctx->config->bus_bw_compute_interval >= |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7642 | periodic_stats_disp_time * 1000) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7643 | if (data_in_time_period) { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7644 | wlan_hdd_display_txrx_stats(hdd_ctx); |
Mohit Khanna | c964965 | 2018-11-28 18:10:28 -0800 | [diff] [blame] | 7645 | dp_txrx_ext_dump_stats(soc, CDP_DP_RX_THREAD_STATS); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7646 | cdp_display_stats(soc, |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7647 | CDP_RX_RING_STATS, |
| 7648 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7649 | cdp_display_stats(soc, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7650 | CDP_TXRX_PATH_STATS, |
| 7651 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7652 | wlan_hdd_display_netif_queue_history |
| 7653 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7654 | qdf_dp_trace_dump_stats(); |
| 7655 | } |
| 7656 | counter = 0; |
| 7657 | data_in_time_period = false; |
| 7658 | } |
| 7659 | } |
| 7660 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7661 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7662 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7663 | * @hdd_ctx: pointer to struct hdd_context |
| 7664 | * |
| 7665 | * Return: none |
| 7666 | */ |
| 7667 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7668 | { |
| 7669 | struct hdd_adapter *adapter; |
| 7670 | |
| 7671 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7672 | hdd_send_rps_disable_ind(adapter); |
| 7673 | } |
| 7674 | |
| 7675 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7676 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7677 | * @hdd_ctx - handle to hdd context |
| 7678 | * @tx_packets - transmit packet count |
| 7679 | * @rx_packets - receive packet count |
| 7680 | * |
| 7681 | * The function controls the bus bandwidth and dynamic control of |
| 7682 | * tcp delayed ack configuration |
| 7683 | * |
| 7684 | * Returns: None |
| 7685 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7686 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7687 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7688 | const uint64_t tx_packets, |
| 7689 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7690 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7691 | u64 total_pkts = tx_packets + rx_packets; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7692 | uint64_t temp_tx = 0, avg_rx = 0; |
| 7693 | uint64_t no_rx_offload_pkts = 0, avg_no_rx_offload_pkts = 0; |
| 7694 | uint64_t rx_offload_pkts = 0, avg_rx_offload_pkts = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7695 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7696 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7697 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7698 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7699 | uint16_t index = 0; |
| 7700 | bool vote_level_change = false; |
| 7701 | bool rx_level_change = false; |
| 7702 | bool tx_level_change = false; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7703 | bool rxthread_high_tput_req = false; |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7704 | bool dptrace_high_tput_req; |
Srinivas Girigowda | 5033534 | 2018-09-07 15:21:01 -0700 | [diff] [blame] | 7705 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7706 | if (total_pkts > hdd_ctx->config->bus_bw_high_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7707 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7708 | else if (total_pkts > hdd_ctx->config->bus_bw_medium_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7709 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7710 | else if (total_pkts > hdd_ctx->config->bus_bw_low_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7711 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7712 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7713 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7714 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7715 | dptrace_high_tput_req = |
| 7716 | next_vote_level > PLD_BUS_WIDTH_NONE ? true : false; |
| 7717 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7718 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7719 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7720 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7721 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7722 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7723 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7724 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7725 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7726 | if (hdd_ctx->hbw_requested) { |
| 7727 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7728 | hdd_ctx->hbw_requested = false; |
| 7729 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7730 | if (hdd_ctx->dynamic_rps) |
| 7731 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7732 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7733 | if (!hdd_ctx->hbw_requested) { |
| 7734 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7735 | hdd_ctx->hbw_requested = true; |
| 7736 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7737 | if (hdd_ctx->dynamic_rps) |
| 7738 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7739 | } |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7740 | |
Manjunathappa Prakash | cb6df76 | 2018-05-29 18:54:58 -0700 | [diff] [blame] | 7741 | if (hdd_ctx->config->napi_cpu_affinity_mask) |
| 7742 | hdd_napi_apply_throughput_policy(hdd_ctx, |
| 7743 | tx_packets, |
| 7744 | rx_packets); |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7745 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7746 | if (rx_packets < hdd_ctx->config->bus_bw_low_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7747 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
| 7748 | else |
| 7749 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7750 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7751 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7752 | qdf_dp_trace_apply_tput_policy(dptrace_high_tput_req); |
| 7753 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7754 | /* |
| 7755 | * Includes tcp+udp, if perf core is required for tcp, then |
| 7756 | * perf core is also required for udp. |
| 7757 | */ |
| 7758 | no_rx_offload_pkts = hdd_ctx->no_rx_offload_pkt_cnt; |
| 7759 | hdd_ctx->no_rx_offload_pkt_cnt = 0; |
| 7760 | rx_offload_pkts = rx_packets - no_rx_offload_pkts; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7761 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7762 | avg_no_rx_offload_pkts = (no_rx_offload_pkts + |
| 7763 | hdd_ctx->prev_no_rx_offload_pkts) / 2; |
| 7764 | hdd_ctx->prev_no_rx_offload_pkts = no_rx_offload_pkts; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7765 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7766 | avg_rx_offload_pkts = (rx_offload_pkts + |
| 7767 | hdd_ctx->prev_rx_offload_pkts) / 2; |
| 7768 | hdd_ctx->prev_rx_offload_pkts = rx_offload_pkts; |
| 7769 | |
| 7770 | avg_rx = avg_no_rx_offload_pkts + avg_rx_offload_pkts; |
| 7771 | /* |
| 7772 | * Takes care to set Rx_thread affinity for below case |
| 7773 | * 1)LRO/GRO not supported ROME case |
| 7774 | * 2)when rx_ol is disabled in cases like concurrency etc |
| 7775 | * 3)For UDP cases |
| 7776 | */ |
| 7777 | if (avg_no_rx_offload_pkts > |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7778 | hdd_ctx->config->bus_bw_high_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7779 | rxthread_high_tput_req = true; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7780 | else |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7781 | rxthread_high_tput_req = false; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7782 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7783 | if (cds_sched_handle_throughput_req(rxthread_high_tput_req)) |
| 7784 | hdd_warn("Rx thread high_tput(%d) affinity request failed", |
| 7785 | rxthread_high_tput_req); |
| 7786 | |
| 7787 | /* fine-tuning parameters for RX Flows */ |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7788 | if (avg_rx > hdd_ctx->config->tcp_delack_thres_high) { |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7789 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7790 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7791 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7792 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7793 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7794 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7795 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7796 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7797 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7798 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7799 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7800 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7801 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Jeff Johnson | b9feee4 | 2018-07-08 10:34:48 -0700 | [diff] [blame] | 7802 | next_rx_level, avg_rx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7803 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7804 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7805 | /* Send throughput indication only if it is enabled. |
| 7806 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7807 | * to default delayed ack. Note that this will disable the |
| 7808 | * dynamic delayed ack mechanism across the system |
| 7809 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7810 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7811 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7812 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7813 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7814 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7815 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7816 | rx_tp_data.level = next_rx_level; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7817 | wlan_hdd_update_tcp_rx_param(hdd_ctx, &rx_tp_data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7818 | } |
| 7819 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7820 | /* fine-tuning parameters for TX Flows */ |
| 7821 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7822 | hdd_ctx->prev_tx = tx_packets; |
| 7823 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7824 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7825 | else |
| 7826 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7827 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7828 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7829 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7830 | struct wlan_tx_tp_data tx_tp_data = {0}; |
| 7831 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7832 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7833 | next_tx_level, temp_tx); |
| 7834 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7835 | tx_level_change = true; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7836 | tx_tp_data.level = next_tx_level; |
| 7837 | tx_tp_data.tcp_limit_output = true; |
| 7838 | wlan_hdd_update_tcp_tx_param(hdd_ctx, &tx_tp_data); |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7839 | } |
| 7840 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7841 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7842 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7843 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7844 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7845 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7846 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7847 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7848 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7849 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7850 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7851 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7852 | |
| 7853 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7854 | } |
| 7855 | |
| 7856 | #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] | 7857 | static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7858 | { |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7859 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7860 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7861 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7862 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7863 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7864 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7865 | bool connected = false; |
| 7866 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7867 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7868 | if (wlan_hdd_validate_context(hdd_ctx)) |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7869 | goto stop_work; |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7870 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7871 | if (hdd_ctx->is_wiphy_suspended) |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7872 | return; |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7873 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7874 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7875 | /* |
| 7876 | * Validate magic so we don't end up accessing |
| 7877 | * an invalid adapter. |
| 7878 | */ |
| 7879 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7880 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7881 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7882 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7883 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 7884 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.conn_state |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7885 | != eConnectionState_Associated) { |
| 7886 | |
| 7887 | continue; |
| 7888 | } |
| 7889 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7890 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7891 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7892 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7893 | |
| 7894 | continue; |
| 7895 | } |
| 7896 | |
| 7897 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7898 | adapter->prev_tx_packets); |
| 7899 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7900 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7901 | |
| 7902 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7903 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7904 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7905 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7906 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7907 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 7908 | adapter->vdev_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7909 | &fwd_tx_packets, &fwd_rx_packets); |
| 7910 | if (ret == A_OK) { |
| 7911 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7912 | fwd_tx_packets, |
| 7913 | adapter->prev_fwd_tx_packets); |
| 7914 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7915 | fwd_tx_packets, |
| 7916 | adapter->prev_fwd_rx_packets); |
| 7917 | } |
| 7918 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7919 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7920 | if (adapter->device_mode == QDF_SAP_MODE) |
| 7921 | con_sap_adapter = adapter; |
| 7922 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7923 | total_rx += adapter->stats.rx_packets; |
| 7924 | total_tx += adapter->stats.tx_packets; |
| 7925 | |
| 7926 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7927 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7928 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7929 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7930 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7931 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7932 | connected = true; |
| 7933 | } |
| 7934 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7935 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7936 | hdd_err("bus bandwidth timer running in disconnected state"); |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7937 | goto stop_work; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7938 | } |
| 7939 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7940 | /* add intra bss forwarded tx and rx packets */ |
| 7941 | tx_packets += fwd_tx_packets_diff; |
| 7942 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7943 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7944 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->pdev)) { |
| 7945 | ucfg_ipa_uc_stat_query(hdd_ctx->pdev, &ipa_tx_packets, |
| 7946 | &ipa_rx_packets); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7947 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7948 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7949 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7950 | if (con_sap_adapter) { |
| 7951 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 7952 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 7953 | } |
| 7954 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7955 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, tx_packets, rx_packets); |
| 7956 | ucfg_ipa_uc_stat_request(hdd_ctx->pdev, 2); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7957 | } |
| 7958 | |
| 7959 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7960 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7961 | return; |
| 7962 | |
| 7963 | stop_work: |
| 7964 | qdf_periodic_work_stop_async(&hdd_ctx->bus_bw_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7965 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7966 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7967 | static void hdd_bus_bw_work_handler(void *context) |
Rajeev Kumar | b2b5e69 | 2018-08-31 15:12:40 -0700 | [diff] [blame] | 7968 | { |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 7969 | struct hdd_context *hdd_ctx = context; |
| 7970 | struct qdf_op_sync *op_sync; |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7971 | |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 7972 | if (qdf_op_protect(&op_sync)) |
| 7973 | return; |
| 7974 | |
| 7975 | __hdd_bus_bw_work_handler(hdd_ctx); |
| 7976 | |
| 7977 | qdf_op_unprotect(op_sync); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7978 | } |
| 7979 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7980 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7981 | { |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7982 | QDF_STATUS status; |
| 7983 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7984 | hdd_enter(); |
| 7985 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7986 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7987 | status = qdf_periodic_work_create(&hdd_ctx->bus_bw_work, |
| 7988 | hdd_bus_bw_work_handler, |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 7989 | hdd_ctx); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7990 | |
| 7991 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7992 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7993 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7994 | } |
| 7995 | |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 7996 | void hdd_bus_bandwidth_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7997 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 7998 | hdd_enter(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7999 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8000 | QDF_BUG(!qdf_periodic_work_stop_sync(&hdd_ctx->bus_bw_work)); |
| 8001 | qdf_periodic_work_destroy(&hdd_ctx->bus_bw_work); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8002 | |
| 8003 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8004 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 8005 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8006 | #endif /* MSM_PLATFORM */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8007 | |
| 8008 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8009 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 8010 | * @hdd_ctx: hdd context |
| 8011 | * |
| 8012 | * Return: 0 for success or error code |
| 8013 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8014 | 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] | 8015 | { |
| 8016 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 8017 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8018 | if (!hdd_ctx->hdd_txrx_hist) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8019 | return -ENOMEM; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8020 | return 0; |
| 8021 | } |
| 8022 | |
| 8023 | /** |
| 8024 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 8025 | * @hdd_ctx: hdd context |
| 8026 | * |
| 8027 | * Return: none |
| 8028 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8029 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8030 | { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 8031 | if (!hdd_ctx || !hdd_ctx->hdd_txrx_hist) |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 8032 | return; |
| 8033 | |
| 8034 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 8035 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8036 | } |
| 8037 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8038 | static uint8_t *convert_level_to_string(uint32_t level) |
| 8039 | { |
| 8040 | switch (level) { |
| 8041 | /* initialize the wlan sub system */ |
| 8042 | case WLAN_SVC_TP_NONE: |
| 8043 | return "NONE"; |
| 8044 | case WLAN_SVC_TP_LOW: |
| 8045 | return "LOW"; |
| 8046 | case WLAN_SVC_TP_MEDIUM: |
| 8047 | return "MED"; |
| 8048 | case WLAN_SVC_TP_HIGH: |
| 8049 | return "HIGH"; |
| 8050 | default: |
| 8051 | return "INVAL"; |
| 8052 | } |
| 8053 | } |
| 8054 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8055 | |
| 8056 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8057 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 8058 | * @hdd_ctx: hdd context |
| 8059 | * |
| 8060 | * Return: none |
| 8061 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8062 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8063 | { |
| 8064 | int i; |
| 8065 | |
| 8066 | #ifdef MSM_PLATFORM |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8067 | hdd_nofl_info("BW compute Interval: %dms", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8068 | hdd_ctx->config->bus_bw_compute_interval); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8069 | 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] | 8070 | hdd_ctx->config->bus_bw_high_threshold, |
| 8071 | hdd_ctx->config->bus_bw_medium_threshold, |
| 8072 | hdd_ctx->config->bus_bw_low_threshold); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8073 | hdd_nofl_info("Enable TCP DEL ACK: %d", |
| 8074 | hdd_ctx->en_tcp_delack_no_lro); |
| 8075 | hdd_nofl_info("TCP DEL High TH: %d TCP DEL Low TH: %d", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8076 | hdd_ctx->config->tcp_delack_thres_high, |
| 8077 | hdd_ctx->config->tcp_delack_thres_low); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8078 | hdd_nofl_info("TCP TX HIGH TP TH: %d (Use to set tcp_output_bytes_limit)", |
| 8079 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8080 | #endif |
| 8081 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8082 | hdd_nofl_info("Total entries: %d Current index: %d", |
| 8083 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8084 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8085 | 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] | 8086 | |
| 8087 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8088 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 8089 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8090 | hdd_nofl_info("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 8091 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 8092 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 8093 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 8094 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8095 | hdd_ctx->hdd_txrx_hist[i]. |
| 8096 | next_vote_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8097 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8098 | hdd_ctx->hdd_txrx_hist[i]. |
| 8099 | next_rx_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8100 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8101 | hdd_ctx->hdd_txrx_hist[i]. |
| 8102 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8103 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8104 | } |
| 8105 | |
| 8106 | /** |
| 8107 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 8108 | * @hdd_ctx: hdd context |
| 8109 | * |
| 8110 | * Return: none |
| 8111 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8112 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8113 | { |
| 8114 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8115 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 8116 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8117 | } |
| 8118 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8119 | /* length of the netif queue log needed per adapter */ |
| 8120 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 8121 | |
| 8122 | /** |
| 8123 | * |
| 8124 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 8125 | * @hdd_ctx: hdd context |
| 8126 | * |
| 8127 | * Return: none |
| 8128 | */ |
| 8129 | static void |
| 8130 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 8131 | { |
| 8132 | int adapter_num = 0; |
| 8133 | int i; |
| 8134 | int bytes_written; |
| 8135 | u32 tbytes; |
| 8136 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8137 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8138 | char *comb_log_str; |
| 8139 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8140 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8141 | |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 8142 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * WLAN_MAX_VDEVS) + 1; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8143 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8144 | if (!comb_log_str) |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8145 | return; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8146 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8147 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8148 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8149 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8150 | curr_time = qdf_system_ticks(); |
| 8151 | total = curr_time - adapter->start_time; |
| 8152 | delta = curr_time - adapter->last_time; |
| 8153 | |
| 8154 | if (adapter->pause_map) { |
| 8155 | pause = adapter->total_pause_time + delta; |
| 8156 | unpause = adapter->total_unpause_time; |
| 8157 | } else { |
| 8158 | unpause = adapter->total_unpause_time + delta; |
| 8159 | pause = adapter->total_pause_time; |
| 8160 | } |
| 8161 | |
| 8162 | tbytes = 0; |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 8163 | qdf_mem_zero(temp_str, sizeof(temp_str)); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8164 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8165 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 8166 | continue; |
| 8167 | tbytes += |
| 8168 | snprintf( |
| 8169 | &temp_str[tbytes], |
| 8170 | (tbytes >= sizeof(temp_str) ? |
| 8171 | 0 : sizeof(temp_str) - tbytes), |
| 8172 | "%d(%d,%d) ", |
| 8173 | i, |
| 8174 | adapter->queue_oper_stats[i]. |
| 8175 | pause_count, |
| 8176 | adapter->queue_oper_stats[i]. |
| 8177 | unpause_count); |
| 8178 | } |
| 8179 | if (tbytes >= sizeof(temp_str)) |
| 8180 | hdd_warn("log truncated"); |
| 8181 | |
| 8182 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8183 | bytes_written >= comb_log_str_size ? 0 : |
| 8184 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8185 | "[%d %d] (%d) %u/%ums %s|", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8186 | adapter->vdev_id, adapter->device_mode, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8187 | adapter->pause_map, |
| 8188 | qdf_system_ticks_to_msecs(pause), |
| 8189 | qdf_system_ticks_to_msecs(total), |
| 8190 | temp_str); |
| 8191 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8192 | adapter_num++; |
| 8193 | } |
| 8194 | |
| 8195 | /* using QDF_TRACE to avoid printing function name */ |
| 8196 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 8197 | "STATS |%s", comb_log_str); |
| 8198 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8199 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8200 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8201 | |
| 8202 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8203 | } |
| 8204 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8205 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 8206 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 8207 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8208 | * |
| 8209 | * Return: none |
| 8210 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8211 | void |
| 8212 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 8213 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8214 | { |
| 8215 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8216 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8217 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8218 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8219 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8220 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 8221 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 8222 | return; |
| 8223 | } |
| 8224 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8225 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8226 | hdd_nofl_info("Netif queue operation statistics:"); |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 8227 | hdd_nofl_info("vdev_id %d device mode %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8228 | adapter->vdev_id, adapter->device_mode); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8229 | hdd_nofl_info("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8230 | curr_time = qdf_system_ticks(); |
| 8231 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8232 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8233 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8234 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8235 | unpause = adapter->total_unpause_time; |
| 8236 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8237 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8238 | pause = adapter->total_pause_time; |
| 8239 | } |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8240 | hdd_nofl_info("Total: %ums Pause: %ums Unpause: %ums", |
| 8241 | qdf_system_ticks_to_msecs(total), |
| 8242 | qdf_system_ticks_to_msecs(pause), |
| 8243 | qdf_system_ticks_to_msecs(unpause)); |
| 8244 | hdd_nofl_info("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8245 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8246 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8247 | qdf_time_t pause_delta = 0; |
| 8248 | |
| 8249 | if (adapter->pause_map & (1 << i)) |
| 8250 | pause_delta = delta; |
| 8251 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8252 | /* using hdd_log to avoid printing function name */ |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8253 | hdd_nofl_info("%s: %d: %d: %ums", |
| 8254 | hdd_reason_type_to_string(i), |
| 8255 | adapter->queue_oper_stats[i].pause_count, |
| 8256 | adapter->queue_oper_stats[i]. |
| 8257 | unpause_count, |
| 8258 | qdf_system_ticks_to_msecs( |
| 8259 | adapter->queue_oper_stats[i]. |
| 8260 | total_pause_time + pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8261 | } |
| 8262 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8263 | hdd_nofl_info("Netif queue operation history:"); |
| 8264 | hdd_nofl_info("Total entries: %d current index %d", |
| 8265 | WLAN_HDD_MAX_HISTORY_ENTRY, |
| 8266 | adapter->history_index); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8267 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8268 | hdd_nofl_info("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8269 | |
| 8270 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8271 | /* using hdd_log to avoid printing function name */ |
| 8272 | if (adapter->queue_oper_history[i].time == 0) |
| 8273 | continue; |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8274 | hdd_nofl_info("%d: %u: %s: %s: %x", |
| 8275 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8276 | adapter->queue_oper_history[i].time), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8277 | hdd_action_type_to_string( |
| 8278 | adapter->queue_oper_history[i]. |
| 8279 | netif_action), |
| 8280 | hdd_reason_type_to_string( |
| 8281 | adapter->queue_oper_history[i]. |
| 8282 | netif_reason), |
| 8283 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8284 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8285 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8286 | } |
| 8287 | |
| 8288 | /** |
| 8289 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 8290 | * @hdd_ctx: hdd context |
| 8291 | * |
| 8292 | * Return: none |
| 8293 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8294 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8295 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8296 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8297 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8298 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8299 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8300 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8301 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8302 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8303 | adapter->history_index = 0; |
| 8304 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 8305 | adapter->total_pause_time = 0; |
| 8306 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8307 | } |
| 8308 | } |
| 8309 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8310 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 8311 | /** |
| 8312 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 8313 | * @hdd_ctx: hdd global context |
| 8314 | * |
| 8315 | * Return: none |
| 8316 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8317 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8318 | { |
| 8319 | uint8_t i; |
| 8320 | |
| 8321 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 8322 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 8323 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 8324 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 8325 | } |
| 8326 | } |
| 8327 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8328 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8329 | { |
| 8330 | } |
| 8331 | #endif |
| 8332 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8333 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 8334 | /** |
| 8335 | * wlan_hdd_set_wow_pulse() - call SME to send wmi cmd of wow pulse |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8336 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8337 | * @enable: enable or disable this behaviour |
| 8338 | * |
| 8339 | * Return: int |
| 8340 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8341 | static int wlan_hdd_set_wow_pulse(struct hdd_context *phddctx, bool enable) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8342 | { |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8343 | struct wow_pulse_mode wow_pulse_set_info; |
| 8344 | QDF_STATUS status; |
| 8345 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8346 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8347 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8348 | if (!ucfg_pmo_is_wow_pulse_enabled(phddctx->psoc)) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8349 | return 0; |
| 8350 | |
| 8351 | /* prepare the request to send to SME */ |
| 8352 | if (enable == true) { |
| 8353 | wow_pulse_set_info.wow_pulse_enable = true; |
| 8354 | wow_pulse_set_info.wow_pulse_pin = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8355 | ucfg_pmo_get_wow_pulse_pin(phddctx->psoc); |
| 8356 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8357 | wow_pulse_set_info.wow_pulse_interval_high = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8358 | ucfg_pmo_get_wow_pulse_interval_high(phddctx->psoc); |
| 8359 | |
| 8360 | wow_pulse_set_info.wow_pulse_interval_low = |
| 8361 | ucfg_pmo_get_wow_pulse_interval_low(phddctx->psoc); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8362 | } else { |
| 8363 | wow_pulse_set_info.wow_pulse_enable = false; |
| 8364 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 8365 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 8366 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 8367 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8368 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8369 | wow_pulse_set_info.wow_pulse_enable, |
| 8370 | wow_pulse_set_info.wow_pulse_pin, |
| 8371 | wow_pulse_set_info.wow_pulse_interval_low, |
| 8372 | wow_pulse_set_info.wow_pulse_interval_high); |
| 8373 | |
| 8374 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 8375 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8376 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8377 | return -EIO; |
| 8378 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8379 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8380 | return 0; |
| 8381 | } |
| 8382 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8383 | static inline int wlan_hdd_set_wow_pulse(struct hdd_context *phddctx, bool enable) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8384 | { |
| 8385 | return 0; |
| 8386 | } |
| 8387 | #endif |
| 8388 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8389 | #ifdef WLAN_FEATURE_FASTPATH |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8390 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8391 | /** |
| 8392 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 8393 | * @hdd_cfg: hdd config |
| 8394 | * @context: lower layer context |
| 8395 | * |
| 8396 | * Return: none |
| 8397 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8398 | void hdd_enable_fastpath(struct hdd_context *hdd_ctx, |
| 8399 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8400 | { |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8401 | if (cfg_get(hdd_ctx->psoc, CFG_DP_ENABLE_FASTPATH)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8402 | hif_enable_fastpath(context); |
| 8403 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8404 | #endif |
| 8405 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8406 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8407 | /** |
| 8408 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8409 | * @hdd_handle: opaque handle for the hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8410 | * @level: thermal level |
| 8411 | * |
| 8412 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8413 | * than 0, and restore the original data path when throttle level is 0 |
| 8414 | * |
| 8415 | * Return: none |
| 8416 | */ |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8417 | 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] | 8418 | { |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8419 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8420 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8421 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 8422 | if (level > THROTTLE_LEVEL_0) |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8423 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8424 | else |
| 8425 | /* restore original concurrency mode */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8426 | 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] | 8427 | } |
| 8428 | |
| 8429 | /** |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8430 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8431 | * @hdd_ctx: pointer to hdd context |
| 8432 | * @adapter: pointer to softap adapter |
| 8433 | * |
| 8434 | * This function is used to get safe channel from current regulatory valid |
| 8435 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8436 | * |
| 8437 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8438 | * failure, the channel number returned is zero. |
| 8439 | */ |
| 8440 | static uint8_t |
| 8441 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8442 | struct hdd_adapter *adapter) |
| 8443 | { |
| 8444 | struct sir_pcl_list pcl = {0}; |
| 8445 | uint32_t i, j; |
| 8446 | bool found = false; |
| 8447 | int ret; |
| 8448 | |
| 8449 | /* Try for safe channel from all valid channel */ |
| 8450 | pcl.pcl_len = MAX_NUM_CHAN; |
| 8451 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 8452 | &pcl.pcl_len); |
| 8453 | if (ret) { |
| 8454 | hdd_err("error %d in getting valid channel list", ret); |
| 8455 | return INVALID_CHANNEL_ID; |
| 8456 | } |
| 8457 | |
| 8458 | for (i = 0; i < pcl.pcl_len; i++) { |
| 8459 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 8460 | found = false; |
| 8461 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
| 8462 | if (pcl.pcl_list[i] == |
| 8463 | hdd_ctx->unsafe_channel_list[j]) { |
| 8464 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
| 8465 | found = true; |
| 8466 | break; |
| 8467 | } |
| 8468 | } |
| 8469 | |
| 8470 | if (found) |
| 8471 | continue; |
| 8472 | |
| 8473 | if ((pcl.pcl_list[i] >= |
| 8474 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
| 8475 | (pcl.pcl_list[i] <= |
| 8476 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
| 8477 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
| 8478 | return pcl.pcl_list[i]; |
| 8479 | } |
| 8480 | } |
| 8481 | |
| 8482 | return INVALID_CHANNEL_ID; |
| 8483 | } |
| 8484 | |
| 8485 | #else |
| 8486 | /** |
| 8487 | * hdd_set_thermal_level_cb() - set thermal level callback function |
| 8488 | * @hdd_handle: opaque handle for the hdd context |
| 8489 | * @level: thermal level |
| 8490 | * |
| 8491 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8492 | * than 0, and restore the original data path when throttle level is 0 |
| 8493 | * |
| 8494 | * Return: none |
| 8495 | */ |
| 8496 | static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level) |
| 8497 | { |
| 8498 | } |
| 8499 | |
| 8500 | /** |
| 8501 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8502 | * @hdd_ctx: pointer to hdd context |
| 8503 | * @adapter: pointer to softap adapter |
| 8504 | * |
| 8505 | * This function is used to get safe channel from current regulatory valid |
| 8506 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8507 | * |
| 8508 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8509 | * failure, the channel number returned is zero. |
| 8510 | */ |
| 8511 | static uint8_t |
| 8512 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8513 | struct hdd_adapter *adapter) |
| 8514 | { |
| 8515 | return 0; |
| 8516 | } |
| 8517 | #endif |
| 8518 | |
| 8519 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8520 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 8521 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 8522 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8523 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8524 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 8525 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 8526 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8527 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8528 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8529 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8530 | */ |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8531 | static uint8_t |
| 8532 | hdd_get_safe_channel_from_pcl_and_acs_range(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8533 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8534 | struct sir_pcl_list pcl; |
| 8535 | QDF_STATUS status; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8536 | uint32_t i; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8537 | mac_handle_t mac_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8538 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8539 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8540 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8541 | if (!hdd_ctx) { |
| 8542 | hdd_err("invalid HDD context"); |
| 8543 | return INVALID_CHANNEL_ID; |
| 8544 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8545 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8546 | mac_handle = hdd_ctx->mac_handle; |
| 8547 | if (!mac_handle) { |
| 8548 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 8549 | return INVALID_CHANNEL_ID; |
| 8550 | } |
| 8551 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8552 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8553 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 8554 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 8555 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8556 | if (QDF_IS_STATUS_ERROR(status)) { |
| 8557 | hdd_err("Get PCL failed"); |
| 8558 | return INVALID_CHANNEL_ID; |
| 8559 | } |
| 8560 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 8561 | /* |
| 8562 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 8563 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 8564 | * try to choose a safe channel from acs range. |
| 8565 | */ |
| 8566 | if (!pcl.pcl_len) |
| 8567 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8568 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8569 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8570 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 8571 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8572 | |
| 8573 | /* PCL already takes unsafe channel into account */ |
| 8574 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8575 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8576 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8577 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8578 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8579 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8580 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8581 | return pcl.pcl_list[i]; |
| 8582 | } |
| 8583 | } |
| 8584 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8585 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8586 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8587 | return hdd_get_safe_channel(hdd_ctx, adapter); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8588 | } |
| 8589 | |
| 8590 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8591 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8592 | * @adapter: AP adapter |
| 8593 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8594 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8595 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8596 | * Moves the SAP interface by invoking the function which |
| 8597 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8598 | * |
| 8599 | * Return: None |
| 8600 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8601 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8602 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8603 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8604 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8605 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8606 | mac_handle_t mac_handle; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8607 | |
| 8608 | if (!adapter) { |
| 8609 | hdd_err("invalid adapter"); |
| 8610 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8611 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8612 | |
| 8613 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8614 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8615 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 8616 | if (!mac_handle) { |
| 8617 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8618 | return; |
| 8619 | } |
| 8620 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8621 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8622 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8623 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8624 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8625 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8626 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8627 | adapter->vdev_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8628 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8629 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8630 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8631 | 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] | 8632 | { |
| 8633 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8634 | int status; |
| 8635 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8636 | |
| 8637 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8638 | |
| 8639 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8640 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8641 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8642 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8643 | } |
| 8644 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8645 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8646 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8647 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8648 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8649 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8650 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8651 | hdd_err("failed to start external acs timer"); |
| 8652 | return -ENOSPC; |
| 8653 | } |
| 8654 | /* Update config to application */ |
| 8655 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8656 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8657 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8658 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8659 | } |
| 8660 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8661 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8662 | /** |
| 8663 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8664 | * @hdd_ctx: hdd context pointer |
| 8665 | * |
| 8666 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8667 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8668 | * sap. User space on LTE coex indication restart driver. |
| 8669 | * |
| 8670 | * Return - none |
| 8671 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8672 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8673 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8674 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8675 | uint32_t i; |
| 8676 | bool found = false; |
| 8677 | uint8_t restart_chan; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8678 | uint8_t scc_on_lte_coex = 0; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8679 | bool value; |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8680 | QDF_STATUS status; |
| 8681 | bool is_acs_support_for_dfs_ltecoex = cfg_default(CFG_USER_ACS_DFS_LTE); |
| 8682 | bool is_vendor_acs_support = |
| 8683 | cfg_default(CFG_USER_AUTO_CHANNEL_SELECTION); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8684 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8685 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8686 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8687 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8688 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8689 | adapter->device_mode, |
| 8690 | adapter->session.ap.sap_config. |
| 8691 | acs_cfg.acs_mode); |
| 8692 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8693 | } |
| 8694 | |
| 8695 | found = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8696 | status = |
| 8697 | ucfg_policy_mgr_get_sta_sap_scc_lte_coex_chnl(hdd_ctxt->psoc, |
| 8698 | &scc_on_lte_coex); |
| 8699 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8700 | hdd_err("can't get scc on lte coex chnl, use def"); |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8701 | /* |
| 8702 | * If STA+SAP is doing SCC & g_sta_sap_scc_on_lte_coex_chan |
| 8703 | * is set, no need to move SAP. |
| 8704 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8705 | if (policy_mgr_is_sta_sap_scc(hdd_ctxt->psoc, |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8706 | adapter->session.ap.operating_channel) && |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8707 | scc_on_lte_coex) |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8708 | hdd_debug("SAP is allowed on SCC channel, no need to move SAP"); |
| 8709 | else { |
| 8710 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
| 8711 | if (adapter->session.ap.operating_channel == |
| 8712 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8713 | found = true; |
| 8714 | hdd_debug("operating ch:%d is unsafe", |
| 8715 | adapter->session.ap.operating_channel); |
| 8716 | break; |
| 8717 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8718 | } |
| 8719 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8720 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8721 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8722 | adapter->session.ap.operating_channel); |
| 8723 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8724 | } |
| 8725 | |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8726 | status = ucfg_mlme_get_acs_support_for_dfs_ltecoex( |
| 8727 | hdd_ctxt->psoc, |
| 8728 | &is_acs_support_for_dfs_ltecoex); |
| 8729 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8730 | hdd_err("get_acs_support_for_dfs_ltecoex failed,set def"); |
| 8731 | |
| 8732 | status = ucfg_mlme_get_vendor_acs_support( |
| 8733 | hdd_ctxt->psoc, |
| 8734 | &is_vendor_acs_support); |
| 8735 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8736 | hdd_err("get_vendor_acs_support failed, set default"); |
| 8737 | |
| 8738 | if (is_vendor_acs_support && is_acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8739 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8740 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8741 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8742 | } else |
| 8743 | restart_chan = |
| 8744 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8745 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8746 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8747 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8748 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8749 | /* |
| 8750 | * SAP restart due to unsafe channel. While |
| 8751 | * restarting the SAP, make sure to clear |
| 8752 | * acs_channel, channel to reset to |
| 8753 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8754 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8755 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8756 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8757 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8758 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8759 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 8760 | ucfg_mlme_get_sap_internal_restart(hdd_ctxt->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8761 | &value); |
| 8762 | hdd_debug("driver to start sap: %d", value); |
| 8763 | if (value) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8764 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8765 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8766 | else |
| 8767 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8768 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8769 | } |
| 8770 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8771 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8772 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8773 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8774 | * @hdd_ctx: HDD global context |
| 8775 | * |
| 8776 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8777 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8778 | * down to the lower layers. Then subscribe to subsequent channel |
| 8779 | * avoidance events. |
| 8780 | * |
| 8781 | * Return: None |
| 8782 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8783 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8784 | { |
| 8785 | uint16_t unsafe_channel_count; |
| 8786 | int index; |
| 8787 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8788 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8789 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8790 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8791 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8792 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8793 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8794 | hdd_ctx->unsafe_channel_count); |
| 8795 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8796 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8797 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8798 | |
| 8799 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8800 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8801 | hdd_ctx->unsafe_channel_list[index]); |
| 8802 | |
| 8803 | } |
| 8804 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8805 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8806 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8807 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8808 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8809 | { |
| 8810 | uint8_t restart_chan; |
| 8811 | |
| 8812 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8813 | if (!restart_chan) { |
| 8814 | hdd_alert("fail to restart SAP"); |
| 8815 | return; |
| 8816 | } |
| 8817 | |
| 8818 | /* SAP restart due to unsafe channel. While restarting |
| 8819 | * the SAP, make sure to clear acs_channel, channel to |
| 8820 | * reset to 0. Otherwise these settings will override |
| 8821 | * the ACS while restart. |
| 8822 | */ |
| 8823 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8824 | |
| 8825 | hdd_debug("sending coex indication"); |
| 8826 | |
| 8827 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8828 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8829 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8830 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8831 | |
| 8832 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8833 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8834 | { |
| 8835 | uint32_t size; |
| 8836 | uint16_t *unsafe_list; |
| 8837 | uint16_t chan_count; |
| 8838 | |
| 8839 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8840 | return -EINVAL; |
| 8841 | |
| 8842 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8843 | NUM_CHANNELS); |
| 8844 | if (chan_count) { |
| 8845 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8846 | unsafe_list = qdf_mem_malloc(size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8847 | if (!unsafe_list) |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8848 | return -ENOMEM; |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8849 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8850 | } else { |
| 8851 | unsafe_list = NULL; |
| 8852 | } |
| 8853 | |
| 8854 | *local_unsafe_list = unsafe_list; |
| 8855 | *local_unsafe_list_count = chan_count; |
| 8856 | |
| 8857 | return 0; |
| 8858 | } |
| 8859 | |
| 8860 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8861 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8862 | { |
| 8863 | int i, j; |
| 8864 | |
| 8865 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8866 | return true; |
| 8867 | if (local_unsafe_list_count == 0) |
| 8868 | return false; |
| 8869 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8870 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8871 | if (local_unsafe_list[i] == |
| 8872 | hdd_ctx->unsafe_channel_list[j]) |
| 8873 | break; |
| 8874 | if (j >= local_unsafe_list_count) |
| 8875 | break; |
| 8876 | } |
| 8877 | if (i >= local_unsafe_list_count) { |
| 8878 | hdd_info("unsafe chan list same"); |
| 8879 | return false; |
| 8880 | } |
| 8881 | |
| 8882 | return true; |
| 8883 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8884 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8885 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8886 | { |
| 8887 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8888 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8889 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8890 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8891 | { |
| 8892 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8893 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8894 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8895 | |
| 8896 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8897 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8898 | * user space |
| 8899 | * @frame_ind: Management frame data to be informed. |
| 8900 | * |
| 8901 | * This function is used to indicate management frame to |
| 8902 | * user space |
| 8903 | * |
| 8904 | * Return: None |
| 8905 | * |
| 8906 | */ |
| 8907 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8908 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8909 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8910 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8911 | int i; |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8912 | struct ieee80211_mgmt *mgmt = |
| 8913 | (struct ieee80211_mgmt *)frame_ind->frameBuf; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8914 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 8915 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8916 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8917 | return; |
| 8918 | |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8919 | if (frame_ind->frame_len < ieee80211_hdrlen(mgmt->frame_control)) { |
| 8920 | hdd_err(" Invalid frame length"); |
| 8921 | return; |
| 8922 | } |
| 8923 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8924 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 8925 | for (i = 0; i < WLAN_MAX_VDEVS; i++) { |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8926 | adapter = |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 8927 | hdd_get_adapter_by_vdev(hdd_ctx, i); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8928 | if (adapter) |
| 8929 | break; |
| 8930 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8931 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8932 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 8933 | if ((adapter) && |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8934 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8935 | __hdd_indicate_mgmt_frame(adapter, |
| 8936 | frame_ind->frame_len, |
| 8937 | frame_ind->frameBuf, |
| 8938 | frame_ind->frameType, |
| 8939 | frame_ind->rxChan, |
Srinivas Dasari | ea1c133 | 2019-02-18 12:43:23 +0530 | [diff] [blame] | 8940 | frame_ind->rxRssi, |
| 8941 | frame_ind->rx_flags); |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8942 | } |
| 8943 | } |
| 8944 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8945 | } else { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 8946 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, |
| 8947 | frame_ind->sessionId); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8948 | } |
| 8949 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 8950 | if ((adapter) && |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8951 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8952 | __hdd_indicate_mgmt_frame(adapter, |
| 8953 | frame_ind->frame_len, |
| 8954 | frame_ind->frameBuf, |
| 8955 | frame_ind->frameType, |
| 8956 | frame_ind->rxChan, |
Srinivas Dasari | ea1c133 | 2019-02-18 12:43:23 +0530 | [diff] [blame] | 8957 | frame_ind->rxRssi, |
| 8958 | frame_ind->rx_flags); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8959 | } |
| 8960 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8961 | void hdd_acs_response_timeout_handler(void *context) |
| 8962 | { |
| 8963 | struct hdd_external_acs_timer_context *timer_context = |
| 8964 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8965 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8966 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8967 | uint8_t reason; |
| 8968 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8969 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8970 | if (!timer_context) { |
| 8971 | hdd_err("invlaid timer context"); |
| 8972 | return; |
| 8973 | } |
| 8974 | adapter = timer_context->adapter; |
| 8975 | reason = timer_context->reason; |
| 8976 | |
| 8977 | |
| 8978 | if ((!adapter) || |
| 8979 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 8980 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 8981 | return; |
| 8982 | } |
| 8983 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8984 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8985 | return; |
| 8986 | |
| 8987 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 8988 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8989 | else |
| 8990 | return; |
| 8991 | |
| 8992 | hdd_err("ACS timeout happened for %s reason %d", |
| 8993 | adapter->dev->name, reason); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8994 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8995 | switch (reason) { |
| 8996 | /* SAP init case */ |
| 8997 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 8998 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8999 | false); |
| 9000 | wlan_hdd_cfg80211_start_acs(adapter); |
| 9001 | break; |
| 9002 | /* DFS detected on current channel */ |
| 9003 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 9004 | wlan_sap_update_next_channel( |
| 9005 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9006 | sme_update_new_channel_event(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9007 | adapter->vdev_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9008 | break; |
| 9009 | /* LTE coex event on current channel */ |
| 9010 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 9011 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 9012 | break; |
| 9013 | default: |
| 9014 | hdd_info("invalid reason for timer invoke"); |
| 9015 | |
| 9016 | } |
| 9017 | } |
| 9018 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9019 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9020 | * hdd_override_ini_config - Override INI config |
| 9021 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9022 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9023 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9024 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9025 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9026 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9027 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9028 | { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9029 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9030 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9031 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 9032 | ucfg_scan_cfg_set_dfs_chan_scan_allowed(hdd_ctx->psoc, |
| 9033 | enable_dfs_chan_scan); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9034 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9035 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9036 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9037 | if (0 == enable_11d || 1 == enable_11d) { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9038 | status = ucfg_mlme_set_11d_enabled(hdd_ctx->psoc, enable_11d); |
| 9039 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9040 | hdd_err("Failed to set 11d_enable flag"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9041 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 9042 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9043 | if (hdd_ctx->config->action_oui_enable && !ucfg_action_oui_enabled()) { |
| 9044 | hdd_ctx->config->action_oui_enable = 0; |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9045 | hdd_err("Ignore action oui ini, since no action_oui component"); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9046 | } |
Will Huang | 14b120f | 2019-01-14 17:26:14 +0800 | [diff] [blame] | 9047 | |
| 9048 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
| 9049 | hdd_override_all_ps(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9050 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9051 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9052 | #ifdef ENABLE_MTRACE_LOG |
| 9053 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9054 | { |
| 9055 | uint8_t module_id = 0; |
| 9056 | int qdf_print_idx = -1; |
| 9057 | |
| 9058 | qdf_print_idx = qdf_get_pidx(); |
| 9059 | for (module_id = 0; module_id < QDF_MODULE_ID_MAX; module_id++) |
| 9060 | qdf_print_set_category_verbose( |
| 9061 | qdf_print_idx, |
| 9062 | module_id, QDF_TRACE_LEVEL_TRACE, |
| 9063 | hdd_ctx->config->enable_mtrace); |
| 9064 | } |
| 9065 | #else |
| 9066 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9067 | { |
| 9068 | } |
| 9069 | |
| 9070 | #endif |
| 9071 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9072 | /** |
| 9073 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 9074 | * @hdd_ctx - HDD context |
| 9075 | * |
| 9076 | * Set trace level for each module based on INI config. |
| 9077 | * |
| 9078 | * Return: None |
| 9079 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9080 | 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] | 9081 | { |
Wu Gao | bc6eaa1 | 2018-11-30 14:17:45 +0800 | [diff] [blame] | 9082 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, 0x7f); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 9083 | hdd_qdf_trace_enable(QDF_MODULE_ID_MLME, 0xffff); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 9084 | hdd_qdf_trace_enable(QDF_MODULE_ID_FWOL, 0xffff); |
Kiran Kumar Lokere | 4ce4048 | 2018-08-30 16:31:00 -0700 | [diff] [blame] | 9085 | hdd_qdf_trace_enable(QDF_MODULE_ID_CRYPTO, 0xffff); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 9086 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9087 | hdd_set_mtrace_for_each(hdd_ctx); |
| 9088 | |
Nirav Shah | 5c083da | 2018-08-03 13:46:02 +0530 | [diff] [blame] | 9089 | hdd_cfg_print_global_config(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9090 | } |
| 9091 | |
| 9092 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9093 | * hdd_context_init() - Initialize HDD context |
| 9094 | * @hdd_ctx: HDD context. |
| 9095 | * |
| 9096 | * Initialize HDD context along with all the feature specific contexts. |
| 9097 | * |
| 9098 | * return: 0 on success and errno on failure. |
| 9099 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9100 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9101 | { |
| 9102 | int ret; |
| 9103 | |
| 9104 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 9105 | hdd_ctx->max_intf_count = WLAN_MAX_VDEVS; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9106 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9107 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 9108 | init_completion(&hdd_ctx->ready_to_suspend); |
| 9109 | |
| 9110 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9111 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 9112 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 9113 | qdf_list_create(&hdd_ctx->hdd_adapters, 0); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9114 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9115 | ret = hdd_scan_context_init(hdd_ctx); |
| 9116 | if (ret) |
| 9117 | goto list_destroy; |
| 9118 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9119 | hdd_rx_wake_lock_create(hdd_ctx); |
| 9120 | |
| 9121 | ret = hdd_sap_context_init(hdd_ctx); |
| 9122 | if (ret) |
| 9123 | goto scan_destroy; |
| 9124 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9125 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 9126 | |
| 9127 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 9128 | |
| 9129 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 9130 | hdd_ctx->config); |
| 9131 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 9132 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9133 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 9134 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 9135 | "monitor_mode_wakelock"); |
| 9136 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9137 | return 0; |
| 9138 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9139 | sap_destroy: |
| 9140 | hdd_sap_context_destroy(hdd_ctx); |
| 9141 | |
| 9142 | scan_destroy: |
| 9143 | hdd_scan_context_destroy(hdd_ctx); |
| 9144 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9145 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 9146 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 9147 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9148 | return ret; |
| 9149 | } |
| 9150 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9151 | void hdd_psoc_idle_timer_start(struct hdd_context *hdd_ctx) |
| 9152 | { |
| 9153 | uint32_t timeout_ms = hdd_ctx->config->iface_change_wait_time; |
| 9154 | enum wake_lock_reason reason = |
| 9155 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER; |
| 9156 | |
Rajeev Kumar | 7b7bb3f | 2018-12-20 12:09:54 -0800 | [diff] [blame] | 9157 | if (!timeout_ms) { |
| 9158 | hdd_info("psoc idle timer is disabled"); |
| 9159 | return; |
| 9160 | } |
| 9161 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9162 | hdd_debug("Starting psoc idle timer"); |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9163 | qdf_delayed_work_start(&hdd_ctx->psoc_idle_timeout_work, timeout_ms); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9164 | hdd_prevent_suspend_timeout(timeout_ms, reason); |
| 9165 | } |
| 9166 | |
| 9167 | void hdd_psoc_idle_timer_stop(struct hdd_context *hdd_ctx) |
| 9168 | { |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9169 | qdf_delayed_work_stop_sync(&hdd_ctx->psoc_idle_timeout_work); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9170 | hdd_debug("Stopped psoc idle timer"); |
| 9171 | } |
| 9172 | |
Sourav Mohapatra | 698d6f6 | 2019-01-29 14:49:52 +0530 | [diff] [blame] | 9173 | /* |
| 9174 | * enum hdd_block_shutdown - Control if driver allows modem shutdown |
| 9175 | * @HDD_UNBLOCK_MODEM_SHUTDOWN: Unblock shutdown |
| 9176 | * @HDD_BLOCK_MODEM_SHUTDOWN: Block shutdown |
| 9177 | * |
| 9178 | * On calling pld_block_shutdown API with the given values, modem |
| 9179 | * graceful shutdown is blocked/unblocked. |
| 9180 | */ |
| 9181 | enum hdd_block_shutdown { |
| 9182 | HDD_UNBLOCK_MODEM_SHUTDOWN, |
| 9183 | HDD_BLOCK_MODEM_SHUTDOWN, |
| 9184 | }; |
| 9185 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9186 | /** |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9187 | * hdd_psoc_idle_shutdown() - perform an idle shutdown on the given psoc |
| 9188 | * @hdd_ctx: the hdd context which should be shutdown |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9189 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9190 | * When no interfaces are "up" on a psoc, an idle shutdown timer is started. |
| 9191 | * If no interfaces are brought up before the timer expires, we do an |
| 9192 | * "idle shutdown," cutting power to the physical SoC to save power. This is |
| 9193 | * done completely transparently from the perspective of userspace. |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9194 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9195 | * Return: None |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9196 | */ |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9197 | static void hdd_psoc_idle_shutdown(struct hdd_context *hdd_ctx) |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9198 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9199 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9200 | int errno; |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9201 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9202 | hdd_enter(); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9203 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9204 | errno = osif_psoc_sync_trans_start(hdd_ctx->parent_dev, &psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9205 | if (errno) { |
| 9206 | hdd_info("psoc busy, abort idle shutdown; errno:%d", errno); |
| 9207 | goto exit; |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9208 | } |
Sourav Mohapatra | 698d6f6 | 2019-01-29 14:49:52 +0530 | [diff] [blame] | 9209 | /* Block the modem graceful shutdown till stop modules is completed */ |
| 9210 | pld_block_shutdown(hdd_ctx->parent_dev, HDD_BLOCK_MODEM_SHUTDOWN); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9211 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9212 | osif_psoc_sync_wait_for_ops(psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9213 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9214 | QDF_BUG(!hdd_wlan_stop_modules(hdd_ctx, false)); |
| 9215 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9216 | osif_psoc_sync_trans_stop(psoc_sync); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9217 | |
Sourav Mohapatra | 698d6f6 | 2019-01-29 14:49:52 +0530 | [diff] [blame] | 9218 | pld_block_shutdown(hdd_ctx->parent_dev, HDD_UNBLOCK_MODEM_SHUTDOWN); |
| 9219 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9220 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9221 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9222 | } |
| 9223 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9224 | int hdd_psoc_idle_restart(struct hdd_context *hdd_ctx) |
| 9225 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 9226 | QDF_BUG(rtnl_is_locked()); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9227 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9228 | return hdd_wlan_start_modules(hdd_ctx, false); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9229 | } |
| 9230 | |
| 9231 | /** |
| 9232 | * hdd_psoc_idle_timeout_callback() - Handler for psoc idle timeout |
| 9233 | * @priv: pointer to hdd context |
| 9234 | * |
| 9235 | * Return: None |
| 9236 | */ |
| 9237 | static void hdd_psoc_idle_timeout_callback(void *priv) |
| 9238 | { |
| 9239 | struct hdd_context *hdd_ctx = priv; |
| 9240 | |
| 9241 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 9242 | return; |
| 9243 | |
| 9244 | hdd_debug("Psoc idle timeout elapsed; starting psoc shutdown"); |
| 9245 | hdd_psoc_idle_shutdown(hdd_ctx); |
| 9246 | } |
| 9247 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9248 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9249 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9250 | { |
| 9251 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 9252 | wlan_logging_to_console); |
| 9253 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 9254 | } |
| 9255 | #else |
| 9256 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9257 | { } |
| 9258 | #endif |
| 9259 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9260 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9261 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9262 | struct wlan_objmgr_psoc *psoc) |
| 9263 | { |
| 9264 | config->wlan_logging_enable = cfg_get(psoc, CFG_WLAN_LOGGING_SUPPORT); |
| 9265 | |
| 9266 | config->wlan_logging_to_console = |
| 9267 | cfg_get(psoc, CFG_WLAN_LOGGING_CONSOLE_SUPPORT); |
| 9268 | } |
| 9269 | #else |
| 9270 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9271 | struct wlan_objmgr_psoc *psoc) |
| 9272 | { |
| 9273 | } |
| 9274 | #endif |
| 9275 | |
| 9276 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9277 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9278 | struct wlan_objmgr_psoc *psoc) |
| 9279 | { |
| 9280 | config->wlan_auto_shutdown = cfg_get(psoc, CFG_WLAN_AUTO_SHUTDOWN); |
| 9281 | } |
| 9282 | #else |
| 9283 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9284 | struct wlan_objmgr_psoc *psoc) |
| 9285 | { |
| 9286 | } |
| 9287 | #endif |
| 9288 | |
| 9289 | #ifndef REMOVE_PKT_LOG |
| 9290 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9291 | struct wlan_objmgr_psoc *psoc) |
| 9292 | { |
| 9293 | config->enable_packet_log = cfg_get(psoc, CFG_ENABLE_PACKET_LOG); |
| 9294 | } |
| 9295 | #else |
| 9296 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9297 | struct wlan_objmgr_psoc *psoc) |
| 9298 | { |
| 9299 | } |
| 9300 | #endif |
| 9301 | |
Sandeep Puligilla | 43b6d1a | 2018-12-03 09:16:13 -0800 | [diff] [blame] | 9302 | #ifdef ENABLE_MTRACE_LOG |
| 9303 | static void hdd_init_mtrace_log(struct hdd_config *config, |
| 9304 | struct wlan_objmgr_psoc *psoc) |
| 9305 | { |
| 9306 | config->enable_mtrace = cfg_get(psoc, CFG_ENABLE_MTRACE); |
| 9307 | } |
| 9308 | #else |
| 9309 | static void hdd_init_mtrace_log(struct hdd_config *config, |
| 9310 | struct wlan_objmgr_psoc *psoc) |
| 9311 | { |
| 9312 | } |
| 9313 | #endif |
| 9314 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9315 | #ifdef FEATURE_RUNTIME_PM |
| 9316 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9317 | struct wlan_objmgr_psoc *psoc) |
| 9318 | { |
| 9319 | config->runtime_pm = cfg_get(psoc, CFG_ENABLE_RUNTIME_PM); |
| 9320 | } |
| 9321 | #else |
| 9322 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9323 | struct wlan_objmgr_psoc *psoc) |
| 9324 | |
| 9325 | { |
| 9326 | } |
| 9327 | #endif |
| 9328 | |
| 9329 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 9330 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9331 | struct wlan_objmgr_psoc *psoc) |
| 9332 | { |
| 9333 | config->vc_mode_cfg_bitmap = cfg_get(psoc, CFG_VC_MODE_BITMAP); |
| 9334 | } |
| 9335 | #else |
| 9336 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9337 | struct wlan_objmgr_psoc *psoc) |
| 9338 | { |
| 9339 | } |
| 9340 | #endif |
| 9341 | |
gaurank kathpalia | 566c81b | 2019-02-20 14:31:45 +0530 | [diff] [blame] | 9342 | #ifdef DHCP_SERVER_OFFLOAD |
| 9343 | static void |
| 9344 | hdd_init_dhcp_server_ip(struct hdd_context *hdd_ctx) |
| 9345 | { |
| 9346 | uint8_t num_entries; |
| 9347 | |
| 9348 | hdd_ctx->config->dhcp_server_ip.is_dhcp_server_ip_valid = true; |
| 9349 | hdd_string_to_u8_array(cfg_get(hdd_ctx->psoc, CFG_DHCP_SERVER_IP_NAME), |
| 9350 | hdd_ctx->config->dhcp_server_ip.dhcp_server_ip, |
| 9351 | &num_entries, IPADDR_NUM_ENTRIES); |
| 9352 | |
| 9353 | if (num_entries != IPADDR_NUM_ENTRIES) { |
| 9354 | hdd_err("Incorrect IP address (%s) assigned for DHCP server!", |
| 9355 | cfg_get(hdd_ctx->psoc, CFG_DHCP_SERVER_IP_NAME)); |
| 9356 | hdd_config->dhcp_server_ip.is_dhcp_server_ip_valid = false; |
| 9357 | } |
| 9358 | } |
| 9359 | #else |
| 9360 | static void |
| 9361 | hdd_init_dhcp_server_ip(struct hdd_context *hdd_ctx) |
| 9362 | { |
| 9363 | } |
| 9364 | #endif |
| 9365 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9366 | /** |
| 9367 | * hdd_cfg_params_init() - Initialize hdd params in hdd_config strucuture |
| 9368 | * @hdd_ctx - Pointer to HDD context |
| 9369 | * |
| 9370 | * Return: None |
| 9371 | */ |
| 9372 | static void hdd_cfg_params_init(struct hdd_context *hdd_ctx) |
| 9373 | { |
| 9374 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
| 9375 | struct hdd_config *config = hdd_ctx->config; |
| 9376 | |
| 9377 | if (!psoc) { |
| 9378 | hdd_err("Invalid psoc"); |
| 9379 | return; |
| 9380 | } |
| 9381 | |
| 9382 | if (!config) { |
| 9383 | hdd_err("Invalid hdd config"); |
| 9384 | return; |
| 9385 | } |
| 9386 | |
gaurank kathpalia | 43c5262 | 2019-02-11 12:30:05 +0530 | [diff] [blame] | 9387 | config->dot11Mode = cfg_get(psoc, CFG_HDD_DOT11_MODE); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9388 | config->bug_on_reinit_failure = cfg_get(psoc, |
| 9389 | CFG_BUG_ON_REINIT_FAILURE); |
| 9390 | |
| 9391 | config->is_ramdump_enabled = cfg_get(psoc, |
| 9392 | CFG_ENABLE_RAMDUMP_COLLECTION); |
| 9393 | |
| 9394 | config->iface_change_wait_time = cfg_get(psoc, |
| 9395 | CFG_INTERFACE_CHANGE_WAIT); |
| 9396 | |
| 9397 | config->multicast_host_fw_msgs = cfg_get(psoc, |
| 9398 | CFG_MULTICAST_HOST_FW_MSGS); |
| 9399 | |
| 9400 | config->private_wext_control = cfg_get(psoc, CFG_PRIVATE_WEXT_CONTROL); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9401 | config->enablefwprint = cfg_get(psoc, CFG_ENABLE_FW_UART_PRINT); |
| 9402 | config->enable_fw_log = cfg_get(psoc, CFG_ENABLE_FW_LOG); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9403 | config->operating_channel = cfg_get(psoc, CFG_OPERATING_CHANNEL); |
| 9404 | config->num_vdevs = cfg_get(psoc, CFG_NUM_VDEV_ENABLE); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9405 | qdf_str_lcopy(config->enable_concurrent_sta, |
| 9406 | cfg_get(psoc, CFG_ENABLE_CONCURRENT_STA), |
| 9407 | CFG_CONCURRENT_IFACE_MAX_LEN); |
| 9408 | qdf_str_lcopy(config->dbs_scan_selection, |
| 9409 | cfg_get(psoc, CFG_DBS_SCAN_SELECTION), |
| 9410 | CFG_DBS_SCAN_PARAM_LENGTH); |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9411 | 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] | 9412 | config->mac_provision = cfg_get(psoc, CFG_ENABLE_MAC_PROVISION); |
| 9413 | config->provisioned_intf_pool = |
| 9414 | cfg_get(psoc, CFG_PROVISION_INTERFACE_POOL); |
| 9415 | config->derived_intf_pool = cfg_get(psoc, CFG_DERIVED_INTERFACE_POOL); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9416 | config->action_oui_enable = cfg_get(psoc, CFG_ENABLE_ACTION_OUI); |
Jeff Johnson | 15a88ac | 2019-03-11 14:35:25 -0700 | [diff] [blame] | 9417 | config->advertise_concurrent_operation = |
Sandeep Puligilla | dc6d68a | 2019-01-04 16:57:12 -0800 | [diff] [blame] | 9418 | cfg_get(psoc, |
| 9419 | CFG_ADVERTISE_CONCURRENT_OPERATION); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9420 | qdf_str_lcopy(config->action_oui_str[0], |
| 9421 | cfg_get(psoc, CFG_ACTION_OUI_CONNECT_1X1), |
| 9422 | ACTION_OUI_MAX_STR_LEN); |
| 9423 | qdf_str_lcopy(config->action_oui_str[1], |
| 9424 | cfg_get(psoc, CFG_ACTION_OUI_ITO_EXTENSION), |
| 9425 | ACTION_OUI_MAX_STR_LEN); |
| 9426 | qdf_str_lcopy(config->action_oui_str[2], |
| 9427 | cfg_get(psoc, CFG_ACTION_OUI_CCKM_1X1), |
| 9428 | ACTION_OUI_MAX_STR_LEN); |
| 9429 | qdf_str_lcopy(config->action_oui_str[3], |
| 9430 | cfg_get(psoc, CFG_ACTION_OUI_ITO_ALTERNATE), |
| 9431 | ACTION_OUI_MAX_STR_LEN); |
| 9432 | qdf_str_lcopy(config->action_oui_str[4], |
| 9433 | cfg_get(psoc, CFG_ACTION_OUI_SWITCH_TO_11N_MODE), |
| 9434 | ACTION_OUI_MAX_STR_LEN); |
| 9435 | qdf_str_lcopy(config->action_oui_str[5], |
| 9436 | cfg_get(psoc, |
| 9437 | CFG_ACTION_OUI_CONNECT_1X1_WITH_1_CHAIN), |
| 9438 | ACTION_OUI_MAX_STR_LEN); |
Rajeev Kumar Sirasanagandla | d7987f1 | 2018-12-08 23:24:04 +0530 | [diff] [blame] | 9439 | qdf_str_lcopy(config->action_oui_str[6], |
| 9440 | cfg_get(psoc, |
| 9441 | CFG_ACTION_OUI_DISABLE_AGGRESSIVE_TX), |
| 9442 | ACTION_OUI_MAX_STR_LEN); |
Sourav Mohapatra | 9e014cf | 2018-12-11 09:39:33 +0530 | [diff] [blame] | 9443 | config->enable_rtt_support = cfg_get(psoc, CFG_ENABLE_RTT_SUPPORT); |
Sandeep Puligilla | efeb4a9 | 2019-01-08 00:06:51 -0800 | [diff] [blame] | 9444 | config->is_unit_test_framework_enabled = |
| 9445 | cfg_get(psoc, CFG_ENABLE_UNIT_TEST_FRAMEWORK); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9446 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9447 | hdd_init_vc_mode_cfg_bitmap(config, psoc); |
| 9448 | hdd_init_runtime_pm(config, psoc); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9449 | hdd_init_wlan_auto_shutdown(config, psoc); |
| 9450 | hdd_init_wlan_logging_params(config, psoc); |
| 9451 | hdd_init_packet_log(config, psoc); |
Sandeep Puligilla | 43b6d1a | 2018-12-03 09:16:13 -0800 | [diff] [blame] | 9452 | hdd_init_mtrace_log(config, psoc); |
gaurank kathpalia | 566c81b | 2019-02-20 14:31:45 +0530 | [diff] [blame] | 9453 | hdd_init_dhcp_server_ip(hdd_ctx); |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 9454 | hdd_dp_cfg_update(psoc, hdd_ctx); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9455 | } |
| 9456 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 9457 | struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9458 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9459 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9460 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9461 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9462 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9463 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9464 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 9465 | hdd_ctx = hdd_cfg80211_wiphy_alloc(); |
| 9466 | if (!hdd_ctx) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9467 | ret = -ENOMEM; |
| 9468 | goto err_out; |
| 9469 | } |
| 9470 | |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9471 | status = qdf_delayed_work_create(&hdd_ctx->psoc_idle_timeout_work, |
| 9472 | hdd_psoc_idle_timeout_callback, |
| 9473 | hdd_ctx); |
| 9474 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9475 | ret = qdf_status_to_os_return(status); |
| 9476 | goto wiphy_dealloc; |
| 9477 | } |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9478 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9479 | hdd_ctx->parent_dev = dev; |
Jeff Johnson | 995fd51 | 2019-03-06 08:45:10 -0800 | [diff] [blame] | 9480 | hdd_ctx->last_scan_reject_vdev_id = WLAN_UMAC_VDEV_ID_MAX; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9481 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9482 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9483 | if (!hdd_ctx->config) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9484 | ret = -ENOMEM; |
| 9485 | goto err_free_hdd_context; |
| 9486 | } |
| 9487 | |
| 9488 | /* Read and parse the qcom_cfg.ini file */ |
| 9489 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9490 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9491 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9492 | WLAN_INI_FILE); |
| 9493 | ret = -EINVAL; |
| 9494 | goto err_free_config; |
| 9495 | } |
| 9496 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 9497 | status = cfg_parse(WLAN_INI_FILE); |
| 9498 | if (QDF_IS_STATUS_ERROR(status)) |
| 9499 | hdd_err("Failed to parse cfg %s; status:%d\n", |
| 9500 | WLAN_INI_FILE, status); |
| 9501 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9502 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID); |
| 9503 | if (ret) { |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9504 | QDF_DEBUG_PANIC("Psoc creation fails!"); |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9505 | goto err_free_config; |
| 9506 | } |
| 9507 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9508 | hdd_cfg_params_init(hdd_ctx); |
| 9509 | |
Dustin Brown | 4bbd546 | 2019-03-22 11:18:13 -0700 | [diff] [blame] | 9510 | /* apply multiplier config, if not already set via module parameter */ |
| 9511 | if (qdf_timer_get_multiplier() == 1) |
| 9512 | qdf_timer_set_multiplier(cfg_get(hdd_ctx->psoc, |
| 9513 | CFG_TIMER_MULTIPLIER)); |
Dustin Brown | a9a8452 | 2019-02-04 12:25:40 -0800 | [diff] [blame] | 9514 | hdd_debug("set timer multiplier: %u", qdf_timer_get_multiplier()); |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 9515 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9516 | cds_set_fatal_event(cfg_get(hdd_ctx->psoc, |
| 9517 | CFG_ENABLE_FATAL_EVENT_TRIGGER)); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 9518 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9519 | hdd_override_ini_config(hdd_ctx); |
| 9520 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9521 | ret = hdd_context_init(hdd_ctx); |
| 9522 | |
| 9523 | if (ret) |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9524 | goto err_hdd_objmgr_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9525 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 9526 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE || |
| 9527 | hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9528 | goto skip_multicast_logging; |
| 9529 | |
| 9530 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 9531 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9532 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 9533 | if (ret) |
| 9534 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9535 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9536 | ret = hdd_init_netlink_services(hdd_ctx); |
| 9537 | if (ret) |
| 9538 | goto err_deinit_txrx_histogram; |
| 9539 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9540 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9541 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9542 | skip_multicast_logging: |
| 9543 | hdd_set_trace_level_for_each(hdd_ctx); |
| 9544 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 9545 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 9546 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9547 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 9548 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9549 | return hdd_ctx; |
| 9550 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9551 | err_deinit_txrx_histogram: |
| 9552 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 9553 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9554 | err_deinit_hdd_context: |
| 9555 | hdd_context_deinit(hdd_ctx); |
| 9556 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9557 | err_hdd_objmgr_destroy: |
| 9558 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 9559 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9560 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9561 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9562 | |
| 9563 | err_free_hdd_context: |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9564 | qdf_delayed_work_destroy(&hdd_ctx->psoc_idle_timeout_work); |
| 9565 | |
| 9566 | wiphy_dealloc: |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 9567 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9568 | |
| 9569 | err_out: |
| 9570 | return ERR_PTR(ret); |
| 9571 | } |
| 9572 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9573 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9574 | * hdd_start_station_adapter()- Start the Station Adapter |
| 9575 | * @adapter: HDD adapter |
| 9576 | * |
| 9577 | * This function initializes the adapter for the station mode. |
| 9578 | * |
| 9579 | * Return: 0 on success or errno on failure. |
| 9580 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9581 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9582 | { |
| 9583 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9584 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9585 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9586 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9587 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9588 | hdd_err("session is already opened, %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9589 | adapter->vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9590 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9591 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9592 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9593 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 9594 | if (ret) { |
| 9595 | hdd_err("failed to create vdev: %d", ret); |
| 9596 | return ret; |
| 9597 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9598 | status = hdd_init_station_mode(adapter); |
| 9599 | |
| 9600 | if (QDF_STATUS_SUCCESS != status) { |
| 9601 | hdd_err("Error Initializing station mode: %d", status); |
| 9602 | return qdf_status_to_os_return(status); |
| 9603 | } |
| 9604 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9605 | hdd_register_tx_flow_control(adapter, |
| 9606 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9607 | hdd_tx_resume_cb, |
| 9608 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9609 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9610 | hdd_exit(); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 9611 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9612 | return 0; |
| 9613 | } |
| 9614 | |
| 9615 | /** |
| 9616 | * hdd_start_ap_adapter()- Start AP Adapter |
| 9617 | * @adapter: HDD adapter |
| 9618 | * |
| 9619 | * This function initializes the adapter for the AP mode. |
| 9620 | * |
| 9621 | * Return: 0 on success errno on failure. |
| 9622 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9623 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9624 | { |
| 9625 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9626 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9627 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9628 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9629 | uint32_t fine_time_meas_cap = 0; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9630 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9631 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9632 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9633 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9634 | hdd_err("session is already opened, %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9635 | adapter->vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9636 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9637 | } |
| 9638 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9639 | * In SSR case no need to create new sap context. |
| 9640 | * Otherwise create sap context first and then create |
| 9641 | * vdev as while creating the vdev, driver needs to |
| 9642 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9643 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9644 | if (adapter->session.ap.sap_context) { |
| 9645 | is_ssr = true; |
| 9646 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9647 | hdd_err("sap creation failed"); |
| 9648 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 9649 | } |
| 9650 | |
| 9651 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 9652 | adapter->session.ap.sap_context); |
| 9653 | if (ret) { |
| 9654 | hdd_err("failed to create vdev, status:%d", ret); |
| 9655 | hdd_sap_destroy_ctx(adapter); |
| 9656 | return ret; |
| 9657 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9658 | |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9659 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 9660 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 9661 | &fine_time_meas_cap); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9662 | sme_cli_set_command(adapter->vdev_id, |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9663 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9664 | (bool)(fine_time_meas_cap & WMI_FW_AP_RTT_RESPR), |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9665 | VDEV_CMD); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9666 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9667 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9668 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9669 | |
| 9670 | if (QDF_STATUS_SUCCESS != status) { |
| 9671 | hdd_err("Error Initializing the AP mode: %d", status); |
| 9672 | return qdf_status_to_os_return(status); |
| 9673 | } |
| 9674 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9675 | hdd_register_tx_flow_control(adapter, |
| 9676 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9677 | hdd_softap_tx_resume_cb, |
| 9678 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9679 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9680 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9681 | return 0; |
| 9682 | } |
| 9683 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9684 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 9685 | /** |
| 9686 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9687 | * @cds_cfg: CDS Configuration |
| 9688 | * @hdd_ctx: Pointer to hdd context |
| 9689 | * |
| 9690 | * Return: none |
| 9691 | */ |
| 9692 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9693 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9694 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9695 | { |
| 9696 | cds_cfg->tx_flow_stop_queue_th = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9697 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9698 | cds_cfg->tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9699 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 9700 | /* configuration for DP RX Threads */ |
| 9701 | cds_cfg->enable_dp_rx_threads = hdd_ctx->enable_dp_rx_threads; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9702 | } |
| 9703 | #else |
| 9704 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9705 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9706 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9707 | { |
| 9708 | } |
| 9709 | #endif |
| 9710 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9711 | /** |
| 9712 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9713 | * @hdd_ctx: HDD Context |
| 9714 | * |
| 9715 | * Return: 0 for Success, errno on failure |
| 9716 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9717 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9718 | { |
| 9719 | struct cds_config_info *cds_cfg; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9720 | int value; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9721 | uint8_t band_capability; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9722 | uint8_t ito_repeat_count; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9723 | bool crash_inject; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9724 | bool self_recovery; |
| 9725 | bool fw_timeout_crash; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9726 | QDF_STATUS status; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9727 | |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9728 | cds_cfg = qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9729 | if (!cds_cfg) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9730 | return -ENOMEM; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9731 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9732 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 9733 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 9734 | &cds_cfg->sta_maxlimod_dtim); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9735 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9736 | status = ucfg_mlme_get_crash_inject(hdd_ctx->psoc, &crash_inject); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9737 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9738 | hdd_err("Failed to get crash inject ini config"); |
| 9739 | goto exit; |
| 9740 | } |
| 9741 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9742 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 9743 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9744 | hdd_err("Failed to get self recovery ini config"); |
| 9745 | goto exit; |
| 9746 | } |
| 9747 | |
| 9748 | status = ucfg_mlme_get_fw_timeout_crash(hdd_ctx->psoc, |
| 9749 | &fw_timeout_crash); |
| 9750 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9751 | hdd_err("Failed to get fw timeout crash ini config"); |
| 9752 | goto exit; |
| 9753 | } |
| 9754 | |
| 9755 | status = ucfg_mlme_get_ito_repeat_count(hdd_ctx->psoc, |
| 9756 | &ito_repeat_count); |
| 9757 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9758 | hdd_err("Failed to get ITO repeat count ini config"); |
| 9759 | goto exit; |
| 9760 | } |
| 9761 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9762 | cds_cfg->force_target_assert_enabled = crash_inject; |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9763 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9764 | ucfg_mlme_get_sap_max_offload_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9765 | cds_cfg->ap_maxoffload_peers = value; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9766 | ucfg_mlme_get_sap_max_offload_reorder_buffs(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9767 | &value); |
| 9768 | cds_cfg->ap_maxoffload_reorderbuffs = value; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9769 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9770 | cds_cfg->reorder_offload = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9771 | cfg_get(hdd_ctx->psoc, CFG_DP_REORDER_OFFLOAD_SUPPORT); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9772 | |
| 9773 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9774 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9775 | |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9776 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9777 | ucfg_mlme_get_sap_max_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9778 | cds_cfg->max_station = value; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9779 | 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] | 9780 | cds_cfg->max_msdus_per_rxinorderind = |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 9781 | cfg_get(hdd_ctx->psoc, CFG_DP_MAX_MSDUS_PER_RXIND); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9782 | cds_cfg->self_recovery_enabled = self_recovery; |
| 9783 | cds_cfg->fw_timeout_crash = fw_timeout_crash; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9784 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9785 | cds_cfg->ito_repeat_count = ito_repeat_count; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9786 | |
| 9787 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9788 | if (QDF_IS_STATUS_ERROR(status)) |
| 9789 | goto exit; |
| 9790 | |
| 9791 | cds_cfg->bandcapability = band_capability; |
Rachit Kankane | 0106e38 | 2018-05-16 18:59:28 +0530 | [diff] [blame] | 9792 | cds_cfg->num_vdevs = hdd_ctx->config->num_vdevs; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9793 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9794 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9795 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9796 | cds_init_ini_config(cds_cfg); |
| 9797 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9798 | |
| 9799 | exit: |
| 9800 | qdf_mem_free(cds_cfg); |
| 9801 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9802 | } |
| 9803 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9804 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9805 | * hdd_update_user_config() - API to update user configuration |
| 9806 | * parameters to obj mgr which are used by multiple components |
| 9807 | * @hdd_ctx: HDD Context |
| 9808 | * |
| 9809 | * Return: 0 for Success, errno on failure |
| 9810 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9811 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9812 | { |
| 9813 | struct wlan_objmgr_psoc_user_config *user_config; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9814 | uint8_t band_capability; |
| 9815 | QDF_STATUS status; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9816 | bool value = false; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9817 | |
| 9818 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9819 | if (QDF_IS_STATUS_ERROR(status)) |
| 9820 | return -EIO; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9821 | |
| 9822 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9823 | if (!user_config) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9824 | return -ENOMEM; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9825 | |
| 9826 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9827 | status = ucfg_mlme_is_11d_enabled(hdd_ctx->psoc, &value); |
| 9828 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9829 | hdd_err("Invalid 11d_enable flag"); |
| 9830 | user_config->is_11d_support_enabled = value; |
| 9831 | |
| 9832 | value = false; |
| 9833 | status = ucfg_mlme_is_11h_enabled(hdd_ctx->psoc, &value); |
| 9834 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9835 | hdd_err("Invalid 11h_enable flag"); |
| 9836 | user_config->is_11h_support_enabled = value; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9837 | user_config->band_capability = band_capability; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9838 | wlan_objmgr_psoc_set_user_config(hdd_ctx->psoc, user_config); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9839 | |
| 9840 | qdf_mem_free(user_config); |
| 9841 | return 0; |
| 9842 | } |
| 9843 | |
| 9844 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9845 | * hdd_init_thermal_info - Initialize thermal level |
| 9846 | * @hdd_ctx: HDD context |
| 9847 | * |
| 9848 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9849 | * which would be called when a configured thermal threshold is hit. |
| 9850 | * |
| 9851 | * Return: 0 on success and errno on failure |
| 9852 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9853 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9854 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9855 | QDF_STATUS status; |
Manikandan Mohan | 9045e2e | 2018-11-26 16:44:19 -0800 | [diff] [blame] | 9856 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9857 | |
Manikandan Mohan | 9045e2e | 2018-11-26 16:44:19 -0800 | [diff] [blame] | 9858 | status = sme_init_thermal_info(mac_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9859 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9860 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9861 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9862 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9863 | sme_add_set_thermal_level_callback(mac_handle, |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9864 | hdd_set_thermal_level_cb); |
| 9865 | |
| 9866 | return 0; |
| 9867 | |
| 9868 | } |
| 9869 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9870 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9871 | /** |
| 9872 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9873 | * |
| 9874 | * Hold RTNL lock |
| 9875 | * |
| 9876 | * Return: True if held and false otherwise |
| 9877 | */ |
| 9878 | static inline bool hdd_hold_rtnl_lock(void) |
| 9879 | { |
| 9880 | rtnl_lock(); |
| 9881 | return true; |
| 9882 | } |
| 9883 | |
| 9884 | /** |
| 9885 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9886 | * |
| 9887 | * Release RTNL lock |
| 9888 | * |
| 9889 | * Return: None |
| 9890 | */ |
| 9891 | static inline void hdd_release_rtnl_lock(void) |
| 9892 | { |
| 9893 | rtnl_unlock(); |
| 9894 | } |
| 9895 | #else |
| 9896 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9897 | static inline void hdd_release_rtnl_lock(void) { } |
| 9898 | #endif |
| 9899 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9900 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9901 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9902 | /* MAX iwpriv command support */ |
| 9903 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9904 | #define PKTLOG_CLEAR_BUFF 4 |
Venkata Sharath Chandra Manchala | 27e4490 | 2019-01-28 11:29:18 -0800 | [diff] [blame] | 9905 | /* Set Maximum pktlog file size to 64MB */ |
| 9906 | #define MAX_PKTLOG_SIZE 64 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9907 | |
| 9908 | /** |
| 9909 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9910 | * @hdd_ctx: hdd context |
| 9911 | * @set_value2: pktlog buffer size value |
| 9912 | * |
| 9913 | * |
| 9914 | * Return: 0 for success or error. |
| 9915 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9916 | 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] | 9917 | { |
| 9918 | struct sir_wifi_start_log start_log = { 0 }; |
| 9919 | QDF_STATUS status; |
| 9920 | |
| 9921 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9922 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9923 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9924 | start_log.user_triggered = 1; |
| 9925 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9926 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9927 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9928 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9929 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9930 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9931 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9932 | return -EINVAL; |
| 9933 | } |
| 9934 | |
| 9935 | return 0; |
| 9936 | } |
| 9937 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9938 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9939 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9940 | * @hdd_ctx: hdd context |
| 9941 | * |
| 9942 | * Return: 0 for success or error. |
| 9943 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9944 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9945 | { |
| 9946 | struct sir_wifi_start_log start_log; |
| 9947 | QDF_STATUS status; |
| 9948 | |
| 9949 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9950 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9951 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9952 | start_log.user_triggered = 1; |
| 9953 | start_log.size = 0; |
| 9954 | start_log.is_pktlog_buff_clear = true; |
| 9955 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9956 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9957 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9958 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9959 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9960 | return -EINVAL; |
| 9961 | } |
| 9962 | |
| 9963 | return 0; |
| 9964 | } |
| 9965 | |
| 9966 | |
| 9967 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9968 | * hdd_process_pktlog_command() - process pktlog command |
| 9969 | * @hdd_ctx: hdd context |
| 9970 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9971 | * @set_value2: pktlog buffer size value |
| 9972 | * |
| 9973 | * This function process pktlog command. |
| 9974 | * set_value2 only matters when set_value is 3 (set buff size) |
| 9975 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9976 | * |
| 9977 | * Return: 0 for success or error. |
| 9978 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9979 | 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] | 9980 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9981 | { |
| 9982 | int ret; |
| 9983 | bool enable; |
| 9984 | uint8_t user_triggered = 0; |
| 9985 | |
| 9986 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9987 | if (0 != ret) |
| 9988 | return ret; |
| 9989 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9990 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9991 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9992 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9993 | hdd_err("invalid pktlog value %d", set_value); |
| 9994 | return -EINVAL; |
| 9995 | } |
| 9996 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9997 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9998 | if (set_value2 <= 0) { |
| 9999 | hdd_err("invalid pktlog size %d", set_value2); |
| 10000 | return -EINVAL; |
| 10001 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
Venkata Sharath Chandra Manchala | 27e4490 | 2019-01-28 11:29:18 -0800 | [diff] [blame] | 10002 | hdd_err_rl("Pktlog size is large. max value is %uMB.", |
| 10003 | MAX_PKTLOG_SIZE); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10004 | return -EINVAL; |
| 10005 | } |
| 10006 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10007 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 10008 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10009 | } |
| 10010 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10011 | /* |
| 10012 | * set_value = 0 then disable packetlog |
| 10013 | * set_value = 1 enable packetlog forcefully |
| 10014 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 10015 | * enable packetlog with AUTO type. |
| 10016 | */ |
| 10017 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 10018 | true : false; |
| 10019 | |
| 10020 | if (1 == set_value) { |
| 10021 | enable = true; |
| 10022 | user_triggered = 1; |
| 10023 | } |
| 10024 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10025 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10026 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10027 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10028 | /** |
| 10029 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 10030 | * @hdd_ctx: HDD context |
| 10031 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10032 | * @user_triggered: triggered through iwpriv |
| 10033 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10034 | * |
| 10035 | * Return: 0 on success; error number otherwise |
| 10036 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10037 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10038 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10039 | { |
| 10040 | struct sir_wifi_start_log start_log; |
| 10041 | QDF_STATUS status; |
| 10042 | |
| 10043 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10044 | start_log.verbose_level = |
| 10045 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10046 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10047 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10048 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10049 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 10050 | /* |
| 10051 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 10052 | * commands. Host uses this flag to decide whether to send pktlog |
| 10053 | * disable command to fw without sending pktlog enable command |
| 10054 | * previously. For eg, If vendor sends pktlog disable command without |
| 10055 | * sending pktlog enable command, then host discards the packet |
| 10056 | * but for iwpriv command, host will send it to fw. |
| 10057 | */ |
| 10058 | start_log.is_iwpriv_command = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10059 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10060 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10061 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10062 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10063 | return -EINVAL; |
| 10064 | } |
| 10065 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10066 | if (enable == true) |
| 10067 | hdd_ctx->is_pktlog_enabled = 1; |
| 10068 | else |
| 10069 | hdd_ctx->is_pktlog_enabled = 0; |
| 10070 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10071 | return 0; |
| 10072 | } |
| 10073 | #endif /* REMOVE_PKT_LOG */ |
| 10074 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10075 | void hdd_free_mac_address_lists(struct hdd_context *hdd_ctx) |
| 10076 | { |
| 10077 | hdd_debug("Resetting MAC address lists"); |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 10078 | qdf_mem_zero(hdd_ctx->provisioned_mac_addr, |
| 10079 | sizeof(hdd_ctx->provisioned_mac_addr)); |
| 10080 | qdf_mem_zero(hdd_ctx->derived_mac_addr, |
| 10081 | sizeof(hdd_ctx->derived_mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10082 | hdd_ctx->num_provisioned_addr = 0; |
| 10083 | hdd_ctx->num_derived_addr = 0; |
| 10084 | hdd_ctx->provisioned_intf_addr_mask = 0; |
| 10085 | hdd_ctx->derived_intf_addr_mask = 0; |
| 10086 | } |
| 10087 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10088 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10089 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 10090 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10091 | * @dev: Device Pointer |
| 10092 | * @num: Number of Valid Mac address |
| 10093 | * |
| 10094 | * Return: Pointer to MAC address buffer |
| 10095 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10096 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 10097 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10098 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10099 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10100 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10101 | |
| 10102 | /** |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10103 | * hdd_get_platform_wlan_derived_mac_buff() - API to query platform driver |
| 10104 | * for derived MAC address |
| 10105 | * @dev: Device Pointer |
| 10106 | * @num: Number of Valid Mac address |
| 10107 | * |
| 10108 | * Return: Pointer to MAC address buffer |
| 10109 | */ |
| 10110 | static uint8_t *hdd_get_platform_wlan_derived_mac_buff(struct device *dev, |
| 10111 | uint32_t *num) |
| 10112 | { |
| 10113 | return pld_get_wlan_derived_mac_address(dev, num); |
| 10114 | } |
| 10115 | |
| 10116 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10117 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 10118 | * @hdd_ctx: HDD Context |
| 10119 | * @num: Number of random mac addresses needed |
| 10120 | * |
| 10121 | * Generate random addresses using bit manipulation on the base mac address |
| 10122 | * |
| 10123 | * Return: None |
| 10124 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10125 | 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] | 10126 | { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10127 | uint32_t idx = hdd_ctx->num_derived_addr; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10128 | uint32_t iter; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10129 | uint8_t *buf = NULL; |
| 10130 | uint8_t macaddr_b3, tmp_br3; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10131 | /* |
| 10132 | * Consider first provisioned mac address as source address to derive |
| 10133 | * remaining addresses |
| 10134 | */ |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10135 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10136 | uint8_t *src = hdd_ctx->provisioned_mac_addr[0].bytes; |
| 10137 | |
| 10138 | for (iter = 0; iter < num; ++iter, ++idx) { |
| 10139 | buf = hdd_ctx->derived_mac_addr[idx].bytes; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10140 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 10141 | macaddr_b3 = buf[3]; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10142 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + idx) & |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10143 | INTF_MACADDR_MASK; |
| 10144 | macaddr_b3 += tmp_br3; |
| 10145 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 10146 | buf[0] |= 0x02; |
| 10147 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10148 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10149 | hdd_ctx->num_derived_addr++; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10150 | } |
| 10151 | } |
| 10152 | |
| 10153 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10154 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10155 | * @hdd_ctx: HDD Context |
| 10156 | * |
| 10157 | * API to get mac addresses from platform driver and update the driver |
| 10158 | * structures and configure FW with the base mac address. |
| 10159 | * Return: int |
| 10160 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10161 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10162 | { |
| 10163 | uint32_t no_of_mac_addr, iter; |
| 10164 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 10165 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 10166 | uint8_t *addr, *buf; |
| 10167 | struct device *dev = hdd_ctx->parent_dev; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10168 | tSirMacAddr mac_addr; |
| 10169 | QDF_STATUS status; |
| 10170 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10171 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10172 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10173 | if (no_of_mac_addr == 0 || !addr) { |
| 10174 | hdd_debug("No mac configured from platform driver"); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10175 | return -EINVAL; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10176 | } |
| 10177 | |
| 10178 | hdd_free_mac_address_lists(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10179 | |
| 10180 | if (no_of_mac_addr > max_mac_addr) |
| 10181 | no_of_mac_addr = max_mac_addr; |
| 10182 | |
| 10183 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 10184 | |
| 10185 | 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] | 10186 | buf = hdd_ctx->provisioned_mac_addr[iter].bytes; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10187 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10188 | hdd_info("provisioned MAC Addr [%d]" MAC_ADDRESS_STR, iter, |
| 10189 | MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10190 | } |
| 10191 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10192 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10193 | hdd_ctx->num_provisioned_addr = no_of_mac_addr; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10194 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10195 | if (hdd_ctx->config->mac_provision) { |
| 10196 | addr = hdd_get_platform_wlan_derived_mac_buff(dev, |
| 10197 | &no_of_mac_addr); |
| 10198 | |
| 10199 | if (no_of_mac_addr == 0 || !addr) |
| 10200 | hdd_warn("No derived address from platform driver"); |
| 10201 | else if (no_of_mac_addr > |
| 10202 | (max_mac_addr - hdd_ctx->num_provisioned_addr)) |
| 10203 | no_of_mac_addr = (max_mac_addr - |
| 10204 | hdd_ctx->num_provisioned_addr); |
| 10205 | |
| 10206 | for (iter = 0; iter < no_of_mac_addr; ++iter, |
| 10207 | addr += mac_addr_size) { |
| 10208 | buf = hdd_ctx->derived_mac_addr[iter].bytes; |
| 10209 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
| 10210 | hdd_debug("derived MAC Addr [%d]" MAC_ADDRESS_STR, iter, |
| 10211 | MAC_ADDR_ARRAY(buf)); |
| 10212 | } |
| 10213 | hdd_ctx->num_derived_addr = no_of_mac_addr; |
| 10214 | } |
| 10215 | |
| 10216 | no_of_mac_addr = hdd_ctx->num_provisioned_addr + |
| 10217 | hdd_ctx->num_derived_addr; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10218 | if (no_of_mac_addr < max_mac_addr) |
| 10219 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 10220 | no_of_mac_addr); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10221 | |
| 10222 | status = sme_set_custom_mac_addr(mac_addr); |
| 10223 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10224 | return -EAGAIN; |
| 10225 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10226 | return 0; |
| 10227 | } |
| 10228 | |
| 10229 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10230 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 10231 | * @hdd_ctx: HDD Context |
| 10232 | * |
| 10233 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 10234 | * will generate its own MAC and update it to FW. |
| 10235 | * |
| 10236 | * Return: 0 for success |
| 10237 | * Non-zero error code for failure |
| 10238 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10239 | 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] | 10240 | { |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10241 | tSirMacAddr custom_mac_addr; |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10242 | QDF_STATUS status; |
| 10243 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10244 | if (hdd_ctx->num_provisioned_addr) |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10245 | qdf_mem_copy(&custom_mac_addr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10246 | &hdd_ctx->provisioned_mac_addr[0].bytes[0], |
| 10247 | sizeof(tSirMacAddr)); |
| 10248 | else |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10249 | qdf_mem_copy(&custom_mac_addr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10250 | &hdd_ctx->derived_mac_addr[0].bytes[0], |
| 10251 | sizeof(tSirMacAddr)); |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10252 | status = sme_set_custom_mac_addr(custom_mac_addr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10253 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10254 | return -EAGAIN; |
| 10255 | return 0; |
| 10256 | } |
| 10257 | |
| 10258 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10259 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 10260 | * @hdd_ctx: HDD Context |
| 10261 | * |
| 10262 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 10263 | * is provisioned with mac addresses, driver uses it, else it will use |
| 10264 | * wlan_mac.bin to update HW MAC addresses. |
| 10265 | * |
| 10266 | * Return: None |
| 10267 | */ |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10268 | static int hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10269 | { |
| 10270 | QDF_STATUS status; |
| 10271 | int ret; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10272 | bool update_mac_addr_to_fw = true; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10273 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10274 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10275 | if (hdd_ctx->config->mac_provision || !ret) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10276 | hdd_info("using MAC address from platform driver"); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10277 | return ret; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10278 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10279 | |
| 10280 | status = hdd_update_mac_config(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10281 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 10282 | hdd_info("using MAC address from wlan_mac.bin"); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10283 | return 0; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10284 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10285 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10286 | hdd_info("using default MAC address"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10287 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10288 | /* Use fw provided MAC */ |
| 10289 | if (!qdf_is_macaddr_zero(&hdd_ctx->hw_macaddr)) { |
| 10290 | hdd_update_macaddr(hdd_ctx, hdd_ctx->hw_macaddr, false); |
| 10291 | update_mac_addr_to_fw = false; |
| 10292 | return 0; |
| 10293 | } else if (hdd_generate_macaddr_auto(hdd_ctx) != 0) { |
| 10294 | struct qdf_mac_addr mac_addr; |
| 10295 | |
| 10296 | hdd_err("MAC failure from device serial no."); |
Jeff Johnson | 51a8052 | 2018-12-11 20:19:44 -0800 | [diff] [blame] | 10297 | qdf_get_random_bytes(&mac_addr, sizeof(mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10298 | /* |
| 10299 | * Reset multicast bit (bit-0) and set |
| 10300 | * locally-administered bit |
| 10301 | */ |
| 10302 | mac_addr.bytes[0] = 0x2; |
| 10303 | hdd_update_macaddr(hdd_ctx, mac_addr, true); |
| 10304 | } |
| 10305 | |
| 10306 | if (update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10307 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10308 | if (ret) |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 10309 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10310 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10311 | return ret; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10312 | } |
| 10313 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10314 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10315 | { |
| 10316 | int vdev_id = 0; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10317 | QDF_STATUS status; |
| 10318 | bool smart_chainmask_enabled; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10319 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10320 | int vpdev = PDEV_CMD; |
| 10321 | int ret; |
| 10322 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10323 | status = ucfg_get_smart_chainmask_enabled(hdd_ctx->psoc, |
| 10324 | &smart_chainmask_enabled); |
| 10325 | if (QDF_IS_STATUS_ERROR(status)) |
| 10326 | return -EINVAL; |
| 10327 | |
| 10328 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10329 | (int)smart_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10330 | if (ret) |
| 10331 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 10332 | |
| 10333 | return ret; |
| 10334 | } |
| 10335 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10336 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10337 | { |
| 10338 | int vdev_id = 0; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10339 | QDF_STATUS status; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10340 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10341 | bool alternative_chainmask_enabled; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10342 | int vpdev = PDEV_CMD; |
| 10343 | int ret; |
| 10344 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10345 | status = ucfg_get_alternative_chainmask_enabled( |
| 10346 | hdd_ctx->psoc, |
| 10347 | &alternative_chainmask_enabled); |
| 10348 | if (QDF_IS_STATUS_ERROR(status)) |
| 10349 | return -EINVAL; |
| 10350 | |
| 10351 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10352 | (int)alternative_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10353 | if (ret) |
| 10354 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 10355 | ret); |
| 10356 | |
| 10357 | return ret; |
| 10358 | } |
| 10359 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10360 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10361 | { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10362 | QDF_STATUS status; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10363 | int vdev_id = 0; |
| 10364 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10365 | bool value; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10366 | int vpdev = PDEV_CMD; |
| 10367 | int ret; |
| 10368 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10369 | status = ucfg_fwol_get_ani_enabled(hdd_ctx->psoc, &value); |
| 10370 | if (QDF_IS_STATUS_ERROR(status)) |
| 10371 | return -EINVAL; |
| 10372 | |
| 10373 | ret = sme_cli_set_command(vdev_id, param_id, (int)value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10374 | if (ret) |
| 10375 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 10376 | |
| 10377 | return ret; |
| 10378 | } |
| 10379 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 10380 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10381 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 10382 | * @hdd_ctx: HDD context |
| 10383 | * |
| 10384 | * Pre configurations to be done at lower layer before calling cds enable. |
| 10385 | * |
| 10386 | * Return: 0 on success and errno on failure. |
| 10387 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10388 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10389 | { |
| 10390 | int ret; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10391 | uint8_t val = 0; |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10392 | QDF_STATUS status; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10393 | uint32_t arp_ac_category; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10394 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10395 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10396 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Ajit Pal Singh | 5d26961 | 2018-04-19 16:29:12 +0530 | [diff] [blame] | 10397 | /* Register HL netdev flow control callback */ |
| 10398 | cdp_hl_fc_register(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10399 | |
| 10400 | /* |
| 10401 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 10402 | * The cfg download must occur before we update the SME config |
| 10403 | * since the SME config operation must access the cfg database |
| 10404 | */ |
| 10405 | status = hdd_set_sme_config(hdd_ctx); |
| 10406 | |
| 10407 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10408 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10409 | ret = qdf_status_to_os_return(status); |
| 10410 | goto out; |
| 10411 | } |
| 10412 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 10413 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 10414 | if (QDF_STATUS_SUCCESS != status) { |
| 10415 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 10416 | ret = qdf_status_to_os_return(status); |
| 10417 | goto out; |
| 10418 | } |
| 10419 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10420 | status = ucfg_mlme_get_tx_chainmask_1ss(hdd_ctx->psoc, &val); |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10421 | if (QDF_STATUS_SUCCESS != status) { |
| 10422 | hdd_err("Get tx_chainmask_1ss from mlme failed"); |
| 10423 | ret = qdf_status_to_os_return(status); |
| 10424 | goto out; |
| 10425 | } |
| 10426 | 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] | 10427 | PDEV_CMD); |
| 10428 | if (0 != ret) { |
| 10429 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 10430 | goto out; |
| 10431 | } |
| 10432 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10433 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 10434 | if (ret) |
| 10435 | goto out; |
| 10436 | |
| 10437 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 10438 | if (ret) |
| 10439 | goto out; |
| 10440 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10441 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 10442 | if (ret) |
| 10443 | goto out; |
| 10444 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10445 | status = ucfg_get_arp_ac_category(hdd_ctx->psoc, &arp_ac_category); |
| 10446 | |
| 10447 | if (QDF_IS_STATUS_ERROR(status)) |
| 10448 | return -EINVAL; |
| 10449 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10450 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10451 | arp_ac_category, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10452 | PDEV_CMD); |
| 10453 | if (0 != ret) { |
| 10454 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10455 | arp_ac_category, ret); |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10456 | goto out; |
| 10457 | } |
| 10458 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10459 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 10460 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10461 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10462 | ret = qdf_status_to_os_return(status); |
| 10463 | goto out; |
| 10464 | } |
| 10465 | |
| 10466 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 10467 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10468 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10469 | ret = -EINVAL; |
| 10470 | goto out; |
| 10471 | } |
| 10472 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10473 | |
| 10474 | hdd_init_channel_avoidance(hdd_ctx); |
| 10475 | |
| 10476 | out: |
| 10477 | return ret; |
| 10478 | } |
| 10479 | |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10480 | #ifdef FEATURE_P2P_LISTEN_OFFLOAD |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10481 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10482 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10483 | * @context: context registered with sme_register_p2p_lo_event(). HDD |
| 10484 | * always registers a hdd context pointer |
| 10485 | * @evt:event structure pointer |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10486 | * |
| 10487 | * This is the p2p listen offload stop event handler, it sends vendor |
| 10488 | * event back to supplicant to notify the stop reason. |
| 10489 | * |
| 10490 | * Return: None |
| 10491 | */ |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10492 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10493 | struct sir_p2p_lo_event *evt) |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10494 | { |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10495 | struct hdd_context *hdd_ctx = context; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10496 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10497 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10498 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10499 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10500 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 10501 | if (!hdd_ctx) { |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10502 | hdd_err("Invalid HDD context pointer"); |
| 10503 | return; |
| 10504 | } |
| 10505 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10506 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 10507 | if (!adapter) { |
| 10508 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 10509 | evt->vdev_id); |
| 10510 | return; |
| 10511 | } |
| 10512 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10513 | vendor_event = |
| 10514 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10515 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10516 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 10517 | GFP_KERNEL); |
| 10518 | |
| 10519 | if (!vendor_event) { |
| 10520 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 10521 | return; |
| 10522 | } |
| 10523 | |
| 10524 | if (nla_put_u32(vendor_event, |
| 10525 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 10526 | evt->reason_code)) { |
| 10527 | hdd_err("nla put failed"); |
| 10528 | kfree_skb(vendor_event); |
| 10529 | return; |
| 10530 | } |
| 10531 | |
| 10532 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10533 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 10534 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10535 | } |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10536 | #else |
| 10537 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10538 | struct sir_p2p_lo_event *evt) |
| 10539 | { |
| 10540 | } |
| 10541 | #endif |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10542 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10543 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 10544 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10545 | { |
| 10546 | return sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap); |
| 10547 | } |
| 10548 | #else |
| 10549 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10550 | { |
| 10551 | return QDF_STATUS_SUCCESS; |
| 10552 | } |
| 10553 | #endif |
| 10554 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10555 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10556 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 10557 | * @hdd_ctx: HDD context |
| 10558 | * |
| 10559 | * This function sends the adaptive dwell time config configuration to the |
| 10560 | * firmware via WMA |
| 10561 | * |
| 10562 | * Return: 0 - success, < 0 - failure |
| 10563 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10564 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10565 | { |
| 10566 | QDF_STATUS status; |
| 10567 | struct adaptive_dwelltime_params dwelltime_params; |
| 10568 | |
Harprit Chhabada | d59ae76 | 2019-01-08 16:40:43 -0800 | [diff] [blame] | 10569 | status = ucfg_fwol_get_all_adaptive_dwelltime_params(hdd_ctx->psoc, |
| 10570 | &dwelltime_params); |
| 10571 | status = ucfg_fwol_set_adaptive_dwelltime_config(&dwelltime_params); |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10572 | |
| 10573 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 10574 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10575 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 10576 | return -EAGAIN; |
| 10577 | } |
| 10578 | return 0; |
| 10579 | } |
| 10580 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10581 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10582 | { |
| 10583 | QDF_STATUS status; |
| 10584 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 10585 | uint32_t i = 0; |
| 10586 | uint8_t count = 0, numentries = 0; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10587 | uint8_t dual_mac_feature; |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10588 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10589 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 10590 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10591 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 10592 | &dual_mac_feature); |
| 10593 | |
| 10594 | if (status != QDF_STATUS_SUCCESS) { |
| 10595 | hdd_err("can't get dual mac feature flag"); |
| 10596 | return -EINVAL; |
| 10597 | } |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10598 | /* check if DBS is enabled or supported */ |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10599 | if ((dual_mac_feature == DISABLE_DBS_CXN_AND_SCAN) || |
| 10600 | (dual_mac_feature == ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10601 | return -EINVAL; |
| 10602 | |
| 10603 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 10604 | dbs_scan_config, &numentries, |
| 10605 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10606 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 10607 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10608 | if (!numentries) { |
Dustin Brown | 6a8d39b | 2018-08-14 15:27:26 -0700 | [diff] [blame] | 10609 | hdd_debug("Do not send scan_selection_config"); |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10610 | return 0; |
| 10611 | } |
| 10612 | |
| 10613 | /* hdd_set_fw_log_params */ |
| 10614 | dbs_scan_params.num_clients = 0; |
| 10615 | while (count < (numentries - 2)) { |
| 10616 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 10617 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 10618 | dbs_scan_params.num_non_dbs_scans[i] = |
| 10619 | dbs_scan_config[count + 2]; |
| 10620 | dbs_scan_params.num_clients++; |
| 10621 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 10622 | dbs_scan_params.module_id[i], |
| 10623 | dbs_scan_params.num_dbs_scans[i], |
| 10624 | dbs_scan_params.num_non_dbs_scans[i]); |
| 10625 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 10626 | i++; |
| 10627 | } |
| 10628 | |
| 10629 | dbs_scan_params.pdev_id = 0; |
| 10630 | |
| 10631 | hdd_debug("clients:%d pdev:%d", |
| 10632 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 10633 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10634 | status = sme_set_dbs_scan_selection_config(hdd_ctx->mac_handle, |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10635 | &dbs_scan_params); |
| 10636 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 10637 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10638 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 10639 | return -EAGAIN; |
| 10640 | } |
| 10641 | return 0; |
| 10642 | } |
| 10643 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10644 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10645 | /** |
| 10646 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 10647 | * @hdd_ctx: HDD context |
| 10648 | * |
| 10649 | * Set auto shutdown callback to get indications from firmware to indicate |
| 10650 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 10651 | * |
| 10652 | * Return: 0 on success and errno on failure. |
| 10653 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10654 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10655 | { |
| 10656 | QDF_STATUS status; |
| 10657 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 10658 | if (!hdd_ctx->config->wlan_auto_shutdown) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10659 | return 0; |
| 10660 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10661 | status = sme_set_auto_shutdown_cb(hdd_ctx->mac_handle, |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10662 | wlan_hdd_auto_shutdown_cb); |
| 10663 | if (status != QDF_STATUS_SUCCESS) |
| 10664 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 10665 | status); |
| 10666 | |
| 10667 | return qdf_status_to_os_return(status); |
| 10668 | } |
| 10669 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10670 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10671 | { |
| 10672 | return 0; |
| 10673 | } |
| 10674 | #endif |
| 10675 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10676 | #ifdef MWS_COEX |
| 10677 | /** |
| 10678 | * hdd_set_mws_coex() - Set MWS coex configurations |
| 10679 | * @hdd_ctx: HDD context |
| 10680 | * |
| 10681 | * This function sends MWS-COEX 4G quick FTDM and |
| 10682 | * MWS-COEX 5G-NR power limit to FW |
| 10683 | * |
| 10684 | * Return: 0 on success and errno on failure. |
| 10685 | */ |
| 10686 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10687 | { |
| 10688 | int ret = 0; |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10689 | uint32_t mws_coex_4g_quick_tdm = 0, mws_coex_5g_nr_pwr_limit = 0; |
| 10690 | |
| 10691 | ucfg_mlme_get_mws_coex_4g_quick_tdm(hdd_ctx->psoc, |
| 10692 | &mws_coex_4g_quick_tdm); |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10693 | |
| 10694 | 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] | 10695 | mws_coex_4g_quick_tdm, |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10696 | PDEV_CMD); |
| 10697 | if (ret) { |
| 10698 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10699 | return ret; |
| 10700 | } |
| 10701 | |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10702 | ucfg_mlme_get_mws_coex_5g_nr_pwr_limit(hdd_ctx->psoc, |
| 10703 | &mws_coex_5g_nr_pwr_limit); |
| 10704 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10705 | 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] | 10706 | mws_coex_5g_nr_pwr_limit, |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10707 | PDEV_CMD); |
| 10708 | if (ret) { |
| 10709 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10710 | return ret; |
| 10711 | } |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10712 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10713 | return ret; |
| 10714 | } |
| 10715 | #else |
| 10716 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10717 | { |
| 10718 | return 0; |
| 10719 | } |
| 10720 | #endif |
| 10721 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10722 | /** |
| 10723 | * hdd_features_init() - Init features |
| 10724 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10725 | * |
| 10726 | * Initialize features and their feature context after WLAN firmware is up. |
| 10727 | * |
| 10728 | * Return: 0 on success and errno on failure. |
| 10729 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10730 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10731 | { |
Jeff Johnson | 19ce8d0 | 2019-02-08 22:56:23 -0800 | [diff] [blame] | 10732 | struct tx_power_limit hddtxlimit; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10733 | QDF_STATUS status; |
| 10734 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10735 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10736 | struct hdd_config *cfg; |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 10737 | bool b_cts2self, is_imps_enabled; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10738 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10739 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10740 | |
Dustin Brown | ad698ae | 2018-09-05 17:19:30 -0700 | [diff] [blame] | 10741 | ret = hdd_update_country_code(hdd_ctx); |
| 10742 | if (ret) { |
| 10743 | hdd_err("Failed to update country code; errno:%d", ret); |
| 10744 | return -EINVAL; |
| 10745 | } |
| 10746 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10747 | ret = hdd_init_mws_coex(hdd_ctx); |
| 10748 | if (ret) |
| 10749 | hdd_warn("Error initializing mws-coex"); |
| 10750 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10751 | cfg = hdd_ctx->config; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10752 | /* FW capabilities received, Set the Dot11 mode */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10753 | mac_handle = hdd_ctx->mac_handle; |
| 10754 | sme_setdef_dot11mode(mac_handle); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10755 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 10756 | ucfg_mlme_is_imps_enabled(hdd_ctx->psoc, &is_imps_enabled); |
| 10757 | hdd_set_idle_ps_config(hdd_ctx, is_imps_enabled); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10758 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10759 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10760 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 10761 | cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 10762 | cfg_dp_enable_data_stall), PDEV_CMD); |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10763 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10764 | ucfg_mlme_get_go_cts2self_for_sta(hdd_ctx->psoc, &b_cts2self); |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 10765 | if (b_cts2self) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10766 | sme_set_cts2self_for_p2p_go(mac_handle); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10767 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10768 | if (hdd_set_vc_mode_config(hdd_ctx)) |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10769 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10770 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10771 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10772 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10773 | |
| 10774 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10775 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10776 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10777 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10778 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10779 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10780 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10781 | if (ret) { |
| 10782 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10783 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10784 | } |
| 10785 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10786 | /** |
| 10787 | * In case of SSR/PDR, if pktlog was enabled manually before |
Rakshith Suresh Patkar | 6d95526 | 2019-03-13 16:51:50 +0530 | [diff] [blame] | 10788 | * SSR/PDR, then enable it again automatically after Wlan |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10789 | * device up. |
Rakshith Suresh Patkar | 6d95526 | 2019-03-13 16:51:50 +0530 | [diff] [blame] | 10790 | * During SSR/PDR, pktlog will be disabled as part of |
| 10791 | * hdd_features_deinit if pktlog is enabled in ini. |
| 10792 | * Re-enable pktlog in SSR case, if pktlog is enabled in ini. |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10793 | */ |
Rakshith Suresh Patkar | 6d95526 | 2019-03-13 16:51:50 +0530 | [diff] [blame] | 10794 | if (cds_is_packet_log_enabled() || |
| 10795 | (cds_is_driver_recovering() && hdd_ctx->is_pktlog_enabled)) |
Alok Kumar | 5a75b9d | 2018-08-31 10:55:43 +0530 | [diff] [blame] | 10796 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10797 | |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 10798 | hddtxlimit.txPower2g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_2G); |
| 10799 | hddtxlimit.txPower5g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_5G); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10800 | status = sme_txpower_limit(mac_handle, &hddtxlimit); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10801 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10802 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10803 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10804 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10805 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 10806 | status = sme_enable_disable_chanavoidind_event(mac_handle, 0); |
| 10807 | if (QDF_IS_STATUS_ERROR(status) && (status != QDF_STATUS_E_NOSUPPORT)) { |
| 10808 | hdd_err("Failed to disable Chan Avoidance Indication"); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10809 | return -EINVAL; |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10810 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10811 | |
| 10812 | /* register P2P Listen Offload event callback */ |
| 10813 | if (wma_is_p2p_lo_capable()) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10814 | sme_register_p2p_lo_event(mac_handle, hdd_ctx, |
| 10815 | wlan_hdd_p2p_lo_event_callback); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10816 | |
| 10817 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10818 | |
| 10819 | if (ret) |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10820 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10821 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10822 | wlan_hdd_init_chan_info(hdd_ctx); |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10823 | wlan_hdd_twt_init(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10824 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10825 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10826 | return 0; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10827 | } |
| 10828 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10829 | /** |
| 10830 | * hdd_features_deinit() - Deinit features |
| 10831 | * @hdd_ctx: HDD context |
| 10832 | * |
| 10833 | * De-Initialize features and their feature context. |
| 10834 | * |
| 10835 | * Return: none. |
| 10836 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10837 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10838 | { |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10839 | wlan_hdd_twt_deinit(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10840 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10841 | wlan_hdd_tsf_deinit(hdd_ctx); |
jitiphil | 4e3bef4 | 2018-11-14 14:31:13 +0530 | [diff] [blame] | 10842 | if (cds_is_packet_log_enabled()) |
| 10843 | hdd_pktlog_enable_disable(hdd_ctx, false, 0, 0); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10844 | } |
| 10845 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10846 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10847 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10848 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10849 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10850 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10851 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10852 | 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] | 10853 | { |
| 10854 | QDF_STATUS status; |
| 10855 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10856 | status = ucfg_scan_register_bcn_cb(hdd_ctx->psoc, |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10857 | wlan_cfg80211_inform_bss_frame, |
| 10858 | SCAN_CB_TYPE_INFORM_BCN); |
| 10859 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Abhishek Singh | 5ffe9de | 2019-03-05 15:42:43 +0530 | [diff] [blame] | 10860 | hdd_err("failed to register SCAN_CB_TYPE_INFORM_BCN with status code %08d [x%08x]", |
| 10861 | status, status); |
| 10862 | return status; |
| 10863 | } |
| 10864 | |
| 10865 | status = ucfg_scan_register_bcn_cb(hdd_ctx->psoc, |
| 10866 | wlan_cfg80211_unlink_bss_list, |
| 10867 | SCAN_CB_TYPE_UNLINK_BSS); |
| 10868 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10869 | 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] | 10870 | status, status); |
| 10871 | return status; |
| 10872 | } |
| 10873 | |
| 10874 | return QDF_STATUS_SUCCESS; |
| 10875 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10876 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10877 | /** |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 10878 | * hdd_v2_flow_pool_map() - Flow pool create callback when vdev is active |
| 10879 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10880 | * |
| 10881 | * Return: none. |
| 10882 | */ |
| 10883 | static void hdd_v2_flow_pool_map(int vdev_id) |
| 10884 | { |
| 10885 | QDF_STATUS status; |
| 10886 | |
| 10887 | status = cdp_flow_pool_map(cds_get_context(QDF_MODULE_ID_SOC), |
| 10888 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 10889 | vdev_id); |
| 10890 | /* |
| 10891 | * For Adrastea flow control v2 is based on FW MAP events, |
| 10892 | * so this above callback is not implemented. |
| 10893 | * Hence this is not actual failure. Dont return failure |
| 10894 | */ |
| 10895 | if ((status != QDF_STATUS_SUCCESS) && |
| 10896 | (status != QDF_STATUS_E_INVAL)) { |
| 10897 | hdd_err("vdev_id: %d, failed to create flow pool status %d", |
| 10898 | vdev_id, status); |
| 10899 | } |
| 10900 | } |
| 10901 | |
| 10902 | /** |
| 10903 | * hdd_v2_flow_pool_unmap() - Flow pool create callback when vdev is not active |
| 10904 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10905 | * |
| 10906 | * Return: none. |
| 10907 | */ |
| 10908 | static void hdd_v2_flow_pool_unmap(int vdev_id) |
| 10909 | { |
| 10910 | cdp_flow_pool_unmap(cds_get_context(QDF_MODULE_ID_SOC), |
| 10911 | cds_get_context(QDF_MODULE_ID_TXRX), vdev_id); |
| 10912 | } |
| 10913 | |
| 10914 | /** |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10915 | * hdd_action_oui_config() - Configure action_oui strings |
| 10916 | * @hdd_ctx: pointer to hdd context |
| 10917 | * |
| 10918 | * This is a HDD wrapper function which invokes ucfg api |
| 10919 | * of action_oui component to parse action oui strings. |
| 10920 | * |
| 10921 | * Return: None |
| 10922 | */ |
| 10923 | static void hdd_action_oui_config(struct hdd_context *hdd_ctx) |
| 10924 | { |
| 10925 | QDF_STATUS status; |
| 10926 | uint32_t id; |
| 10927 | uint8_t *str; |
| 10928 | |
| 10929 | if (!hdd_ctx->config->action_oui_enable) |
| 10930 | return; |
| 10931 | |
| 10932 | for (id = 0; id < ACTION_OUI_MAXIMUM_ID; id++) { |
| 10933 | str = hdd_ctx->config->action_oui_str[id]; |
| 10934 | if (!qdf_str_len(str)) |
| 10935 | continue; |
| 10936 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10937 | status = ucfg_action_oui_parse(hdd_ctx->psoc, str, id); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10938 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10939 | hdd_err("Failed to parse action_oui str: %u", id); |
| 10940 | } |
| 10941 | } |
| 10942 | |
| 10943 | /** |
| 10944 | * hdd_action_oui_send() - Send action_oui extensions to firmware |
| 10945 | * @hdd_ctx: pointer to hdd context |
| 10946 | * |
| 10947 | * This is a HDD wrapper function which invokes ucfg api |
| 10948 | * of action_oui component to send action oui extensions to firmware. |
| 10949 | * |
| 10950 | * Return: None |
| 10951 | */ |
| 10952 | static void hdd_action_oui_send(struct hdd_context *hdd_ctx) |
| 10953 | { |
| 10954 | QDF_STATUS status; |
| 10955 | |
| 10956 | if (!hdd_ctx->config->action_oui_enable) |
| 10957 | return; |
| 10958 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10959 | status = ucfg_action_oui_send(hdd_ctx->psoc); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10960 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10961 | hdd_err("Failed to send one or all action_ouis"); |
| 10962 | } |
| 10963 | |
Jeff Johnson | 0187c62 | 2019-01-04 06:39:44 -0800 | [diff] [blame] | 10964 | static void hdd_hastings_bt_war_initialize(struct hdd_context *hdd_ctx) |
| 10965 | { |
| 10966 | if (hdd_ctx->config->iface_change_wait_time) |
| 10967 | hdd_hastings_bt_war_disable_fw(hdd_ctx); |
| 10968 | else |
| 10969 | hdd_hastings_bt_war_enable_fw(hdd_ctx); |
| 10970 | } |
| 10971 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10972 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10973 | * hdd_configure_cds() - Configure cds modules |
| 10974 | * @hdd_ctx: HDD context |
| 10975 | * @adapter: Primary adapter context |
| 10976 | * |
| 10977 | * Enable Cds modules after WLAN firmware is up. |
| 10978 | * |
| 10979 | * Return: 0 on success and errno on failure. |
| 10980 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10981 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10982 | { |
| 10983 | int ret; |
| 10984 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10985 | int set_value; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10986 | mac_handle_t mac_handle; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10987 | bool enable_rts_sifsbursting; |
| 10988 | uint8_t enable_phy_reg_retention; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10989 | uint8_t max_mpdus_inampdu, is_force_1x1 = 0; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10990 | uint32_t num_abg_tx_chains = 0; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10991 | uint16_t num_11b_tx_chains = 0; |
| 10992 | uint16_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10993 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 10994 | bool value; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 10995 | enum pmo_auto_pwr_detect_failure_mode auto_power_fail_mode; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 10996 | bool bval = false; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10997 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10998 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10999 | |
| 11000 | hdd_action_oui_send(hdd_ctx); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11001 | status = ucfg_policy_mgr_get_force_1x1(hdd_ctx->psoc, &is_force_1x1); |
| 11002 | if (status != QDF_STATUS_SUCCESS) { |
| 11003 | hdd_err("Failed to get force 1x1 value"); |
| 11004 | goto out; |
| 11005 | } |
| 11006 | if (is_force_1x1) |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11007 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 11008 | 1, PDEV_CMD); |
| 11009 | /* set chip power save failure detected callback */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11010 | sme_set_chip_pwr_save_fail_cb(mac_handle, |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11011 | hdd_chip_pwr_save_fail_detected_cb); |
| 11012 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11013 | status = ucfg_get_max_mpdus_inampdu(hdd_ctx->psoc, |
| 11014 | &max_mpdus_inampdu); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11015 | if (status) { |
| 11016 | hdd_err("Failed to get max mpdus in ampdu value"); |
| 11017 | goto out; |
| 11018 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11019 | |
| 11020 | if (max_mpdus_inampdu) { |
| 11021 | set_value = max_mpdus_inampdu; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11022 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 11023 | set_value, PDEV_CMD); |
| 11024 | } |
| 11025 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11026 | status = ucfg_get_enable_rts_sifsbursting(hdd_ctx->psoc, |
| 11027 | &enable_rts_sifsbursting); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11028 | if (status) { |
| 11029 | hdd_err("Failed to get rts sifs bursting value"); |
| 11030 | goto out; |
| 11031 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11032 | |
| 11033 | if (enable_rts_sifsbursting) { |
| 11034 | set_value = enable_rts_sifsbursting; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11035 | sme_cli_set_command(0, |
| 11036 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 11037 | set_value, PDEV_CMD); |
| 11038 | } |
| 11039 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 11040 | ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11041 | if (value) { |
| 11042 | set_value = value; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11043 | sme_cli_set_command(0, |
| 11044 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 11045 | set_value, PDEV_CMD); |
| 11046 | } |
| 11047 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11048 | status = ucfg_mlme_get_num_11b_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11049 | &num_11b_tx_chains); |
| 11050 | if (status != QDF_STATUS_SUCCESS) { |
| 11051 | hdd_err("Failed to get num_11b_tx_chains"); |
| 11052 | goto out; |
| 11053 | } |
| 11054 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11055 | status = ucfg_mlme_get_num_11ag_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11056 | &num_11ag_tx_chains); |
| 11057 | if (status != QDF_STATUS_SUCCESS) { |
| 11058 | hdd_err("Failed to get num_11ag_tx_chains"); |
| 11059 | goto out; |
| 11060 | } |
| 11061 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11062 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 11063 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11064 | hdd_err("unable to get vht_enable2x2"); |
| 11065 | |
| 11066 | if (!bval) { |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11067 | if (num_11b_tx_chains > 1) |
| 11068 | num_11b_tx_chains = 1; |
| 11069 | if (num_11ag_tx_chains > 1) |
| 11070 | num_11ag_tx_chains = 1; |
| 11071 | } |
| 11072 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11073 | num_11b_tx_chains); |
| 11074 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11075 | num_11ag_tx_chains); |
| 11076 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 11077 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11078 | |
Paul Zhang | 02526cd | 2018-09-20 17:47:46 +0800 | [diff] [blame] | 11079 | if (!ucfg_reg_is_regdb_offloaded(hdd_ctx->psoc)) |
| 11080 | ucfg_reg_program_default_cc(hdd_ctx->pdev, |
| 11081 | hdd_ctx->reg.reg_domain); |
| 11082 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11083 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 11084 | if (ret) { |
| 11085 | hdd_err("Failed to pre-configure cds"); |
| 11086 | goto out; |
| 11087 | } |
| 11088 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11089 | /* Always get latest IPA resources allocated from cds_open and configure |
| 11090 | * IPA module before configuring them to FW. Sequence required as crash |
| 11091 | * observed otherwise. |
| 11092 | */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11093 | if (ucfg_ipa_uc_ol_init(hdd_ctx->pdev, |
| 11094 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 11095 | hdd_err("Failed to setup pipes"); |
| 11096 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11097 | } |
| 11098 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11099 | /* |
| 11100 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 11101 | * else |
| 11102 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11103 | status = cds_enable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11104 | |
| 11105 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11106 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11107 | goto out; |
| 11108 | } |
| 11109 | |
| 11110 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 11111 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11112 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11113 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11114 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11115 | status = hdd_register_bcn_cb(hdd_ctx); |
| 11116 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 11117 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11118 | goto cds_disable; |
| 11119 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11120 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11121 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11122 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11123 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11124 | |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 11125 | /* Donot disable rx offload on concurrency for lithium based targets */ |
| 11126 | if (!(hdd_ctx->target_type == TARGET_TYPE_QCA6290 || |
| 11127 | hdd_ctx->target_type == TARGET_TYPE_QCA6390)) |
| 11128 | if (hdd_ctx->ol_enable) |
| 11129 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 11130 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11131 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 11132 | 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] | 11133 | dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; |
| 11134 | dp_cbs.hdd_v2_flow_pool_unmap = hdd_v2_flow_pool_unmap; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11135 | status = policy_mgr_register_dp_cb(hdd_ctx->psoc, &dp_cbs); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11136 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11137 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11138 | goto cds_disable; |
| 11139 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11140 | status = policy_mgr_register_mode_change_cb(hdd_ctx->psoc, |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11141 | wlan_hdd_send_mode_change_event); |
| 11142 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 11143 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 11144 | goto cds_disable; |
| 11145 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11146 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 11147 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 11148 | hdd_debug("enhance green ap is not enabled"); |
| 11149 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 11150 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 11151 | hdd_debug("Failed to set wow pulse"); |
| 11152 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 11153 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
Manikandan Mohan | 66df7fc | 2019-01-08 17:57:05 -0800 | [diff] [blame] | 11154 | ucfg_fwol_get_gcmp_enable(hdd_ctx->psoc), PDEV_CMD); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11155 | |
| 11156 | auto_power_fail_mode = |
| 11157 | ucfg_pmo_get_auto_power_fail_mode(hdd_ctx->psoc); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11158 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11159 | auto_power_fail_mode, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11160 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11161 | status = ucfg_get_enable_phy_reg_retention(hdd_ctx->psoc, |
| 11162 | &enable_phy_reg_retention); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11163 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11164 | if (QDF_IS_STATUS_ERROR(status)) |
| 11165 | return -EINVAL; |
| 11166 | |
| 11167 | if (enable_phy_reg_retention) |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11168 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11169 | enable_phy_reg_retention, PDEV_CMD); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11170 | |
Jeff Johnson | 0187c62 | 2019-01-04 06:39:44 -0800 | [diff] [blame] | 11171 | hdd_hastings_bt_war_initialize(hdd_ctx); |
| 11172 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11173 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11174 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11175 | cds_disable: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11176 | cds_disable(hdd_ctx->psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11177 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11178 | out: |
| 11179 | return -EINVAL; |
| 11180 | } |
| 11181 | |
| 11182 | /** |
| 11183 | * hdd_deconfigure_cds() -De-Configure cds |
| 11184 | * @hdd_ctx: HDD context |
| 11185 | * |
| 11186 | * Deconfigure Cds modules before WLAN firmware is down. |
| 11187 | * |
| 11188 | * Return: 0 on success and errno on failure. |
| 11189 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11190 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11191 | { |
| 11192 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11193 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11194 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11195 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 11196 | |
| 11197 | /* De-init features */ |
| 11198 | hdd_features_deinit(hdd_ctx); |
| 11199 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11200 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->psoc); |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 11201 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11202 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11203 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11204 | qdf_status = cds_disable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11205 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11206 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 11207 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11208 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11209 | } |
| 11210 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11211 | 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] | 11212 | hdd_err("Failed to disconnect pipes"); |
| 11213 | ret = -EINVAL; |
| 11214 | } |
| 11215 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11216 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11217 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11218 | } |
| 11219 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11220 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 11221 | static void hdd_deregister_policy_manager_callback( |
| 11222 | struct wlan_objmgr_psoc *psoc) |
| 11223 | { |
| 11224 | if (QDF_STATUS_SUCCESS != |
| 11225 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 11226 | hdd_err("HDD callback deregister with policy manager failed"); |
| 11227 | } |
| 11228 | } |
| 11229 | #else |
| 11230 | static void hdd_deregister_policy_manager_callback( |
| 11231 | struct wlan_objmgr_psoc *psoc) |
| 11232 | { |
| 11233 | } |
| 11234 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11235 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11236 | 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] | 11237 | { |
| 11238 | void *hif_ctx; |
| 11239 | qdf_device_t qdf_ctx; |
| 11240 | QDF_STATUS qdf_status; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11241 | bool is_recovery_stop = cds_is_driver_recovering(); |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11242 | int ret = 0; |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11243 | int debugfs_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11244 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11245 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11246 | hdd_enter(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11247 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11248 | hdd_deregister_policy_manager_callback(hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11249 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11250 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11251 | if (!qdf_ctx) { |
| 11252 | hdd_err("QDF device context NULL"); |
| 11253 | return -EINVAL; |
| 11254 | } |
| 11255 | |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11256 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11257 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11258 | debugfs_threads = hdd_return_debugfs_threads_count(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11259 | |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 11260 | if (debugfs_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
| 11261 | hdd_warn("Debugfs threads %d, wiphy suspend %d", |
| 11262 | debugfs_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11263 | |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11264 | if (IS_IDLE_STOP && !ftm_mode) { |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 11265 | hdd_psoc_idle_timer_start(hdd_ctx); |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11266 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11267 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11268 | return 0; |
| 11269 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 11270 | } |
| 11271 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 11272 | /* free user wowl patterns */ |
| 11273 | hdd_free_user_wowl_ptrns(); |
| 11274 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11275 | switch (hdd_ctx->driver_status) { |
| 11276 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11277 | hdd_debug("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11278 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11279 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11280 | hdd_debug("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11281 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11282 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 11283 | hdd_info("Wlan transitioning (CLOSED <- ENABLED)"); |
| 11284 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11285 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE || |
| 11286 | hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 11287 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11288 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 11289 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11290 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11291 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11292 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11293 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11294 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11295 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11296 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11297 | break; |
| 11298 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11299 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11300 | hdd_ctx->driver_status); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11301 | ret = -EINVAL; |
| 11302 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11303 | } |
| 11304 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11305 | hdd_sysfs_destroy_powerstats_interface(); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11306 | hdd_sysfs_destroy_version_interface(); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11307 | hdd_sysfs_destroy_driver_root_obj(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11308 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11309 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11310 | if (hdd_get_conparam() != QDF_GLOBAL_EPPING_MODE) { |
| 11311 | qdf_status = cds_post_disable(); |
| 11312 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11313 | hdd_err("Failed to process post CDS disable! :%d", |
| 11314 | qdf_status); |
| 11315 | ret = -EINVAL; |
| 11316 | QDF_ASSERT(0); |
| 11317 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11318 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11319 | /* De-register the SME callbacks */ |
| 11320 | hdd_deregister_cb(hdd_ctx); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 11321 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11322 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 11323 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11324 | qdf_status = cds_dp_close(hdd_ctx->psoc); |
| 11325 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11326 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 11327 | ret = -EINVAL; |
| 11328 | QDF_ASSERT(0); |
| 11329 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11330 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11331 | qdf_status = cds_close(hdd_ctx->psoc); |
| 11332 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11333 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
| 11334 | ret = -EINVAL; |
| 11335 | QDF_ASSERT(0); |
| 11336 | } |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11337 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11338 | qdf_status = wbuff_module_deinit(); |
| 11339 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 11340 | hdd_err("WBUFF de-init unsuccessful; status: %d", |
| 11341 | qdf_status); |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11342 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11343 | hdd_component_pdev_close(hdd_ctx->pdev); |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11344 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11345 | hdd_component_psoc_close(hdd_ctx->psoc); |
| 11346 | dispatcher_pdev_close(hdd_ctx->pdev); |
| 11347 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 11348 | if (ret) { |
| 11349 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 11350 | QDF_ASSERT(0); |
| 11351 | } |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11352 | } |
| 11353 | |
| 11354 | /* |
| 11355 | * Reset total mac phy during module stop such that during |
| 11356 | * next module start same psoc is used to populate new service |
| 11357 | * ready data |
| 11358 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11359 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11360 | if (tgt_hdl) |
| 11361 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 11362 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11363 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11364 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 11365 | if (!hif_ctx) { |
| 11366 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11367 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11368 | } |
| 11369 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 11370 | if (hdd_ctx->target_hw_name) { |
| 11371 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 11372 | hdd_ctx->target_hw_name = NULL; |
| 11373 | } |
| 11374 | |
Visweswara Tanuku | c949ad2 | 2019-03-20 13:00:30 +0530 | [diff] [blame] | 11375 | if (hdd_get_conparam() != QDF_GLOBAL_EPPING_MODE) { |
| 11376 | epping_disable(); |
| 11377 | epping_close(); |
| 11378 | } |
| 11379 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 11380 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11381 | |
| 11382 | ol_cds_free(); |
| 11383 | |
Dustin Brown | c2a156e | 2018-10-25 16:56:27 -0700 | [diff] [blame] | 11384 | if (IS_IDLE_STOP) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11385 | ret = pld_power_off(qdf_ctx->dev); |
| 11386 | if (ret) |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11387 | hdd_err("Failed to power down device; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11388 | } |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11389 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11390 | /* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */ |
| 11391 | wlan_hdd_free_cache_channels(hdd_ctx); |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11392 | |
Jingxiang Ge | 3de0275 | 2019-01-29 15:47:03 +0800 | [diff] [blame] | 11393 | hdd_sap_destroy_ctx_all(hdd_ctx, is_recovery_stop); |
| 11394 | |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 11395 | hdd_check_for_leaks(hdd_ctx, is_recovery_stop); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 11396 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11397 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11398 | /* Once the firmware sequence is completed reset this flag */ |
| 11399 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11400 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11401 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11402 | |
Kai Liu | eabb1df | 2018-11-08 14:58:54 +0800 | [diff] [blame] | 11403 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, PLD_BUS_WIDTH_NONE); |
| 11404 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11405 | done: |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11406 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11407 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11408 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11409 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11410 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11411 | } |
| 11412 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11413 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11414 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11415 | * hdd_state_info_dump() - prints state information of hdd layer |
| 11416 | * @buf: buffer pointer |
| 11417 | * @size: size of buffer to be filled |
| 11418 | * |
| 11419 | * This function is used to dump state information of hdd layer |
| 11420 | * |
| 11421 | * Return: None |
| 11422 | */ |
| 11423 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 11424 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11425 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 11426 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11427 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11428 | uint16_t len = 0; |
| 11429 | char *buf = *buf_ptr; |
| 11430 | |
| 11431 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11432 | if (!hdd_ctx) { |
| 11433 | hdd_err("Failed to get hdd context "); |
| 11434 | return; |
| 11435 | } |
| 11436 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11437 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11438 | |
| 11439 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 11440 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11441 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 11442 | "\n is_scheduler_suspended %d", |
| 11443 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11444 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11445 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11446 | if (adapter->dev) |
| 11447 | len += scnprintf(buf + len, *size - len, |
| 11448 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 11449 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11450 | "\n device_mode: %d", adapter->device_mode); |
| 11451 | switch (adapter->device_mode) { |
| 11452 | case QDF_STA_MODE: |
| 11453 | case QDF_P2P_CLIENT_MODE: |
| 11454 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11455 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 11456 | "\n conn_state: %d", |
| 11457 | hdd_sta_ctx->conn_info.conn_state); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11458 | break; |
| 11459 | |
| 11460 | default: |
| 11461 | break; |
| 11462 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11463 | } |
| 11464 | |
| 11465 | *size -= len; |
| 11466 | *buf_ptr += len; |
| 11467 | } |
| 11468 | |
| 11469 | /** |
| 11470 | * hdd_register_debug_callback() - registration function for hdd layer |
| 11471 | * to print hdd state information |
| 11472 | * |
| 11473 | * Return: None |
| 11474 | */ |
| 11475 | static void hdd_register_debug_callback(void) |
| 11476 | { |
| 11477 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 11478 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11479 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 11480 | static void hdd_register_debug_callback(void) |
| 11481 | { |
| 11482 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11483 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11484 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11485 | /* |
| 11486 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 11487 | * |
| 11488 | * This function is used to create bug report lock |
| 11489 | * |
| 11490 | * Return: None |
| 11491 | */ |
| 11492 | static void wlan_init_bug_report_lock(void) |
| 11493 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 11494 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11495 | |
| 11496 | p_cds_context = cds_get_global_context(); |
| 11497 | if (!p_cds_context) { |
| 11498 | hdd_err("cds context is NULL"); |
| 11499 | return; |
| 11500 | } |
| 11501 | |
| 11502 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 11503 | } |
| 11504 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11505 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11506 | void hdd_dp_trace_init(struct hdd_config *config) |
| 11507 | { |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11508 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 11509 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 11510 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 11511 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 11512 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 11513 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 11514 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11515 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11516 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11517 | if (!config->enable_dp_trace) { |
| 11518 | hdd_err("dp trace is disabled from ini"); |
| 11519 | return; |
| 11520 | } |
| 11521 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11522 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 11523 | &num_entries, sizeof(config_params)); |
| 11524 | |
| 11525 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11526 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11527 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11528 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11529 | else if (bw_compute_interval > 1000) { |
| 11530 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 11531 | thresh_time_limit = 1; |
| 11532 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11533 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 11534 | |
| 11535 | switch (num_entries) { |
| 11536 | case 4: |
| 11537 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11538 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11539 | case 3: |
| 11540 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11541 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11542 | case 2: |
| 11543 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11544 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11545 | case 1: |
| 11546 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11547 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11548 | default: |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 11549 | hdd_debug("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 11550 | live_mode, thresh, thresh_time_limit, |
| 11551 | verbosity, proto_bitmap); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11552 | }; |
| 11553 | |
| 11554 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 11555 | verbosity, proto_bitmap); |
| 11556 | |
| 11557 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11558 | #endif |
| 11559 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11560 | #ifdef DISABLE_CHANNEL_LIST |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11561 | 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] | 11562 | { |
| 11563 | return qdf_mutex_create(&hdd_ctx->cache_channel_lock); |
| 11564 | } |
| 11565 | #else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11566 | 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] | 11567 | { |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11568 | return QDF_STATUS_SUCCESS; |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11569 | } |
| 11570 | #endif |
| 11571 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11572 | static QDF_STATUS hdd_open_adapter_no_trans(struct hdd_context *hdd_ctx, |
| 11573 | enum QDF_OPMODE op_mode, |
| 11574 | const char *iface_name, |
| 11575 | uint8_t *mac_addr_bytes) |
| 11576 | { |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11577 | struct osif_vdev_sync *vdev_sync; |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11578 | struct hdd_adapter *adapter; |
| 11579 | QDF_STATUS status; |
| 11580 | int errno; |
| 11581 | |
| 11582 | QDF_BUG(rtnl_is_locked()); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11583 | |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11584 | errno = osif_vdev_sync_create(hdd_ctx->parent_dev, &vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11585 | if (errno) |
| 11586 | return qdf_status_from_os_return(errno); |
| 11587 | |
| 11588 | adapter = hdd_open_adapter(hdd_ctx, op_mode, iface_name, |
| 11589 | mac_addr_bytes, NET_NAME_UNKNOWN, true); |
| 11590 | if (!adapter) { |
| 11591 | status = QDF_STATUS_E_INVAL; |
| 11592 | goto destroy_sync; |
| 11593 | } |
| 11594 | |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11595 | osif_vdev_sync_register(adapter->dev, vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11596 | |
| 11597 | return QDF_STATUS_SUCCESS; |
| 11598 | |
| 11599 | destroy_sync: |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11600 | osif_vdev_sync_destroy(vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11601 | |
| 11602 | return status; |
| 11603 | } |
| 11604 | |
| 11605 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 11606 | /** |
| 11607 | * hdd_open_p2p_interface - Open P2P interface |
| 11608 | * @hdd_ctx: HDD context |
| 11609 | * |
| 11610 | * Return: QDF_STATUS |
| 11611 | */ |
| 11612 | static QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
| 11613 | { |
| 11614 | QDF_STATUS status; |
| 11615 | bool p2p_dev_addr_admin; |
| 11616 | bool is_p2p_locally_administered = false; |
| 11617 | |
| 11618 | cfg_p2p_get_device_addr_admin(hdd_ctx->psoc, &p2p_dev_addr_admin); |
| 11619 | |
| 11620 | if (p2p_dev_addr_admin) { |
| 11621 | if (hdd_ctx->num_provisioned_addr && |
| 11622 | !(hdd_ctx->provisioned_mac_addr[0].bytes[0] & 0x02)) { |
| 11623 | hdd_ctx->p2p_device_address = |
| 11624 | hdd_ctx->provisioned_mac_addr[0]; |
| 11625 | |
| 11626 | /* |
| 11627 | * Generate the P2P Device Address. This consists of |
| 11628 | * the device's primary MAC address with the locally |
| 11629 | * administered bit set. |
| 11630 | */ |
| 11631 | |
| 11632 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
| 11633 | is_p2p_locally_administered = true; |
| 11634 | } else if (!(hdd_ctx->derived_mac_addr[0].bytes[0] & 0x02)) { |
| 11635 | hdd_ctx->p2p_device_address = |
| 11636 | hdd_ctx->derived_mac_addr[0]; |
| 11637 | /* |
| 11638 | * Generate the P2P Device Address. This consists of |
| 11639 | * the device's primary MAC address with the locally |
| 11640 | * administered bit set. |
| 11641 | */ |
| 11642 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
| 11643 | is_p2p_locally_administered = true; |
| 11644 | } |
| 11645 | } |
| 11646 | if (!is_p2p_locally_administered) { |
| 11647 | uint8_t *p2p_dev_addr; |
| 11648 | |
| 11649 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx, |
| 11650 | QDF_P2P_DEVICE_MODE); |
| 11651 | if (!p2p_dev_addr) { |
| 11652 | hdd_err("Failed to get MAC address for new p2p device"); |
| 11653 | return QDF_STATUS_E_INVAL; |
| 11654 | } |
| 11655 | |
| 11656 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
| 11657 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
| 11658 | } |
| 11659 | |
| 11660 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_P2P_DEVICE_MODE, |
| 11661 | "p2p%d", |
| 11662 | hdd_ctx->p2p_device_address.bytes); |
| 11663 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11664 | hdd_err("Failed to open p2p interface"); |
| 11665 | return QDF_STATUS_E_INVAL; |
| 11666 | } |
| 11667 | |
| 11668 | return QDF_STATUS_SUCCESS; |
| 11669 | } |
| 11670 | #else |
| 11671 | static inline QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
| 11672 | { |
| 11673 | return QDF_STATUS_SUCCESS; |
| 11674 | } |
| 11675 | #endif |
| 11676 | |
| 11677 | static QDF_STATUS hdd_open_ocb_interface(struct hdd_context *hdd_ctx) |
| 11678 | { |
| 11679 | QDF_STATUS status; |
| 11680 | uint8_t *mac_addr; |
| 11681 | |
| 11682 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_OCB_MODE); |
| 11683 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_OCB_MODE, |
| 11684 | "wlanocb%d", mac_addr); |
| 11685 | if (QDF_IS_STATUS_ERROR(status)) |
| 11686 | hdd_err("Failed to open 802.11p interface"); |
| 11687 | |
| 11688 | return status; |
| 11689 | } |
| 11690 | |
| 11691 | static QDF_STATUS hdd_open_concurrent_interface(struct hdd_context *hdd_ctx) |
| 11692 | { |
| 11693 | QDF_STATUS status; |
| 11694 | const char *iface_name; |
| 11695 | uint8_t *mac_addr; |
| 11696 | |
| 11697 | if (qdf_str_eq(hdd_ctx->config->enable_concurrent_sta, "")) |
| 11698 | return QDF_STATUS_SUCCESS; |
| 11699 | |
| 11700 | iface_name = hdd_ctx->config->enable_concurrent_sta; |
| 11701 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_STA_MODE); |
| 11702 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_STA_MODE, |
| 11703 | iface_name, mac_addr); |
| 11704 | if (QDF_IS_STATUS_ERROR(status)) |
| 11705 | hdd_err("Failed to open concurrent station interface"); |
| 11706 | |
| 11707 | return status; |
| 11708 | } |
| 11709 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11710 | static QDF_STATUS |
| 11711 | hdd_open_adapters_for_mission_mode(struct hdd_context *hdd_ctx) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11712 | { |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11713 | enum dot11p_mode dot11p_mode; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11714 | QDF_STATUS status; |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11715 | uint8_t *mac_addr; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11716 | |
| 11717 | ucfg_mlme_get_dot11p_mode(hdd_ctx->psoc, &dot11p_mode); |
| 11718 | |
| 11719 | /* Create only 802.11p interface? */ |
| 11720 | if (dot11p_mode == CFG_11P_STANDALONE) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11721 | return hdd_open_ocb_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11722 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11723 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_STA_MODE); |
| 11724 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_STA_MODE, |
| 11725 | "wlan%d", mac_addr); |
| 11726 | if (QDF_IS_STATUS_ERROR(status)) |
| 11727 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11728 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11729 | /* opening concurrent STA is best effort, continue on error */ |
| 11730 | hdd_open_concurrent_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11731 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11732 | status = hdd_open_p2p_interface(hdd_ctx); |
| 11733 | if (status) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11734 | goto err_close_adapters; |
| 11735 | |
| 11736 | /* Open 802.11p Interface */ |
| 11737 | if (dot11p_mode == CFG_11P_CONCURRENT) { |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11738 | status = hdd_open_ocb_interface(hdd_ctx); |
| 11739 | if (QDF_IS_STATUS_ERROR(status)) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11740 | goto err_close_adapters; |
| 11741 | } |
| 11742 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11743 | return QDF_STATUS_SUCCESS; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11744 | |
| 11745 | err_close_adapters: |
| 11746 | hdd_close_all_adapters(hdd_ctx, true); |
| 11747 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11748 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11749 | } |
| 11750 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11751 | 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] | 11752 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11753 | 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] | 11754 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11755 | return hdd_open_adapter_no_trans(hdd_ctx, QDF_FTM_MODE, |
| 11756 | "wlan%d", mac_addr); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11757 | } |
| 11758 | |
| 11759 | static QDF_STATUS |
| 11760 | hdd_open_adapters_for_monitor_mode(struct hdd_context *hdd_ctx) |
| 11761 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11762 | 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] | 11763 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11764 | return hdd_open_adapter_no_trans(hdd_ctx, QDF_MONITOR_MODE, |
| 11765 | "wlan%d", mac_addr); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11766 | } |
| 11767 | |
| 11768 | static QDF_STATUS hdd_open_adapters_for_epping_mode(struct hdd_context *hdd_ctx) |
| 11769 | { |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11770 | epping_enable_adapter(); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11771 | return QDF_STATUS_SUCCESS; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11772 | } |
| 11773 | |
| 11774 | typedef QDF_STATUS (*hdd_open_mode_handler)(struct hdd_context *hdd_ctx); |
| 11775 | |
| 11776 | static const hdd_open_mode_handler |
| 11777 | hdd_open_mode_handlers[QDF_GLOBAL_MAX_MODE] = { |
| 11778 | [QDF_GLOBAL_MISSION_MODE] = hdd_open_adapters_for_mission_mode, |
| 11779 | [QDF_GLOBAL_FTM_MODE] = hdd_open_adapters_for_ftm_mode, |
| 11780 | [QDF_GLOBAL_MONITOR_MODE] = hdd_open_adapters_for_monitor_mode, |
| 11781 | [QDF_GLOBAL_EPPING_MODE] = hdd_open_adapters_for_epping_mode, |
| 11782 | }; |
| 11783 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11784 | static QDF_STATUS hdd_open_adapters_for_mode(struct hdd_context *hdd_ctx, |
| 11785 | enum QDF_GLOBAL_MODE driver_mode) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11786 | { |
| 11787 | QDF_STATUS status; |
| 11788 | |
| 11789 | if (driver_mode < 0 || |
| 11790 | driver_mode >= QDF_GLOBAL_MAX_MODE || |
| 11791 | !hdd_open_mode_handlers[driver_mode]) { |
| 11792 | hdd_err("Driver mode %d not supported", driver_mode); |
| 11793 | return -ENOTSUPP; |
| 11794 | } |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11795 | |
| 11796 | hdd_hold_rtnl_lock(); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11797 | status = hdd_open_mode_handlers[driver_mode](hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11798 | hdd_release_rtnl_lock(); |
| 11799 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11800 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11801 | } |
| 11802 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11803 | int hdd_wlan_startup(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11804 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11805 | QDF_STATUS status; |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11806 | int errno; |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 11807 | bool is_imps_enabled; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11808 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11809 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11810 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11811 | hdd_action_oui_config(hdd_ctx); |
| 11812 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11813 | qdf_nbuf_init_replenish_timer(); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11814 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11815 | status = wlan_hdd_cache_chann_mutex_create(hdd_ctx); |
| 11816 | if (QDF_IS_STATUS_ERROR(status)) |
| 11817 | return qdf_status_to_os_return(status); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11818 | |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 11819 | #ifdef FEATURE_WLAN_CH_AVOID |
| 11820 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 11821 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11822 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11823 | osif_request_manager_init(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11824 | hdd_driver_memdump_init(); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11825 | hdd_bus_bandwidth_init(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11826 | |
Arunk Khandavalli | 5ff037547 | 2019-01-11 17:26:47 +0530 | [diff] [blame] | 11827 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 11828 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
| 11829 | QDF_TIMER_TYPE_SW, |
| 11830 | hdd_skip_acs_scan_timer_handler, |
| 11831 | hdd_ctx); |
| 11832 | if (QDF_IS_STATUS_ERROR(status)) |
| 11833 | hdd_err("Failed to init ACS Skip timer"); |
| 11834 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
| 11835 | #endif |
| 11836 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11837 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 11838 | if (errno) { |
| 11839 | hdd_err("Failed to start modules; errno:%d", errno); |
| 11840 | goto memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11841 | } |
| 11842 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11843 | if (hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) |
| 11844 | return 0; |
| 11845 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 11846 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11847 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11848 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 11849 | if (!hdd_ctx->mac_handle) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11850 | hdd_err("Mac Handle is null"); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11851 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11852 | } |
| 11853 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11854 | errno = hdd_wiphy_init(hdd_ctx); |
| 11855 | if (errno) { |
| 11856 | hdd_err("Failed to initialize wiphy; errno:%d", errno); |
| 11857 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11858 | } |
| 11859 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11860 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 11861 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 11862 | errno = hdd_initialize_mac_address(hdd_ctx); |
| 11863 | if (errno) { |
| 11864 | hdd_err("MAC initializtion failed: %d", errno); |
| 11865 | goto unregister_wiphy; |
| 11866 | } |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 11867 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11868 | errno = register_netdevice_notifier(&hdd_netdev_notifier); |
| 11869 | if (errno) { |
| 11870 | hdd_err("register_netdevice_notifier failed; errno:%d", errno); |
| 11871 | goto unregister_wiphy; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11872 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 11873 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11874 | errno = register_reboot_notifier(&system_reboot_notifier); |
| 11875 | if (errno) { |
| 11876 | hdd_err("Failed to register reboot notifier; errno:%d", errno); |
| 11877 | goto unregister_netdev; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11878 | } |
| 11879 | |
Sandeep Puligilla | 3461878 | 2019-01-04 17:42:42 -0800 | [diff] [blame] | 11880 | wlan_hdd_update_11n_mode(hdd_ctx); |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 11881 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 11882 | hdd_lpass_notify_wlan_version(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11883 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11884 | errno = hdd_register_notifiers(hdd_ctx); |
| 11885 | if (errno) |
| 11886 | goto unregister_reboot; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 11887 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11888 | status = wlansap_global_init(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11889 | if (QDF_IS_STATUS_ERROR(status)) |
| 11890 | goto unregister_notifiers; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11891 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 11892 | ucfg_mlme_is_imps_enabled(hdd_ctx->psoc, &is_imps_enabled); |
| 11893 | hdd_set_idle_ps_config(hdd_ctx, is_imps_enabled); |
Arun Kumar Khandavalli | deda5a8 | 2019-03-11 15:32:19 +0530 | [diff] [blame^] | 11894 | hdd_debugfs_mws_coex_info_init(hdd_ctx); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11895 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11896 | hdd_exit(); |
| 11897 | |
| 11898 | return 0; |
| 11899 | |
| 11900 | unregister_notifiers: |
| 11901 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11902 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11903 | unregister_reboot: |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11904 | unregister_reboot_notifier(&system_reboot_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11905 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11906 | unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11907 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 11908 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11909 | unregister_wiphy: |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 11910 | qdf_dp_trace_deinit(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11911 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11912 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11913 | stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11914 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11915 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11916 | memdump_deinit: |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11917 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11918 | hdd_driver_memdump_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11919 | osif_request_manager_deinit(); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11920 | qdf_nbuf_deinit_replenish_timer(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 11921 | |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 11922 | if (cds_is_fw_down()) |
| 11923 | hdd_err("Not setting the complete event as fw is down"); |
| 11924 | else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11925 | hdd_start_complete(errno); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11926 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11927 | hdd_exit(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11928 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11929 | return errno; |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11930 | } |
| 11931 | |
| 11932 | QDF_STATUS hdd_psoc_create_vdevs(struct hdd_context *hdd_ctx) |
| 11933 | { |
| 11934 | enum QDF_GLOBAL_MODE driver_mode = hdd_get_conparam(); |
| 11935 | QDF_STATUS status; |
| 11936 | |
| 11937 | status = hdd_open_adapters_for_mode(hdd_ctx, driver_mode); |
| 11938 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11939 | hdd_err("Failed to create vdevs; status:%d", status); |
| 11940 | return status; |
| 11941 | } |
| 11942 | |
| 11943 | if (hdd_ctx->rps) |
| 11944 | hdd_set_rps_cpu_mask(hdd_ctx); |
| 11945 | |
| 11946 | if (driver_mode != QDF_GLOBAL_FTM_MODE) |
| 11947 | hdd_psoc_idle_timer_start(hdd_ctx); |
| 11948 | |
| 11949 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11950 | } |
| 11951 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11952 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11953 | * hdd_wlan_update_target_info() - update target type info |
| 11954 | * @hdd_ctx: HDD context |
| 11955 | * @context: hif context |
| 11956 | * |
| 11957 | * Update target info received from firmware in hdd context |
| 11958 | * Return:None |
| 11959 | */ |
| 11960 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11961 | 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] | 11962 | { |
| 11963 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 11964 | |
| 11965 | if (!tgt_info) { |
| 11966 | hdd_err("Target info is Null"); |
| 11967 | return; |
| 11968 | } |
| 11969 | |
| 11970 | hdd_ctx->target_type = tgt_info->target_type; |
| 11971 | } |
| 11972 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11973 | 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] | 11974 | { |
| 11975 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11976 | int status; |
| 11977 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11978 | struct osif_request *request = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11979 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11980 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11981 | |
| 11982 | if (!rsp) { |
| 11983 | hdd_err("data is null"); |
| 11984 | return; |
| 11985 | } |
| 11986 | |
| 11987 | status = wlan_hdd_validate_context(hdd_ctx); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11988 | if (status != 0) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11989 | return; |
| 11990 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11991 | request = osif_request_get(context); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11992 | if (!request) { |
| 11993 | hdd_err("obselete request"); |
| 11994 | return; |
| 11995 | } |
| 11996 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11997 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 11998 | if ((!adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11999 | hdd_err("Invalid adapter or adapter has invalid magic"); |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12000 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12001 | return; |
| 12002 | } |
| 12003 | |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 12004 | hdd_debug("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 12005 | hdd_debug("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 12006 | hdd_debug("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 12007 | hdd_debug("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 12008 | hdd_debug("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 12009 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 12010 | hdd_debug("rsp->dad_detected :%x", rsp->dad_detected); |
| 12011 | hdd_debug("rsp->connect_status :%x", rsp->connect_status); |
| 12012 | hdd_debug("rsp->ba_session_establishment_status :%x", |
| 12013 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12014 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12015 | 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] | 12016 | adapter->dad |= rsp->dad_detected; |
| 12017 | adapter->con_status = rsp->connect_status; |
| 12018 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12019 | /* Flag true indicates connectivity check stats present. */ |
| 12020 | if (rsp->connect_stats_present) { |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 12021 | hdd_debug("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 12022 | hdd_debug("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12023 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 12024 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 12025 | rsp->icmpv4_rsp_recvd; |
| 12026 | } |
| 12027 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12028 | osif_request_complete(request); |
| 12029 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12030 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12031 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12032 | } |
| 12033 | |
Visweswara Tanuku | 633976b | 2019-01-07 16:13:12 +0530 | [diff] [blame] | 12034 | #ifdef WLAN_FEATURE_MOTION_DETECTION |
| 12035 | /** |
| 12036 | * hdd_md_host_evt_cb - Callback for Motion Detection Event |
| 12037 | * @ctx: HDD context |
| 12038 | * @event: motion detect event |
| 12039 | * |
| 12040 | * Callback for Motion Detection Event. Re-enables Motion |
| 12041 | * Detection again upon event |
| 12042 | * |
| 12043 | * Return: QDF_STATUS QDF_STATUS_SUCCESS on Success and |
| 12044 | * QDF_STATUS_E_FAILURE on failure |
| 12045 | */ |
| 12046 | QDF_STATUS hdd_md_host_evt_cb(void *ctx, struct sir_md_evt *event) |
| 12047 | { |
| 12048 | struct hdd_adapter *adapter = NULL; |
| 12049 | struct hdd_context *hdd_ctx; |
| 12050 | QDF_STATUS status; |
| 12051 | struct sme_motion_det_en motion_det; |
| 12052 | |
| 12053 | if (!ctx || !event) |
| 12054 | return QDF_STATUS_E_INVAL; |
| 12055 | |
| 12056 | hdd_ctx = (struct hdd_context *)ctx; |
| 12057 | status = wlan_hdd_validate_context(hdd_ctx); |
| 12058 | if (0 != status) |
| 12059 | return QDF_STATUS_E_INVAL; |
| 12060 | |
| 12061 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, event->vdev_id); |
| 12062 | if (!adapter || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 12063 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 12064 | return QDF_STATUS_E_INVAL; |
| 12065 | } |
| 12066 | |
| 12067 | hdd_debug("Motion Detection CB vdev_id=%u, status=%u", |
| 12068 | event->vdev_id, event->status); |
| 12069 | |
| 12070 | if (adapter->motion_detection_mode) { |
| 12071 | motion_det.vdev_id = event->vdev_id; |
| 12072 | motion_det.enable = 1; |
| 12073 | hdd_debug("Motion Detect CB -> Enable Motion Detection again"); |
| 12074 | sme_motion_det_enable(hdd_ctx->mac_handle, &motion_det); |
| 12075 | } |
| 12076 | |
| 12077 | return QDF_STATUS_SUCCESS; |
| 12078 | } |
| 12079 | #endif /* WLAN_FEATURE_MOTION_DETECTION */ |
| 12080 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12081 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12082 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12083 | * @hdd_ctx: HDD context |
| 12084 | * |
| 12085 | * Register the HDD callbacks to CDS/SME. |
| 12086 | * |
| 12087 | * Return: 0 for success or Error code for failure |
| 12088 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12089 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12090 | { |
| 12091 | QDF_STATUS status; |
| 12092 | int ret = 0; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12093 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12094 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12095 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12096 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12097 | hdd_err("in ftm mode, no need to register callbacks"); |
| 12098 | return ret; |
| 12099 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12100 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12101 | mac_handle = hdd_ctx->mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12102 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12103 | sme_register_oem_data_rsp_callback(mac_handle, |
| 12104 | hdd_send_oem_data_rsp_msg); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12105 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12106 | sme_register_mgmt_frame_ind_callback(mac_handle, |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 12107 | hdd_indicate_mgmt_frame); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12108 | sme_set_tsfcb(mac_handle, hdd_get_tsf_cb, hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12109 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12110 | wlan_hdd_cfg80211_stats_ext_callback); |
| 12111 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12112 | sme_ext_scan_register_callback(mac_handle, |
| 12113 | wlan_hdd_cfg80211_extscan_callback); |
| 12114 | sme_stats_ext2_register_callback(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 12115 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12116 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12117 | sme_set_rssi_threshold_breached_cb(mac_handle, |
| 12118 | hdd_rssi_threshold_breached); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12119 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12120 | sme_set_link_layer_stats_ind_cb(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12121 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 12122 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12123 | 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] | 12124 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12125 | sme_set_link_layer_ext_cb(mac_handle, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 12126 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
Abhinav Kumar | 338e57d | 2019-02-04 17:30:10 +0530 | [diff] [blame] | 12127 | sme_update_hidden_ssid_status_cb(mac_handle, |
| 12128 | hdd_hidden_ssid_enable_roaming); |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 12129 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12130 | status = sme_set_lost_link_info_cb(mac_handle, |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 12131 | hdd_lost_link_info_cb); |
| 12132 | /* print error and not block the startup process */ |
| 12133 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12134 | hdd_err("set lost link info callback failed"); |
| 12135 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12136 | ret = hdd_register_data_stall_detect_cb(); |
| 12137 | if (ret) { |
| 12138 | hdd_err("Register data stall detect detect callback failed."); |
| 12139 | return ret; |
| 12140 | } |
| 12141 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12142 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 12143 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12144 | sme_register_set_connection_info_cb(mac_handle, |
| 12145 | hdd_set_connection_in_progress, |
| 12146 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12147 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12148 | status = sme_congestion_register_callback(mac_handle, |
| 12149 | hdd_update_cca_info_cb); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12150 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12151 | hdd_err("set congestion callback failed"); |
| 12152 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12153 | status = sme_set_bt_activity_info_cb(mac_handle, |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 12154 | hdd_bt_activity_cb); |
| 12155 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12156 | hdd_err("set bt activity info callback failed"); |
| 12157 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12158 | status = sme_register_tx_queue_cb(mac_handle, |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 12159 | hdd_tx_queue_cb); |
| 12160 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12161 | hdd_err("Register tx queue callback failed"); |
| 12162 | |
Visweswara Tanuku | 633976b | 2019-01-07 16:13:12 +0530 | [diff] [blame] | 12163 | #ifdef WLAN_FEATURE_MOTION_DETECTION |
| 12164 | sme_set_md_host_evt_cb(mac_handle, hdd_md_host_evt_cb, (void *)hdd_ctx); |
| 12165 | #endif /* WLAN_FEATURE_MOTION_DETECTION */ |
| 12166 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12167 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12168 | |
| 12169 | return ret; |
| 12170 | } |
| 12171 | |
| 12172 | /** |
| 12173 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 12174 | * @hdd_ctx: HDD context |
| 12175 | * |
| 12176 | * De-Register the HDD callbacks to CDS/SME. |
| 12177 | * |
| 12178 | * Return: void |
| 12179 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12180 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12181 | { |
| 12182 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12183 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12184 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12185 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12186 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12187 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12188 | hdd_err("in ftm mode, no need to deregister callbacks"); |
| 12189 | return; |
| 12190 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12191 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12192 | mac_handle = hdd_ctx->mac_handle; |
| 12193 | sme_deregister_tx_queue_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12194 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12195 | sme_reset_link_layer_stats_ind_cb(mac_handle); |
| 12196 | sme_reset_rssi_threshold_breached_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12197 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12198 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12199 | wlan_hdd_cfg80211_stats_ext_callback); |
| 12200 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12201 | status = sme_reset_tsfcb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12202 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12203 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 12204 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12205 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12206 | ret = hdd_deregister_data_stall_detect_cb(); |
| 12207 | if (ret) |
| 12208 | hdd_err("Failed to de-register data stall detect event callback"); |
| 12209 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12210 | sme_deregister_oem_data_rsp_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12211 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12212 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12213 | } |
| 12214 | |
| 12215 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12216 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12217 | * @adapter: Pointer to the HDD adapter |
| 12218 | * @param: Params to the operation |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12219 | * |
| 12220 | * This to take counter measure to handle deauth req from HDD |
| 12221 | * |
| 12222 | * Return: None |
| 12223 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12224 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12225 | struct csr_del_sta_params *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12226 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12227 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12228 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12229 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12230 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12231 | /* Ignore request to deauth bcmc station */ |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12232 | if (param->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12233 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12234 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12235 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12236 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12237 | param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12238 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12239 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12240 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12241 | } |
| 12242 | |
| 12243 | /** |
| 12244 | * 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] | 12245 | * @adapter: Pointer to the HDD |
| 12246 | * @param: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12247 | * |
| 12248 | * This to take counter measure to handle deauth req from HDD |
| 12249 | * |
| 12250 | * Return: None |
| 12251 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12252 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12253 | struct csr_del_sta_params *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12254 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12255 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12256 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12257 | /* Ignore request to disassoc bcmc station */ |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12258 | if (param->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12259 | return; |
| 12260 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12261 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12262 | param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12263 | } |
| 12264 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12265 | void wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12266 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12267 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12268 | struct hdd_adapter *adapter = NULL; |
| 12269 | struct csr_roam_profile *roam_profile; |
| 12270 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12271 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12272 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12273 | hdd_debug("No active sta session"); |
| 12274 | return; |
| 12275 | } |
| 12276 | |
| 12277 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12278 | roam_profile = hdd_roam_profile(adapter); |
| 12279 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12280 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12281 | if (cur_adapter->vdev_id != adapter->vdev_id && |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12282 | adapter->device_mode == QDF_STA_MODE && |
| 12283 | hdd_conn_is_connected(sta_ctx)) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12284 | hdd_debug("%d Disable roaming", adapter->vdev_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12285 | sme_stop_roaming(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12286 | adapter->vdev_id, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12287 | ecsr_driver_disabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12288 | } |
| 12289 | } |
| 12290 | } |
| 12291 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12292 | void wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12293 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12294 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12295 | struct hdd_adapter *adapter = NULL; |
| 12296 | struct csr_roam_profile *roam_profile; |
| 12297 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12298 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12299 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12300 | hdd_debug("No active sta session"); |
| 12301 | return; |
| 12302 | } |
| 12303 | |
| 12304 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12305 | roam_profile = hdd_roam_profile(adapter); |
| 12306 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12307 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12308 | if (cur_adapter->vdev_id != adapter->vdev_id && |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12309 | adapter->device_mode == QDF_STA_MODE && |
| 12310 | hdd_conn_is_connected(sta_ctx)) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12311 | hdd_debug("%d Enable roaming", adapter->vdev_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12312 | sme_start_roaming(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12313 | adapter->vdev_id, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12314 | REASON_DRIVER_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12315 | } |
| 12316 | } |
| 12317 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12318 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12319 | /** |
| 12320 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 12321 | * @skb: sk buffer pointer |
| 12322 | * |
| 12323 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 12324 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 12325 | * |
| 12326 | * Return: None |
| 12327 | */ |
| 12328 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 12329 | { |
| 12330 | #ifdef CNSS_GENL |
| 12331 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 12332 | #else |
| 12333 | nl_srv_bcast(skb); |
| 12334 | #endif |
| 12335 | } |
| 12336 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12337 | 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] | 12338 | { |
| 12339 | struct sk_buff *skb; |
| 12340 | struct nlmsghdr *nlh; |
| 12341 | tAniMsgHdr *ani_hdr; |
| 12342 | void *nl_data = NULL; |
| 12343 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12344 | struct radio_index_tlv *radio_info; |
| 12345 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12346 | |
| 12347 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 12348 | flags = GFP_ATOMIC; |
| 12349 | |
| 12350 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 12351 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12352 | if (!skb) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12353 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12354 | |
| 12355 | nlh = (struct nlmsghdr *)skb->data; |
| 12356 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 12357 | nlh->nlmsg_flags = 0; |
| 12358 | nlh->nlmsg_seq = 0; |
| 12359 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 12360 | |
| 12361 | ani_hdr = NLMSG_DATA(nlh); |
| 12362 | ani_hdr->type = type; |
| 12363 | |
| 12364 | switch (type) { |
| 12365 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 12366 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12367 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12368 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12369 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12370 | ani_hdr->length = 0; |
| 12371 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12372 | break; |
| 12373 | case WLAN_SVC_WLAN_STATUS_IND: |
| 12374 | case WLAN_SVC_WLAN_VERSION_IND: |
| 12375 | case WLAN_SVC_DFS_CAC_START_IND: |
| 12376 | case WLAN_SVC_DFS_CAC_END_IND: |
| 12377 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 12378 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 12379 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 12380 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 12381 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 12382 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12383 | ani_hdr->length = len; |
| 12384 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 12385 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 12386 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12387 | break; |
| 12388 | |
| 12389 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 12390 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12391 | type); |
| 12392 | kfree_skb(skb); |
| 12393 | return; |
| 12394 | } |
| 12395 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12396 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 12397 | * Add radio index at the end of the svc event in TLV format |
| 12398 | * to maintain the backward compatibility with userspace |
| 12399 | * applications. |
| 12400 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12401 | |
| 12402 | tlv_len = 0; |
| 12403 | |
| 12404 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 12405 | < WLAN_NL_MAX_PAYLOAD) { |
| 12406 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 12407 | sizeof(*ani_hdr) + len); |
| 12408 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 12409 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 12410 | radio_info->radio = radio; |
| 12411 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12412 | hdd_debug("Added radio index tlv - radio index %d", |
| 12413 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12414 | } |
| 12415 | |
| 12416 | nlh->nlmsg_len += tlv_len; |
| 12417 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 12418 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12419 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12420 | } |
| 12421 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12422 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 12423 | void wlan_hdd_auto_shutdown_cb(void) |
| 12424 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12425 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12426 | |
| 12427 | if (!hdd_ctx) |
| 12428 | return; |
| 12429 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12430 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12431 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 12432 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12433 | } |
| 12434 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12435 | 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] | 12436 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12437 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12438 | bool ap_connected = false, sta_connected = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12439 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12440 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12441 | mac_handle = hdd_ctx->mac_handle; |
| 12442 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12443 | return; |
| 12444 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12445 | if (hdd_ctx->config->wlan_auto_shutdown == 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12446 | return; |
| 12447 | |
| 12448 | if (enable == false) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12449 | if (sme_set_auto_shutdown_timer(mac_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12450 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12451 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12452 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12453 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12454 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12455 | return; |
| 12456 | } |
| 12457 | |
| 12458 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12459 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->psoc)) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12460 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12461 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12462 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 12463 | conn_info.conn_state == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12464 | eConnectionState_Associated) { |
| 12465 | sta_connected = true; |
| 12466 | break; |
| 12467 | } |
| 12468 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12469 | |
| 12470 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12471 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12472 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12473 | ap_connected = true; |
| 12474 | break; |
| 12475 | } |
| 12476 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12477 | } |
| 12478 | } |
| 12479 | |
| 12480 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12481 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12482 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12483 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12484 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12485 | if (sme_set_auto_shutdown_timer(mac_handle, |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12486 | hdd_ctx->config->wlan_auto_shutdown) |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12487 | != QDF_STATUS_SUCCESS) |
| 12488 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 12489 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 12490 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12491 | hdd_ctx->config->wlan_auto_shutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12492 | } |
| 12493 | #endif |
| 12494 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12495 | struct hdd_adapter * |
| 12496 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 12497 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12498 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12499 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12500 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12501 | |
| 12502 | con_sap_adapter = NULL; |
| 12503 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12504 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12505 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 12506 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12507 | adapter != this_sap_adapter) { |
| 12508 | if (check_start_bss) { |
| 12509 | if (test_bit(SOFTAP_BSS_STARTED, |
| 12510 | &adapter->event_flags)) { |
| 12511 | con_sap_adapter = adapter; |
| 12512 | break; |
| 12513 | } |
| 12514 | } else { |
| 12515 | con_sap_adapter = adapter; |
| 12516 | break; |
| 12517 | } |
| 12518 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12519 | } |
| 12520 | |
| 12521 | return con_sap_adapter; |
| 12522 | } |
| 12523 | |
| 12524 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12525 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12526 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12527 | return adapter->device_mode == QDF_STA_MODE || |
| 12528 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12529 | } |
| 12530 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12531 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12532 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12533 | return adapter->device_mode == QDF_SAP_MODE || |
| 12534 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 12535 | } |
| 12536 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12537 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12538 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12539 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12540 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12541 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12542 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12543 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 12544 | conn_info.conn_state == eConnectionState_Associated) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12545 | return true; |
| 12546 | } |
| 12547 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12548 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12549 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12550 | return true; |
| 12551 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12552 | } |
| 12553 | |
| 12554 | return false; |
| 12555 | } |
| 12556 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12557 | 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] | 12558 | { |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 12559 | qdf_periodic_work_start(&hdd_ctx->bus_bw_work, |
| 12560 | hdd_ctx->config->bus_bw_compute_interval); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12561 | } |
| 12562 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12563 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12564 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12565 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12566 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12567 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12568 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12569 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12570 | } |
| 12571 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12572 | 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] | 12573 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12574 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12575 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12576 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12577 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12578 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12579 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12580 | } |
| 12581 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12582 | 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] | 12583 | { |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 12584 | if (!qdf_periodic_work_stop_sync(&hdd_ctx->bus_bw_work)) |
| 12585 | return; |
| 12586 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12587 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12588 | hdd_reset_tcp_delack(hdd_ctx); |
| 12589 | } |
| 12590 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12591 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12592 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12593 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12594 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12595 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12596 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12597 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12598 | } |
| 12599 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12600 | 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] | 12601 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12602 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12603 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12604 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12605 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12606 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12607 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12608 | } |
| 12609 | #endif |
| 12610 | |
| 12611 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12612 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 12613 | * @ap_adapter: SAP adapter |
| 12614 | * |
| 12615 | * This function will process the stopping of sap adapter. |
| 12616 | * |
| 12617 | * Return: None |
| 12618 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12619 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12620 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12621 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12622 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12623 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12624 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12625 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12626 | if (!ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12627 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12628 | return; |
| 12629 | } |
| 12630 | |
| 12631 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12632 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12633 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12634 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12635 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12636 | mutex_lock(&hdd_ctx->sap_lock); |
| 12637 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 12638 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12639 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12640 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12641 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12642 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12643 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12644 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 12645 | qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 12646 | SME_CMD_STOP_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12647 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12648 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12649 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12650 | return; |
| 12651 | } |
| 12652 | } |
| 12653 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12654 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12655 | ap_adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12656 | ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12657 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12658 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12659 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12660 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12661 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12662 | } |
| 12663 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12664 | } |
| 12665 | |
| 12666 | /** |
| 12667 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 12668 | * @ap_adapter: SAP adapter |
| 12669 | * |
| 12670 | * This function will process the starting of sap adapter. |
| 12671 | * |
| 12672 | * Return: None |
| 12673 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12674 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12675 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12676 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12677 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12678 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12679 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 8f8ceb9 | 2019-03-24 08:16:55 -0700 | [diff] [blame] | 12680 | struct sap_config *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12681 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12682 | if (!ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12683 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12684 | return; |
| 12685 | } |
| 12686 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12687 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 12688 | hdd_err("SoftAp role has not been enabled"); |
| 12689 | return; |
| 12690 | } |
| 12691 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12692 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 12693 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12694 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 12695 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12696 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12697 | mutex_lock(&hdd_ctx->sap_lock); |
| 12698 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 12699 | goto end; |
| 12700 | |
| 12701 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12702 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12703 | goto end; |
| 12704 | } |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12705 | wlan_reg_set_channel_params(hdd_ctx->pdev, |
Abhinav Kumar | 6f69448 | 2018-09-04 16:07:39 +0530 | [diff] [blame] | 12706 | hdd_ap_ctx->sap_config.channel, 0, |
| 12707 | &hdd_ap_ctx->sap_config.ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12708 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 12709 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12710 | 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] | 12711 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12712 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12713 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12714 | goto end; |
| 12715 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12716 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12717 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 12718 | SME_CMD_START_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12719 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12720 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12721 | goto end; |
| 12722 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12723 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12724 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12725 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12726 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12727 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12728 | ap_adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12729 | ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12730 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12731 | true); |
| 12732 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 12733 | mutex_unlock(&hdd_ctx->sap_lock); |
| 12734 | |
| 12735 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12736 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12737 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12738 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 12739 | /* SAP context and beacon cleanup will happen during driver unload |
| 12740 | * in hdd_stop_adapter |
| 12741 | */ |
| 12742 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 12743 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12744 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12745 | |
| 12746 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12747 | * hdd_get_fw_version() - Get FW version |
| 12748 | * @hdd_ctx: pointer to HDD context. |
| 12749 | * @major_spid: FW version - major spid. |
| 12750 | * @minor_spid: FW version - minor spid |
| 12751 | * @ssid: FW version - ssid |
| 12752 | * @crmid: FW version - crmid |
| 12753 | * |
| 12754 | * This function is called to get the firmware build version stored |
| 12755 | * as part of the HDD context |
| 12756 | * |
| 12757 | * Return: None |
| 12758 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12759 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12760 | uint32_t *major_spid, uint32_t *minor_spid, |
| 12761 | uint32_t *siid, uint32_t *crmid) |
| 12762 | { |
| 12763 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 12764 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 12765 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 12766 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 12767 | } |
| 12768 | |
| 12769 | #ifdef QCA_CONFIG_SMP |
| 12770 | /** |
| 12771 | * wlan_hdd_get_cpu() - get cpu_index |
| 12772 | * |
| 12773 | * Return: cpu_index |
| 12774 | */ |
| 12775 | int wlan_hdd_get_cpu(void) |
| 12776 | { |
| 12777 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12778 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12779 | put_cpu(); |
| 12780 | return cpu_index; |
| 12781 | } |
| 12782 | #endif |
| 12783 | |
| 12784 | /** |
| 12785 | * hdd_get_fwpath() - get framework path |
| 12786 | * |
| 12787 | * This function is used to get the string written by |
| 12788 | * userspace to start the wlan driver |
| 12789 | * |
| 12790 | * Return: string |
| 12791 | */ |
| 12792 | const char *hdd_get_fwpath(void) |
| 12793 | { |
| 12794 | return fwpath.string; |
| 12795 | } |
| 12796 | |
Dustin Brown | 94ce20f | 2018-09-04 13:11:38 -0700 | [diff] [blame] | 12797 | static inline int hdd_state_query_cb(void) |
| 12798 | { |
| 12799 | return !!wlan_hdd_validate_context(cds_get_context(QDF_MODULE_ID_HDD)); |
| 12800 | } |
| 12801 | |
Dustin Brown | 265e82b | 2019-03-18 11:07:32 -0700 | [diff] [blame] | 12802 | static int __hdd_op_protect_cb(void **out_sync, const char *func) |
| 12803 | { |
| 12804 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12805 | |
| 12806 | if (!hdd_ctx) |
| 12807 | return -EAGAIN; |
| 12808 | |
| 12809 | return __osif_psoc_sync_op_start(hdd_ctx->parent_dev, |
| 12810 | (struct osif_psoc_sync **)out_sync, |
| 12811 | func); |
| 12812 | } |
| 12813 | |
| 12814 | static void __hdd_op_unprotect_cb(void *sync, const char *func) |
| 12815 | { |
| 12816 | __osif_psoc_sync_op_stop(sync, func); |
| 12817 | } |
| 12818 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12819 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12820 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12821 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12822 | * This function initilizes CDS global context with the help of cds_init. This |
| 12823 | * has to be the first function called after probe to get a valid global |
| 12824 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12825 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12826 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12827 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12828 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12829 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12830 | QDF_STATUS status; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12831 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12832 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12833 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12834 | hdd_err("Failed to allocate CDS context"); |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 12835 | return -ENOMEM; |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12836 | } |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 12837 | |
Dustin Brown | 265e82b | 2019-03-18 11:07:32 -0700 | [diff] [blame] | 12838 | 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] | 12839 | |
| 12840 | wlan_init_bug_report_lock(); |
| 12841 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12842 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12843 | wlan_logging_sock_init_svc(); |
| 12844 | #endif |
| 12845 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12846 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 12847 | hdd_register_debug_callback(); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12848 | wlan_roam_debug_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12849 | |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 12850 | return 0; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12851 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12852 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12853 | /** |
| 12854 | * hdd_deinit() - Deinitialize Driver |
| 12855 | * |
| 12856 | * This function frees CDS global context with the help of cds_deinit. This |
| 12857 | * has to be the last function call in remove callback to free the global |
| 12858 | * context. |
| 12859 | */ |
| 12860 | void hdd_deinit(void) |
| 12861 | { |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12862 | wlan_roam_debug_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12863 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12864 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12865 | wlan_logging_sock_deinit_svc(); |
| 12866 | #endif |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12867 | |
| 12868 | wlan_destroy_bug_report_lock(); |
Dustin Brown | 265e82b | 2019-03-18 11:07:32 -0700 | [diff] [blame] | 12869 | qdf_op_callbacks_register(NULL, NULL); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12870 | cds_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12871 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12872 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12873 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 12874 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 12875 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12876 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12877 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12878 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12879 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 12880 | struct file *file) |
| 12881 | { |
| 12882 | return 0; |
| 12883 | } |
| 12884 | |
| 12885 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 12886 | const char __user *user_buf, |
| 12887 | size_t count, |
| 12888 | loff_t *f_pos) |
| 12889 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12890 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12891 | static const char wlan_off_str[] = "OFF"; |
| 12892 | static const char wlan_on_str[] = "ON"; |
| 12893 | int ret; |
| 12894 | unsigned long rc; |
| 12895 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12896 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12897 | pr_err("Failed to read buffer\n"); |
| 12898 | return -EINVAL; |
| 12899 | } |
| 12900 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12901 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12902 | pr_debug("Wifi turning off from UI\n"); |
| 12903 | goto exit; |
| 12904 | } |
| 12905 | |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 12906 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12907 | pr_info("Wifi Turning On from UI\n"); |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12908 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12909 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12910 | pr_err("Invalid value received from framework"); |
| 12911 | goto exit; |
| 12912 | } |
| 12913 | |
| 12914 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 12915 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12916 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 12917 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 12918 | if (!rc) { |
Srinivas Girigowda | 09625b0 | 2018-09-10 15:28:09 -0700 | [diff] [blame] | 12919 | hdd_alert("Timed-out!!"); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12920 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12921 | return ret; |
| 12922 | } |
| 12923 | |
| 12924 | hdd_start_complete(0); |
| 12925 | } |
| 12926 | |
| 12927 | exit: |
| 12928 | return count; |
| 12929 | } |
| 12930 | |
| 12931 | |
| 12932 | const struct file_operations wlan_hdd_state_fops = { |
| 12933 | .owner = THIS_MODULE, |
| 12934 | .open = wlan_hdd_state_ctrl_param_open, |
| 12935 | .write = wlan_hdd_state_ctrl_param_write, |
| 12936 | }; |
| 12937 | |
| 12938 | static int wlan_hdd_state_ctrl_param_create(void) |
| 12939 | { |
| 12940 | unsigned int wlan_hdd_state_major = 0; |
| 12941 | int ret; |
| 12942 | struct device *dev; |
| 12943 | |
| 12944 | device = MKDEV(wlan_hdd_state_major, 0); |
| 12945 | |
| 12946 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 12947 | if (ret) { |
| 12948 | pr_err("Failed to register qcwlanstate"); |
| 12949 | goto dev_alloc_err; |
| 12950 | } |
| 12951 | wlan_hdd_state_major = MAJOR(device); |
| 12952 | |
| 12953 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 12954 | if (IS_ERR(class)) { |
| 12955 | pr_err("wlan_hdd_state class_create error"); |
| 12956 | goto class_err; |
| 12957 | } |
| 12958 | |
| 12959 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 12960 | if (IS_ERR(dev)) { |
| 12961 | pr_err("wlan_hdd_statedevice_create error"); |
| 12962 | goto err_class_destroy; |
| 12963 | } |
| 12964 | |
| 12965 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 12966 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 12967 | if (ret) { |
| 12968 | pr_err("Failed to add cdev error"); |
| 12969 | goto cdev_add_err; |
| 12970 | } |
| 12971 | |
| 12972 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 12973 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 12974 | |
| 12975 | return 0; |
| 12976 | |
| 12977 | cdev_add_err: |
| 12978 | device_destroy(class, device); |
| 12979 | err_class_destroy: |
| 12980 | class_destroy(class); |
| 12981 | class_err: |
| 12982 | unregister_chrdev_region(device, dev_num); |
| 12983 | dev_alloc_err: |
| 12984 | return -ENODEV; |
| 12985 | } |
| 12986 | |
| 12987 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 12988 | { |
| 12989 | cdev_del(&wlan_hdd_state_cdev); |
| 12990 | device_destroy(class, device); |
| 12991 | class_destroy(class); |
| 12992 | unregister_chrdev_region(device, dev_num); |
| 12993 | |
| 12994 | pr_info("Device node unregistered"); |
| 12995 | } |
| 12996 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12997 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12998 | * hdd_component_init() - Initialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12999 | * |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13000 | * Return: QDF_STATUS |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13001 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13002 | static QDF_STATUS hdd_component_init(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13003 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13004 | QDF_STATUS status; |
| 13005 | |
| 13006 | /* initialize converged components */ |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13007 | status = target_if_init(wma_get_psoc_from_scn_handle); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13008 | if (QDF_IS_STATUS_ERROR(status)) |
| 13009 | return status; |
| 13010 | |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13011 | status = ucfg_mlme_global_init(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13012 | if (QDF_IS_STATUS_ERROR(status)) |
| 13013 | goto target_if_deinit; |
| 13014 | |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13015 | status = dispatcher_init(); |
| 13016 | if (QDF_IS_STATUS_ERROR(status)) |
| 13017 | goto mlme_global_deinit; |
| 13018 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13019 | /* initialize non-converged components */ |
| 13020 | status = ucfg_mlme_init(); |
| 13021 | if (QDF_IS_STATUS_ERROR(status)) |
| 13022 | goto dispatcher_deinit; |
| 13023 | |
| 13024 | status = ucfg_fwol_init(); |
| 13025 | if (QDF_IS_STATUS_ERROR(status)) |
| 13026 | goto mlme_deinit; |
| 13027 | |
| 13028 | status = disa_init(); |
| 13029 | if (QDF_IS_STATUS_ERROR(status)) |
| 13030 | goto fwol_deinit; |
| 13031 | |
| 13032 | status = pmo_init(); |
| 13033 | if (QDF_IS_STATUS_ERROR(status)) |
| 13034 | goto disa_deinit; |
| 13035 | |
| 13036 | status = ucfg_ocb_init(); |
| 13037 | if (QDF_IS_STATUS_ERROR(status)) |
| 13038 | goto pmo_deinit; |
| 13039 | |
| 13040 | status = ipa_init(); |
| 13041 | if (QDF_IS_STATUS_ERROR(status)) |
| 13042 | goto ocb_deinit; |
| 13043 | |
| 13044 | status = ucfg_action_oui_init(); |
| 13045 | if (QDF_IS_STATUS_ERROR(status)) |
| 13046 | goto ipa_deinit; |
| 13047 | |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13048 | status = nan_init(); |
| 13049 | if (QDF_IS_STATUS_ERROR(status)) |
| 13050 | goto action_oui_deinit; |
| 13051 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13052 | status = ucfg_p2p_init(); |
| 13053 | if (QDF_IS_STATUS_ERROR(status)) |
| 13054 | goto nan_deinit; |
| 13055 | |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13056 | status = policy_mgr_init(); |
| 13057 | if (QDF_IS_STATUS_ERROR(status)) |
| 13058 | goto p2p_deinit; |
| 13059 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13060 | status = ucfg_tdls_init(); |
| 13061 | if (QDF_IS_STATUS_ERROR(status)) |
| 13062 | goto policy_deinit; |
| 13063 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13064 | return QDF_STATUS_SUCCESS; |
| 13065 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13066 | policy_deinit: |
| 13067 | policy_mgr_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13068 | p2p_deinit: |
| 13069 | ucfg_p2p_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13070 | nan_deinit: |
| 13071 | nan_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13072 | action_oui_deinit: |
| 13073 | ucfg_action_oui_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13074 | ipa_deinit: |
| 13075 | ipa_deinit(); |
| 13076 | ocb_deinit: |
| 13077 | ucfg_ocb_deinit(); |
| 13078 | pmo_deinit: |
| 13079 | pmo_deinit(); |
| 13080 | disa_deinit: |
| 13081 | disa_deinit(); |
| 13082 | fwol_deinit: |
| 13083 | ucfg_fwol_deinit(); |
| 13084 | mlme_deinit: |
| 13085 | ucfg_mlme_deinit(); |
| 13086 | dispatcher_deinit: |
| 13087 | dispatcher_deinit(); |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13088 | mlme_global_deinit: |
| 13089 | ucfg_mlme_global_deinit(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13090 | target_if_deinit: |
| 13091 | target_if_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13092 | |
| 13093 | return status; |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13094 | } |
| 13095 | |
| 13096 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13097 | * hdd_component_deinit() - Deinitialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13098 | * |
| 13099 | * Return: None |
| 13100 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13101 | static void hdd_component_deinit(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13102 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13103 | /* deinitialize non-converged components */ |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13104 | ucfg_tdls_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13105 | policy_mgr_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13106 | ucfg_p2p_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13107 | nan_deinit(); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 13108 | ucfg_action_oui_deinit(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 13109 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13110 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13111 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13112 | disa_deinit(); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13113 | ucfg_fwol_deinit(); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13114 | ucfg_mlme_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13115 | |
| 13116 | /* deinitialize converged components */ |
| 13117 | dispatcher_deinit(); |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13118 | ucfg_mlme_global_deinit(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13119 | target_if_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13120 | } |
| 13121 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13122 | QDF_STATUS hdd_component_psoc_open(struct wlan_objmgr_psoc *psoc) |
| 13123 | { |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13124 | QDF_STATUS status; |
| 13125 | |
| 13126 | status = ucfg_mlme_psoc_open(psoc); |
| 13127 | if (QDF_IS_STATUS_ERROR(status)) |
| 13128 | return status; |
| 13129 | |
| 13130 | status = ucfg_fwol_psoc_open(psoc); |
| 13131 | if (QDF_IS_STATUS_ERROR(status)) |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13132 | goto err_fwol; |
| 13133 | |
| 13134 | status = ucfg_pmo_psoc_open(psoc); |
| 13135 | if (QDF_IS_STATUS_ERROR(status)) |
| 13136 | goto err_pmo; |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13137 | |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13138 | status = ucfg_policy_mgr_psoc_open(psoc); |
| 13139 | if (QDF_IS_STATUS_ERROR(status)) |
| 13140 | goto err_plcy_mgr; |
| 13141 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13142 | status = ucfg_p2p_psoc_open(psoc); |
| 13143 | if (QDF_IS_STATUS_ERROR(status)) |
| 13144 | goto err_p2p; |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13145 | |
| 13146 | status = ucfg_tdls_psoc_open(psoc); |
| 13147 | if (QDF_IS_STATUS_ERROR(status)) |
| 13148 | goto err_tdls; |
| 13149 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13150 | return status; |
| 13151 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13152 | err_tdls: |
| 13153 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13154 | err_p2p: |
| 13155 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13156 | err_plcy_mgr: |
| 13157 | ucfg_pmo_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13158 | err_pmo: |
| 13159 | ucfg_fwol_psoc_close(psoc); |
| 13160 | err_fwol: |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13161 | ucfg_mlme_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13162 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13163 | return status; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13164 | } |
| 13165 | |
| 13166 | void hdd_component_psoc_close(struct wlan_objmgr_psoc *psoc) |
| 13167 | { |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13168 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13169 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13170 | ucfg_policy_mgr_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13171 | ucfg_pmo_psoc_close(psoc); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13172 | ucfg_fwol_psoc_close(psoc); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13173 | ucfg_mlme_psoc_close(psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13174 | } |
| 13175 | |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13176 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 13177 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13178 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13179 | disa_psoc_enable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13180 | nan_psoc_enable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13181 | p2p_psoc_enable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13182 | policy_mgr_psoc_enable(psoc); |
Wu Gao | a67c380 | 2018-12-27 12:07:52 +0800 | [diff] [blame] | 13183 | ucfg_tdls_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13184 | } |
| 13185 | |
| 13186 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 13187 | { |
Wu Gao | a67c380 | 2018-12-27 12:07:52 +0800 | [diff] [blame] | 13188 | ucfg_tdls_psoc_disable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13189 | policy_mgr_psoc_disable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13190 | p2p_psoc_disable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13191 | nan_psoc_disable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13192 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13193 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13194 | } |
| 13195 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 13196 | QDF_STATUS hdd_component_pdev_open(struct wlan_objmgr_pdev *pdev) |
| 13197 | { |
| 13198 | return ucfg_mlme_pdev_open(pdev); |
| 13199 | } |
| 13200 | |
| 13201 | void hdd_component_pdev_close(struct wlan_objmgr_pdev *pdev) |
| 13202 | { |
| 13203 | ucfg_mlme_pdev_close(pdev); |
| 13204 | } |
| 13205 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13206 | static QDF_STATUS hdd_qdf_print_init(void) |
| 13207 | { |
| 13208 | QDF_STATUS status; |
| 13209 | int qdf_print_idx; |
| 13210 | |
| 13211 | status = qdf_print_setup(); |
| 13212 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13213 | pr_err("Failed qdf_print_setup; status:%u\n", status); |
| 13214 | return status; |
| 13215 | } |
| 13216 | |
| 13217 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 13218 | if (qdf_print_idx < 0) { |
| 13219 | pr_err("Failed to register for qdf_print_ctrl\n"); |
| 13220 | return QDF_STATUS_E_FAILURE; |
| 13221 | } |
| 13222 | |
| 13223 | qdf_set_pidx(qdf_print_idx); |
| 13224 | |
| 13225 | return QDF_STATUS_SUCCESS; |
| 13226 | } |
| 13227 | |
| 13228 | static void hdd_qdf_print_deinit(void) |
| 13229 | { |
| 13230 | int qdf_pidx = qdf_get_pidx(); |
| 13231 | |
| 13232 | qdf_set_pidx(-1); |
| 13233 | qdf_print_ctrl_cleanup(qdf_pidx); |
| 13234 | |
| 13235 | /* currently, no qdf print 'un-setup'*/ |
| 13236 | } |
| 13237 | |
| 13238 | static QDF_STATUS hdd_qdf_init(void) |
| 13239 | { |
| 13240 | QDF_STATUS status; |
| 13241 | |
| 13242 | status = hdd_qdf_print_init(); |
| 13243 | if (QDF_IS_STATUS_ERROR(status)) |
| 13244 | goto exit; |
| 13245 | |
| 13246 | status = qdf_debugfs_init(); |
| 13247 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13248 | hdd_err("Failed to init debugfs; status:%u", status); |
| 13249 | goto print_deinit; |
| 13250 | } |
| 13251 | |
| 13252 | qdf_lock_stats_init(); |
| 13253 | qdf_mem_init(); |
| 13254 | qdf_mc_timer_manager_init(); |
| 13255 | qdf_event_list_init(); |
| 13256 | |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13257 | status = qdf_talloc_feature_init(); |
| 13258 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13259 | hdd_err("Failed to init talloc; status:%u", status); |
| 13260 | goto event_deinit; |
| 13261 | } |
| 13262 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13263 | status = qdf_cpuhp_init(); |
| 13264 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13265 | hdd_err("Failed to init cpuhp; status:%u", status); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13266 | goto talloc_deinit; |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13267 | } |
| 13268 | |
| 13269 | status = qdf_trace_spin_lock_init(); |
| 13270 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13271 | hdd_err("Failed to init spinlock; status:%u", status); |
| 13272 | goto cpuhp_deinit; |
| 13273 | } |
| 13274 | |
| 13275 | qdf_trace_init(); |
| 13276 | qdf_register_debugcb_init(); |
| 13277 | |
| 13278 | return QDF_STATUS_SUCCESS; |
| 13279 | |
| 13280 | cpuhp_deinit: |
| 13281 | qdf_cpuhp_deinit(); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13282 | talloc_deinit: |
| 13283 | qdf_talloc_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13284 | event_deinit: |
| 13285 | qdf_event_list_destroy(); |
| 13286 | qdf_mc_timer_manager_exit(); |
| 13287 | qdf_mem_exit(); |
| 13288 | qdf_lock_stats_deinit(); |
| 13289 | qdf_debugfs_exit(); |
| 13290 | print_deinit: |
| 13291 | hdd_qdf_print_deinit(); |
| 13292 | |
| 13293 | exit: |
| 13294 | return status; |
| 13295 | } |
| 13296 | |
| 13297 | static void hdd_qdf_deinit(void) |
| 13298 | { |
| 13299 | /* currently, no debugcb deinit */ |
| 13300 | |
| 13301 | qdf_trace_deinit(); |
| 13302 | |
| 13303 | /* currently, no trace spinlock deinit */ |
| 13304 | |
| 13305 | qdf_cpuhp_deinit(); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13306 | qdf_talloc_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13307 | qdf_event_list_destroy(); |
| 13308 | qdf_mc_timer_manager_exit(); |
| 13309 | qdf_mem_exit(); |
| 13310 | qdf_lock_stats_deinit(); |
| 13311 | qdf_debugfs_exit(); |
| 13312 | hdd_qdf_print_deinit(); |
| 13313 | } |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13314 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13315 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
| 13316 | static bool is_monitor_mode_supported(void) |
| 13317 | { |
| 13318 | return true; |
| 13319 | } |
| 13320 | #else |
| 13321 | static bool is_monitor_mode_supported(void) |
| 13322 | { |
| 13323 | pr_err("Monitor mode not supported!"); |
| 13324 | return false; |
| 13325 | } |
| 13326 | #endif |
| 13327 | |
| 13328 | #ifdef WLAN_FEATURE_EPPING |
| 13329 | static bool is_epping_mode_supported(void) |
| 13330 | { |
| 13331 | return true; |
| 13332 | } |
| 13333 | #else |
| 13334 | static bool is_epping_mode_supported(void) |
| 13335 | { |
| 13336 | pr_err("Epping mode not supported!"); |
| 13337 | return false; |
| 13338 | } |
| 13339 | #endif |
| 13340 | |
| 13341 | #ifdef QCA_WIFI_FTM |
| 13342 | static bool is_ftm_mode_supported(void) |
| 13343 | { |
| 13344 | return true; |
| 13345 | } |
| 13346 | #else |
| 13347 | static bool is_ftm_mode_supported(void) |
| 13348 | { |
| 13349 | pr_err("FTM mode not supported!"); |
| 13350 | return false; |
| 13351 | } |
| 13352 | #endif |
| 13353 | |
| 13354 | /** |
| 13355 | * is_con_mode_valid() check con mode is valid or not |
| 13356 | * @mode: global con mode |
| 13357 | * |
| 13358 | * Return: TRUE on success FALSE on failure |
| 13359 | */ |
| 13360 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
| 13361 | { |
| 13362 | switch (mode) { |
| 13363 | case QDF_GLOBAL_MONITOR_MODE: |
| 13364 | return is_monitor_mode_supported(); |
| 13365 | case QDF_GLOBAL_EPPING_MODE: |
| 13366 | return is_epping_mode_supported(); |
| 13367 | case QDF_GLOBAL_FTM_MODE: |
| 13368 | return is_ftm_mode_supported(); |
| 13369 | case QDF_GLOBAL_MISSION_MODE: |
| 13370 | return true; |
| 13371 | default: |
| 13372 | return false; |
| 13373 | } |
| 13374 | } |
| 13375 | |
| 13376 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
| 13377 | enum QDF_GLOBAL_MODE curr_mode) |
| 13378 | { |
| 13379 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 13380 | return; |
| 13381 | |
| 13382 | switch (curr_mode) { |
| 13383 | case QDF_GLOBAL_MONITOR_MODE: |
| 13384 | hdd_info("Release wakelock for monitor mode!"); |
| 13385 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 13386 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 13387 | /* fallthrough */ |
| 13388 | case QDF_GLOBAL_MISSION_MODE: |
| 13389 | case QDF_GLOBAL_FTM_MODE: |
| 13390 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 13391 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
| 13392 | hdd_stop_all_adapters(hdd_ctx); |
| 13393 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 13394 | |
| 13395 | break; |
| 13396 | default: |
| 13397 | break; |
| 13398 | } |
| 13399 | } |
| 13400 | |
| 13401 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
| 13402 | enum QDF_GLOBAL_MODE curr_mode) |
| 13403 | { |
| 13404 | int driver_status; |
| 13405 | |
| 13406 | driver_status = hdd_ctx->driver_status; |
| 13407 | |
| 13408 | switch (curr_mode) { |
| 13409 | case QDF_GLOBAL_MISSION_MODE: |
| 13410 | case QDF_GLOBAL_MONITOR_MODE: |
| 13411 | case QDF_GLOBAL_FTM_MODE: |
| 13412 | hdd_close_all_adapters(hdd_ctx, false); |
| 13413 | break; |
| 13414 | case QDF_GLOBAL_EPPING_MODE: |
| 13415 | epping_disable(); |
| 13416 | epping_close(); |
| 13417 | break; |
| 13418 | default: |
| 13419 | return; |
| 13420 | } |
| 13421 | } |
| 13422 | |
| 13423 | static int |
| 13424 | hdd_parse_driver_mode(const char *mode_str, enum QDF_GLOBAL_MODE *out_mode) |
| 13425 | { |
| 13426 | QDF_STATUS status; |
| 13427 | uint32_t mode; |
| 13428 | |
| 13429 | *out_mode = QDF_GLOBAL_MAX_MODE; |
| 13430 | |
| 13431 | status = qdf_uint32_parse(mode_str, &mode); |
| 13432 | if (QDF_IS_STATUS_ERROR(status)) |
| 13433 | return qdf_status_to_os_return(status); |
| 13434 | |
| 13435 | if (mode >= QDF_GLOBAL_MAX_MODE) |
| 13436 | return -ERANGE; |
| 13437 | |
| 13438 | *out_mode = (enum QDF_GLOBAL_MODE)mode; |
| 13439 | |
| 13440 | return 0; |
| 13441 | } |
| 13442 | |
| 13443 | /** |
| 13444 | * __hdd_driver_mode_change() - Handles a driver mode change |
| 13445 | * @hdd_ctx: Pointer to the global HDD context |
| 13446 | * @next_mode: the driver mode to transition to |
| 13447 | * |
| 13448 | * This function is invoked when user updates con_mode using sys entry, |
| 13449 | * to initialize and bring-up driver in that specific mode. |
| 13450 | * |
| 13451 | * Return: Errno |
| 13452 | */ |
| 13453 | static int __hdd_driver_mode_change(struct hdd_context *hdd_ctx, |
| 13454 | enum QDF_GLOBAL_MODE next_mode) |
| 13455 | { |
| 13456 | enum QDF_GLOBAL_MODE curr_mode; |
| 13457 | int errno; |
| 13458 | |
| 13459 | hdd_info("Driver mode changing to %d", next_mode); |
| 13460 | |
| 13461 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13462 | if (errno) |
| 13463 | return errno; |
| 13464 | |
| 13465 | if (!is_con_mode_valid(next_mode)) { |
| 13466 | hdd_err_rl("Requested driver mode is invalid"); |
| 13467 | return -EINVAL; |
| 13468 | } |
| 13469 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13470 | curr_mode = hdd_get_conparam(); |
| 13471 | if (curr_mode == next_mode) { |
| 13472 | hdd_err_rl("Driver is already in the requested mode"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13473 | return 0; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13474 | } |
| 13475 | |
| 13476 | /* ensure adapters are stopped */ |
| 13477 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 13478 | |
| 13479 | errno = hdd_wlan_stop_modules(hdd_ctx, true); |
| 13480 | if (errno) { |
| 13481 | hdd_err("Stop wlan modules failed"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13482 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13483 | } |
| 13484 | |
| 13485 | /* Cleanup present mode before switching to new mode */ |
| 13486 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 13487 | |
| 13488 | hdd_set_conparam(next_mode); |
| 13489 | |
| 13490 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 13491 | if (errno) { |
| 13492 | hdd_err("Start wlan modules failed: %d", errno); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13493 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13494 | } |
| 13495 | |
| 13496 | errno = hdd_open_adapters_for_mode(hdd_ctx, next_mode); |
| 13497 | if (errno) { |
| 13498 | hdd_err("Failed to open adapters"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13499 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13500 | } |
| 13501 | |
| 13502 | if (next_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 13503 | struct hdd_adapter *adapter = |
| 13504 | hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE); |
| 13505 | |
| 13506 | QDF_BUG(adapter); |
| 13507 | if (!adapter) { |
| 13508 | hdd_err("Failed to get monitor adapter"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13509 | return -EINVAL; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13510 | } |
| 13511 | |
| 13512 | errno = hdd_start_adapter(adapter); |
| 13513 | if (errno) { |
| 13514 | hdd_err("Failed to start monitor adapter"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13515 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13516 | } |
| 13517 | |
| 13518 | hdd_info("Acquire wakelock for monitor mode"); |
| 13519 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 13520 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 13521 | } |
| 13522 | |
| 13523 | /* con_mode is a global module parameter */ |
| 13524 | con_mode = next_mode; |
| 13525 | hdd_info("Driver mode successfully changed to %d", next_mode); |
| 13526 | |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13527 | return 0; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13528 | } |
| 13529 | |
| 13530 | static int hdd_driver_mode_change(enum QDF_GLOBAL_MODE mode) |
| 13531 | { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13532 | struct osif_driver_sync *driver_sync; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13533 | struct hdd_context *hdd_ctx; |
| 13534 | QDF_STATUS status; |
| 13535 | int errno; |
| 13536 | |
| 13537 | hdd_enter(); |
| 13538 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13539 | status = osif_driver_sync_trans_start_wait(&driver_sync); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13540 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13541 | hdd_err("Failed to start 'mode change'; status:%u", status); |
| 13542 | errno = qdf_status_to_os_return(status); |
| 13543 | goto exit; |
| 13544 | } |
| 13545 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13546 | osif_driver_sync_wait_for_ops(driver_sync); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13547 | |
| 13548 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13549 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13550 | if (errno) |
| 13551 | goto trans_stop; |
| 13552 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13553 | errno = __hdd_driver_mode_change(hdd_ctx, mode); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13554 | |
| 13555 | trans_stop: |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13556 | osif_driver_sync_trans_stop(driver_sync); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13557 | |
| 13558 | exit: |
| 13559 | hdd_exit(); |
| 13560 | |
| 13561 | return errno; |
| 13562 | } |
| 13563 | |
| 13564 | static int hdd_set_con_mode(enum QDF_GLOBAL_MODE mode) |
| 13565 | { |
| 13566 | con_mode = mode; |
| 13567 | |
| 13568 | return 0; |
| 13569 | } |
| 13570 | |
| 13571 | static int (*hdd_set_con_mode_cb)(enum QDF_GLOBAL_MODE mode) = hdd_set_con_mode; |
| 13572 | |
| 13573 | static void hdd_driver_mode_change_register(void) |
| 13574 | { |
| 13575 | hdd_set_con_mode_cb = hdd_driver_mode_change; |
| 13576 | } |
| 13577 | |
| 13578 | static void hdd_driver_mode_change_unregister(void) |
| 13579 | { |
| 13580 | hdd_set_con_mode_cb = hdd_set_con_mode; |
| 13581 | } |
| 13582 | |
| 13583 | static int con_mode_handler(const char *kmessage, const struct kernel_param *kp) |
| 13584 | { |
| 13585 | enum QDF_GLOBAL_MODE mode; |
| 13586 | int errno; |
| 13587 | |
| 13588 | errno = hdd_parse_driver_mode(kmessage, &mode); |
| 13589 | if (errno) { |
| 13590 | hdd_err_rl("Failed to parse driver mode '%s'", kmessage); |
| 13591 | return errno; |
| 13592 | } |
| 13593 | |
| 13594 | return hdd_set_con_mode_cb(mode); |
| 13595 | } |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13596 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13597 | /** |
| 13598 | * hdd_driver_load() - Perform the driver-level load operation |
| 13599 | * |
| 13600 | * Note: this is used in both static and DLKM driver builds |
| 13601 | * |
| 13602 | * Return: Errno |
| 13603 | */ |
| 13604 | static int hdd_driver_load(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13605 | { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13606 | struct osif_driver_sync *driver_sync; |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13607 | QDF_STATUS status; |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13608 | int errno; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13609 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13610 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 13611 | g_wlan_driver_version); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13612 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13613 | status = hdd_qdf_init(); |
| 13614 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13615 | errno = qdf_status_to_os_return(status); |
| 13616 | goto exit; |
| 13617 | } |
| 13618 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13619 | osif_sync_init(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13620 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13621 | status = osif_driver_sync_create_and_trans(&driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13622 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13623 | hdd_err("Failed to init driver sync; status:%u", status); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13624 | errno = qdf_status_to_os_return(status); |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13625 | goto sync_deinit; |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13626 | } |
| 13627 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13628 | errno = hdd_init(); |
| 13629 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13630 | hdd_err("Failed to init HDD; errno:%d", errno); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13631 | goto trans_stop; |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13632 | } |
| 13633 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13634 | status = hdd_component_init(); |
| 13635 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13636 | hdd_err("Failed to init components; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13637 | errno = qdf_status_to_os_return(status); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13638 | goto hdd_deinit; |
| 13639 | } |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13640 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13641 | status = qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
| 13642 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13643 | hdd_err("Failed to create wake lock; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13644 | errno = qdf_status_to_os_return(status); |
| 13645 | goto comp_deinit; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13646 | } |
| 13647 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13648 | hdd_set_conparam(con_mode); |
| 13649 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13650 | errno = wlan_hdd_state_ctrl_param_create(); |
| 13651 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13652 | hdd_err("Failed to create ctrl param; errno:%d", errno); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13653 | goto wakelock_destroy; |
| 13654 | } |
| 13655 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13656 | errno = pld_init(); |
| 13657 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13658 | hdd_err("Failed to init PLD; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13659 | goto param_destroy; |
| 13660 | } |
| 13661 | |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13662 | hdd_driver_mode_change_register(); |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13663 | |
| 13664 | osif_driver_sync_register(driver_sync); |
| 13665 | osif_driver_sync_trans_stop(driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13666 | |
| 13667 | /* psoc probe can happen in registration; do after 'load' transition */ |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13668 | errno = wlan_hdd_register_driver(); |
| 13669 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13670 | hdd_err("Failed to register driver; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13671 | goto pld_deinit; |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13672 | } |
| 13673 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13674 | hdd_debug("%s: driver loaded", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13675 | |
| 13676 | return 0; |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13677 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13678 | pld_deinit: |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13679 | status = osif_driver_sync_trans_start(&driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13680 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13681 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13682 | osif_driver_sync_unregister(); |
| 13683 | osif_driver_sync_wait_for_ops(driver_sync); |
| 13684 | |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13685 | hdd_driver_mode_change_unregister(); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13686 | pld_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13687 | |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13688 | param_destroy: |
| 13689 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13690 | wakelock_destroy: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13691 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13692 | comp_deinit: |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13693 | hdd_component_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13694 | hdd_deinit: |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13695 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13696 | trans_stop: |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13697 | osif_driver_sync_trans_stop(driver_sync); |
| 13698 | osif_driver_sync_destroy(driver_sync); |
| 13699 | sync_deinit: |
| 13700 | osif_sync_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13701 | hdd_qdf_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13702 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13703 | exit: |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13704 | return errno; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13705 | } |
| 13706 | |
| 13707 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13708 | * hdd_driver_unload() - Performs the driver-level unload operation |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13709 | * |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13710 | * Note: this is used in both static and DLKM driver builds |
| 13711 | * |
| 13712 | * Return: None |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13713 | */ |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13714 | static void hdd_driver_unload(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13715 | { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13716 | struct osif_driver_sync *driver_sync; |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 13717 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13718 | QDF_STATUS status; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 13719 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13720 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 13721 | QWLAN_VERSIONSTR); |
| 13722 | |
Dustin Brown | 8c0b5e3 | 2019-01-18 13:56:02 -0800 | [diff] [blame] | 13723 | if (g_is_system_reboot_triggered) { |
| 13724 | hdd_info("System rebooting; Skipping unload"); |
| 13725 | return; |
| 13726 | } |
| 13727 | |
| 13728 | if (hdd_ctx) |
| 13729 | hdd_psoc_idle_timer_stop(hdd_ctx); |
| 13730 | |
| 13731 | /* trigger SoC remove */ |
| 13732 | wlan_hdd_unregister_driver(); |
| 13733 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13734 | status = osif_driver_sync_trans_start_wait(&driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13735 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13736 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13737 | hdd_err("Unable to unload wlan; status:%u", status); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 13738 | return; |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13739 | } |
| 13740 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13741 | osif_driver_sync_unregister(); |
| 13742 | osif_driver_sync_wait_for_ops(driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13743 | |
Will Huang | ba035ec | 2018-07-05 11:13:30 +0800 | [diff] [blame] | 13744 | cds_set_driver_loaded(false); |
| 13745 | cds_set_unload_in_progress(true); |
| 13746 | |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13747 | hdd_driver_mode_change_unregister(); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13748 | pld_deinit(); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13749 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13750 | hdd_set_conparam(0); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13751 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13752 | hdd_component_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13753 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13754 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13755 | osif_driver_sync_trans_stop(driver_sync); |
| 13756 | osif_driver_sync_destroy(driver_sync); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 13757 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13758 | osif_sync_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13759 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13760 | hdd_qdf_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13761 | } |
| 13762 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13763 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13764 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13765 | * wlan_boot_cb() - Wlan boot callback |
| 13766 | * @kobj: object whose directory we're creating the link in. |
| 13767 | * @attr: attribute the user is interacting with |
| 13768 | * @buff: the buffer containing the user data |
| 13769 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13770 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13771 | * This callback is invoked when the fs is ready to start the |
| 13772 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13773 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13774 | * 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] | 13775 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13776 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13777 | struct kobj_attribute *attr, |
| 13778 | const char *buf, |
| 13779 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13780 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13781 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13782 | if (wlan_loader->loaded_state) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13783 | hdd_err("wlan driver already initialized"); |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13784 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13785 | } |
| 13786 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13787 | if (hdd_driver_load()) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13788 | return -EIO; |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13789 | |
| 13790 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13791 | |
| 13792 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13793 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13794 | |
| 13795 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13796 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 13797 | * |
| 13798 | * Return: None |
| 13799 | * |
| 13800 | */ |
| 13801 | static void hdd_sysfs_cleanup(void) |
| 13802 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13803 | /* remove from group */ |
| 13804 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 13805 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 13806 | wlan_loader->attr_group); |
| 13807 | |
| 13808 | /* unlink the object from parent */ |
| 13809 | kobject_del(wlan_loader->boot_wlan_obj); |
| 13810 | |
| 13811 | /* free the object */ |
| 13812 | kobject_put(wlan_loader->boot_wlan_obj); |
| 13813 | |
| 13814 | kfree(wlan_loader->attr_group); |
| 13815 | kfree(wlan_loader); |
| 13816 | |
| 13817 | wlan_loader = NULL; |
| 13818 | } |
| 13819 | |
| 13820 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13821 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 13822 | * ready |
| 13823 | * |
| 13824 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 13825 | * when the filesystem is ready. |
| 13826 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13827 | * QDF API cannot be used here since this function is called even before |
| 13828 | * initializing WLAN driver. |
| 13829 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13830 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13831 | */ |
| 13832 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13833 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13834 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13835 | |
| 13836 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13837 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13838 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13839 | |
| 13840 | wlan_loader->boot_wlan_obj = NULL; |
| 13841 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 13842 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13843 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13844 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13845 | |
| 13846 | wlan_loader->loaded_state = 0; |
| 13847 | wlan_loader->attr_group->attrs = attrs; |
| 13848 | |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 13849 | wlan_loader->boot_wlan_obj = kobject_create_and_add(WLAN_LOADER_NAME, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13850 | kernel_kobj); |
| 13851 | if (!wlan_loader->boot_wlan_obj) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13852 | hdd_err("sysfs create and add failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13853 | goto error_return; |
| 13854 | } |
| 13855 | |
| 13856 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 13857 | wlan_loader->attr_group); |
| 13858 | if (ret) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13859 | hdd_err("sysfs create group failed; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13860 | goto error_return; |
| 13861 | } |
| 13862 | |
| 13863 | return 0; |
| 13864 | |
| 13865 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13866 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13867 | |
| 13868 | return ret; |
| 13869 | } |
| 13870 | |
| 13871 | /** |
| 13872 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 13873 | * |
| 13874 | * Return: 0 on success or errno on failure |
| 13875 | */ |
| 13876 | static int wlan_deinit_sysfs(void) |
| 13877 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13878 | if (!wlan_loader) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13879 | hdd_err("wlan_loader is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13880 | return -EINVAL; |
| 13881 | } |
| 13882 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13883 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13884 | return 0; |
| 13885 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13886 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13887 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13888 | |
| 13889 | #ifdef MODULE |
| 13890 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13891 | * hdd_module_init() - Module init helper |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13892 | * |
| 13893 | * Module init helper function used by both module and static driver. |
| 13894 | * |
| 13895 | * Return: 0 for success, errno on failure |
| 13896 | */ |
| 13897 | static int hdd_module_init(void) |
| 13898 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13899 | if (hdd_driver_load()) |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13900 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13901 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13902 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13903 | } |
| 13904 | #else |
| 13905 | static int __init hdd_module_init(void) |
| 13906 | { |
| 13907 | int ret = -EINVAL; |
| 13908 | |
| 13909 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13910 | if (ret) |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13911 | hdd_err("Failed to create sysfs entry"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13912 | |
| 13913 | return ret; |
| 13914 | } |
| 13915 | #endif |
| 13916 | |
| 13917 | |
| 13918 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13919 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13920 | * hdd_module_exit() - Exit function |
| 13921 | * |
| 13922 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 13923 | * |
| 13924 | * Return: None |
| 13925 | */ |
| 13926 | static void __exit hdd_module_exit(void) |
| 13927 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13928 | hdd_driver_unload(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13929 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13930 | #else |
| 13931 | static void __exit hdd_module_exit(void) |
| 13932 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13933 | hdd_driver_unload(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13934 | wlan_deinit_sysfs(); |
| 13935 | } |
| 13936 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13937 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13938 | static int fwpath_changed_handler(const char *kmessage, |
| 13939 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13940 | { |
| 13941 | return param_set_copystring(kmessage, kp); |
| 13942 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13943 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13944 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13945 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13946 | { |
| 13947 | int ret; |
| 13948 | |
| 13949 | ret = param_set_int(kmessage, kp); |
| 13950 | |
| 13951 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 13952 | pr_err("Only FTM mode supported!"); |
| 13953 | return -ENOTSUPP; |
| 13954 | } |
| 13955 | |
| 13956 | hdd_set_conparam(con_mode_ftm); |
| 13957 | con_mode = con_mode_ftm; |
| 13958 | |
| 13959 | return ret; |
| 13960 | } |
| 13961 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 13962 | #ifdef WLAN_FEATURE_EPPING |
| 13963 | static int con_mode_handler_epping(const char *kmessage, |
| 13964 | const struct kernel_param *kp) |
| 13965 | { |
| 13966 | int ret; |
| 13967 | |
| 13968 | ret = param_set_int(kmessage, kp); |
| 13969 | |
| 13970 | if (con_mode_epping != QDF_GLOBAL_EPPING_MODE) { |
| 13971 | pr_err("Only EPPING mode supported!"); |
| 13972 | return -ENOTSUPP; |
| 13973 | } |
| 13974 | |
| 13975 | hdd_set_conparam(con_mode_epping); |
| 13976 | con_mode = con_mode_epping; |
| 13977 | |
| 13978 | return ret; |
| 13979 | } |
| 13980 | #endif |
| 13981 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13982 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13983 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13984 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13985 | { |
| 13986 | int ret; |
| 13987 | |
| 13988 | ret = param_set_int(kmessage, kp); |
| 13989 | |
| 13990 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 13991 | pr_err("Only Monitor mode supported!"); |
| 13992 | return -ENOTSUPP; |
| 13993 | } |
| 13994 | |
| 13995 | hdd_set_conparam(con_mode_monitor); |
| 13996 | con_mode = con_mode_monitor; |
| 13997 | |
| 13998 | return ret; |
| 13999 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14000 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14001 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14002 | /** |
| 14003 | * hdd_get_conparam() - driver exit point |
| 14004 | * |
| 14005 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 14006 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14007 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14008 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14009 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14010 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14011 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14012 | } |
| 14013 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14014 | void hdd_set_conparam(int32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14015 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 14016 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14017 | } |
| 14018 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14019 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14020 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 14021 | * @hdd_ctx: HDD context |
| 14022 | * |
| 14023 | * Cleans up the pre cac interface, if it exists |
| 14024 | * |
| 14025 | * Return: None |
| 14026 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14027 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14028 | { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 14029 | uint8_t vdev_id; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14030 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 14031 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14032 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 14033 | 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] | 14034 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14035 | hdd_err("failed to get pre cac vdev id"); |
| 14036 | return; |
| 14037 | } |
| 14038 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 14039 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14040 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 14041 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14042 | return; |
| 14043 | } |
| 14044 | |
| 14045 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 14046 | wlan_hdd_sap_pre_cac_failure, |
| 14047 | (void *)precac_adapter); |
| 14048 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 14049 | |
| 14050 | } |
| 14051 | |
| 14052 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14053 | * hdd_update_ol_config - API to update ol configuration parameters |
| 14054 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14055 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14056 | * Return: void |
| 14057 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14058 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14059 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14060 | struct ol_config_info cfg = {0}; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14061 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14062 | bool self_recovery = false; |
| 14063 | QDF_STATUS status; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14064 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14065 | if (!ol_ctx) |
| 14066 | return; |
| 14067 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14068 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14069 | if (QDF_IS_STATUS_ERROR(status)) |
| 14070 | hdd_err("Failed to get self recovery ini config"); |
| 14071 | |
| 14072 | cfg.enable_self_recovery = self_recovery; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14073 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 14074 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 14075 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 14076 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14077 | |
| 14078 | ol_init_ini_config(ol_ctx, &cfg); |
| 14079 | } |
| 14080 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14081 | #ifdef FEATURE_RUNTIME_PM |
| 14082 | /** |
| 14083 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 14084 | * @hdd_ctx: hdd context |
| 14085 | * @cfg: pointer to the configuration memory being populated |
| 14086 | * |
| 14087 | * Return: void |
| 14088 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14089 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14090 | struct hif_config_info *cfg) |
| 14091 | { |
| 14092 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14093 | cfg->runtime_pm_delay = |
| 14094 | ucfg_pmo_get_runtime_pm_delay(hdd_ctx->psoc); |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14095 | } |
| 14096 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14097 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14098 | struct hif_config_info *cfg) |
| 14099 | { |
| 14100 | } |
| 14101 | #endif |
| 14102 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14103 | /** |
| 14104 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 14105 | * @hdd_ctx: HDD Context |
| 14106 | * |
| 14107 | * Return: void |
| 14108 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14109 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14110 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14111 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14112 | struct hif_config_info cfg = {0}; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14113 | bool prevent_link_down = false; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14114 | bool self_recovery = false; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14115 | QDF_STATUS status; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14116 | |
| 14117 | if (!scn) |
| 14118 | return; |
| 14119 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14120 | status = ucfg_mlme_get_prevent_link_down(hdd_ctx->psoc, |
| 14121 | &prevent_link_down); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14122 | if (QDF_IS_STATUS_ERROR(status)) |
| 14123 | hdd_err("Failed to get prevent_link_down config"); |
| 14124 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14125 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14126 | if (QDF_IS_STATUS_ERROR(status)) |
| 14127 | hdd_err("Failed to get self recovery ini config"); |
| 14128 | |
| 14129 | cfg.enable_self_recovery = self_recovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14130 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14131 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14132 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14133 | if (prevent_link_down) |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14134 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14135 | } |
| 14136 | |
| 14137 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14138 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 14139 | * datapath |
| 14140 | * @hdd_ctx: HDD Context |
| 14141 | * |
| 14142 | * Return: 0 for success/errno for failure |
| 14143 | */ |
| 14144 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 14145 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14146 | struct cdp_config_params params = {0}; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14147 | QDF_STATUS status; |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14148 | void *soc; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14149 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14150 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 14151 | params.tso_enable = cfg_get(hdd_ctx->psoc, CFG_DP_TSO); |
| 14152 | params.lro_enable = cfg_get(hdd_ctx->psoc, CFG_DP_LRO); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14153 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 14154 | params.tx_flow_stop_queue_threshold = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 14155 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14156 | params.tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 14157 | cfg_get(hdd_ctx->psoc, |
| 14158 | CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14159 | #endif |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14160 | params.flow_steering_enable = |
| 14161 | cfg_get(hdd_ctx->psoc, CFG_DP_FLOW_STEERING_ENABLED); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14162 | params.napi_enable = hdd_ctx->napi_enable; |
| 14163 | params.tcp_udp_checksumoffload = |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14164 | cfg_get(hdd_ctx->psoc, |
| 14165 | CFG_DP_TCP_UDP_CKSUM_OFFLOAD); |
Sravan Kumar Kairam | 0af1ee5 | 2018-12-12 20:37:51 +0530 | [diff] [blame] | 14166 | params.ipa_enable = ucfg_ipa_is_enabled(); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 14167 | params.gro_enable = cfg_get(hdd_ctx->psoc, CFG_DP_GRO); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14168 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14169 | status = cdp_update_config_parameters(soc, ¶ms); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14170 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 14171 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14172 | return status; |
| 14173 | } |
| 14174 | |
| 14175 | return 0; |
| 14176 | } |
| 14177 | |
| 14178 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14179 | * hdd_update_config() - Initialize driver per module ini parameters |
| 14180 | * @hdd_ctx: HDD Context |
| 14181 | * |
| 14182 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14183 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14184 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14185 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14186 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14187 | int ret; |
| 14188 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14189 | if (ucfg_pmo_is_ns_offloaded(hdd_ctx->psoc)) |
| 14190 | hdd_ctx->ns_offload_enable = true; |
| 14191 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14192 | hdd_update_ol_config(hdd_ctx); |
| 14193 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14194 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 14195 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 14196 | else |
| 14197 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 14198 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14199 | |
| 14200 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14201 | } |
| 14202 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14203 | /** |
| 14204 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 14205 | * @hdd_ctx: HDD context |
| 14206 | * |
| 14207 | * Return: void |
| 14208 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14209 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14210 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14211 | struct pmo_psoc_cfg psoc_cfg = {0}; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14212 | QDF_STATUS status; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14213 | enum pmo_wow_enable_type wow_enable; |
| 14214 | |
| 14215 | ucfg_pmo_get_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14216 | |
| 14217 | /* |
| 14218 | * Value of hdd_ctx->wowEnable can be, |
| 14219 | * 0 - Disable both magic pattern match and pattern byte match. |
| 14220 | * 1 - Enable magic pattern match on all interfaces. |
| 14221 | * 2 - Enable pattern byte match on all interfaces. |
| 14222 | * 3 - Enable both magic patter and pattern byte match on |
| 14223 | * all interfaces. |
| 14224 | */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14225 | wow_enable = ucfg_pmo_get_wow_enable(hdd_ctx->psoc); |
| 14226 | psoc_cfg.magic_ptrn_enable = (wow_enable & 0x01) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14227 | psoc_cfg.ptrn_match_enable_all_vdev = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14228 | (wow_enable & 0x02) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14229 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 14230 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 14231 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 14232 | &psoc_cfg.sta_max_li_mod_dtim); |
| 14233 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14234 | |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 14235 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14236 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14237 | status = ucfg_pmo_update_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 14238 | if (QDF_IS_STATUS_ERROR(status)) |
| 14239 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 14240 | |
| 14241 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14242 | } |
| 14243 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14244 | 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] | 14245 | struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14246 | { |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14247 | struct wlan_fwol_ie_whitelist whitelist = {0}; |
| 14248 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14249 | QDF_STATUS status; |
| 14250 | bool is_ie_whitelist_enable = false; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14251 | uint8_t i = 0; |
| 14252 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14253 | status = ucfg_fwol_get_ie_whitelist(psoc, &is_ie_whitelist_enable); |
| 14254 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14255 | hdd_err("Unable to get IE whitelist param"); |
| 14256 | return; |
| 14257 | } |
| 14258 | |
| 14259 | ie_whitelist->white_list = is_ie_whitelist_enable; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14260 | if (!ie_whitelist->white_list) |
| 14261 | return; |
| 14262 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14263 | status = ucfg_fwol_get_all_whitelist_params(psoc, &whitelist); |
| 14264 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14265 | hdd_err("Unable to get all whitelist params"); |
| 14266 | return; |
| 14267 | } |
| 14268 | |
| 14269 | ie_whitelist->ie_bitmap[0] = whitelist.ie_bitmap_0; |
| 14270 | ie_whitelist->ie_bitmap[1] = whitelist.ie_bitmap_1; |
| 14271 | ie_whitelist->ie_bitmap[2] = whitelist.ie_bitmap_2; |
| 14272 | ie_whitelist->ie_bitmap[3] = whitelist.ie_bitmap_3; |
| 14273 | ie_whitelist->ie_bitmap[4] = whitelist.ie_bitmap_4; |
| 14274 | ie_whitelist->ie_bitmap[5] = whitelist.ie_bitmap_5; |
| 14275 | ie_whitelist->ie_bitmap[6] = whitelist.ie_bitmap_6; |
| 14276 | ie_whitelist->ie_bitmap[7] = whitelist.ie_bitmap_7; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14277 | |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14278 | ie_whitelist->num_vendor_oui = whitelist.no_of_probe_req_ouis; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14279 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14280 | ie_whitelist->voui[i] = whitelist.probe_req_voui[i]; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14281 | } |
| 14282 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14283 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 14284 | { |
| 14285 | uint8_t i, score; |
| 14286 | |
| 14287 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 14288 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 14289 | if (score > MAX_INDEX_SCORE) |
| 14290 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 14291 | MAX_INDEX_SCORE, i); |
| 14292 | } |
| 14293 | |
| 14294 | return per_index_score; |
| 14295 | } |
| 14296 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14297 | QDF_STATUS hdd_update_score_config( |
| 14298 | struct scoring_config *score_config, struct hdd_context *hdd_ctx) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14299 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14300 | struct hdd_config *cfg = hdd_ctx->config; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14301 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14302 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14303 | bool bval = false; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 14304 | uint32_t channel_bonding_mode; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14305 | |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14306 | qdf_mem_zero(&vdev_ini_cfg, sizeof(struct wlan_mlme_nss_chains)); |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14307 | /* Populate the nss chain params from ini for this vdev type */ |
| 14308 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 14309 | QDF_STA_MODE, |
| 14310 | hdd_ctx->num_rf_chains); |
| 14311 | |
| 14312 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]; |
| 14313 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]; |
| 14314 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14315 | sme_update_score_config(hdd_ctx->mac_handle, score_config); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14316 | |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 14317 | ucfg_mlme_get_channel_bonding_24ghz(hdd_ctx->psoc, |
| 14318 | &channel_bonding_mode); |
| 14319 | score_config->cb_mode_24G = channel_bonding_mode; |
| 14320 | ucfg_mlme_get_channel_bonding_5ghz(hdd_ctx->psoc, |
| 14321 | &channel_bonding_mode); |
| 14322 | score_config->cb_mode_5G = channel_bonding_mode; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14323 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14324 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 14325 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 14326 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 14327 | score_config->he_cap = 1; |
| 14328 | |
| 14329 | if (score_config->he_cap || |
| 14330 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 14331 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 14332 | score_config->vht_cap = 1; |
| 14333 | |
| 14334 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 14335 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 14336 | score_config->ht_cap = 1; |
| 14337 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14338 | status = ucfg_mlme_get_vht_for_24ghz(hdd_ctx->psoc, &bval); |
| 14339 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14340 | hdd_err("Failed to get vht_for_24ghz"); |
| 14341 | if (score_config->vht_cap && bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14342 | score_config->vht_24G_cap = 1; |
| 14343 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14344 | status = ucfg_mlme_get_vht_enable_tx_bf(hdd_ctx->psoc, |
| 14345 | &bval); |
| 14346 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14347 | hdd_err("unable to get vht_enable_tx_bf"); |
| 14348 | |
| 14349 | if (bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14350 | score_config->beamformee_cap = 1; |
| 14351 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14352 | return QDF_STATUS_SUCCESS; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14353 | } |
| 14354 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14355 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14356 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 14357 | * @hdd_ctx: HDD context |
| 14358 | * |
| 14359 | * Return: 0 if success else err |
| 14360 | */ |
| 14361 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 14362 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14363 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14364 | struct dfs_user_config dfs_cfg = {0}; |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14365 | QDF_STATUS status; |
| 14366 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 14367 | ucfg_mlme_get_dfs_filter_offload(hdd_ctx->psoc, |
| 14368 | &dfs_cfg.dfs_is_phyerr_filter_offload); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14369 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 14370 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14371 | hdd_err("failed dfs psoc configuration"); |
| 14372 | return -EINVAL; |
| 14373 | } |
| 14374 | |
| 14375 | return 0; |
| 14376 | } |
| 14377 | |
| 14378 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14379 | * hdd_update_scan_config - API to update scan configuration parameters |
| 14380 | * @hdd_ctx: HDD context |
| 14381 | * |
| 14382 | * Return: 0 if success else err |
| 14383 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14384 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14385 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14386 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Sandeep Puligilla | d788702 | 2019-02-26 00:48:52 -0800 | [diff] [blame] | 14387 | struct scan_user_cfg scan_cfg; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14388 | QDF_STATUS status; |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14389 | uint32_t mcast_mcc_rest_time = 0; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14390 | |
Sandeep Puligilla | d788702 | 2019-02-26 00:48:52 -0800 | [diff] [blame] | 14391 | qdf_mem_zero(&scan_cfg, sizeof(scan_cfg)); |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14392 | status = ucfg_mlme_get_sta_miracast_mcc_rest_time(hdd_ctx->psoc, |
| 14393 | &mcast_mcc_rest_time); |
| 14394 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14395 | hdd_err("ucfg_mlme_get_sta_miracast_mcc_rest_time, use def"); |
| 14396 | return -EIO; |
| 14397 | } |
| 14398 | scan_cfg.sta_miracast_mcc_rest_time = mcast_mcc_rest_time; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14399 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14400 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14401 | status = hdd_update_score_config(&scan_cfg.score_config, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14402 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14403 | hdd_err("Failed to update scoring config"); |
| 14404 | return -EINVAL; |
| 14405 | } |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14406 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14407 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 14408 | if (status != QDF_STATUS_SUCCESS) { |
| 14409 | hdd_err("failed pmo psoc configuration"); |
| 14410 | return -EINVAL; |
| 14411 | } |
| 14412 | |
| 14413 | return 0; |
| 14414 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14415 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14416 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14417 | { |
| 14418 | int ret; |
| 14419 | |
| 14420 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14421 | if (ret) |
| 14422 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14423 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14424 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14425 | if (ret) |
| 14426 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14427 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14428 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14429 | if (ret) |
| 14430 | return ret; |
| 14431 | |
| 14432 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14433 | if (ret) |
| 14434 | return ret; |
| 14435 | |
| 14436 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14437 | |
| 14438 | return ret; |
| 14439 | } |
| 14440 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14441 | /** |
| 14442 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 14443 | * @mode : cfg80211 DFS mode |
| 14444 | * |
| 14445 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 14446 | */ |
| 14447 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 14448 | { |
| 14449 | switch (mode) { |
| 14450 | case DFS_MODE_ENABLE: |
| 14451 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14452 | case DFS_MODE_DISABLE: |
| 14453 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14454 | case DFS_MODE_DEPRIORITIZE: |
| 14455 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14456 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14457 | hdd_debug("ACS dfs mode is NONE"); |
| 14458 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14459 | } |
| 14460 | } |
| 14461 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14462 | /** |
| 14463 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 14464 | * @hddctx: pointer to hdd context |
| 14465 | * @set_value: enable/disable |
| 14466 | * |
| 14467 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 14468 | * Host(even though it is duplicate). When Host send vendor command |
| 14469 | * disable,FW doesn't perform any action. Whenever any change in |
| 14470 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 14471 | * |
| 14472 | * return - 0 on success, appropriate error values on failure. |
| 14473 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14474 | 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] | 14475 | { |
| 14476 | QDF_STATUS status; |
| 14477 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14478 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14479 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14480 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14481 | status = sme_enable_disable_chanavoidind_event(hdd_ctx->mac_handle, |
| 14482 | set_value); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14483 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14484 | hdd_err("Failed to send chan avoid command to SME"); |
| 14485 | return -EINVAL; |
| 14486 | } |
| 14487 | return 0; |
| 14488 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14489 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14490 | /** |
| 14491 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 14492 | * @value: value to set |
| 14493 | * |
| 14494 | * This function will set the passed value to roaming in progress flag. |
| 14495 | * |
| 14496 | * Return: None |
| 14497 | */ |
| 14498 | void hdd_set_roaming_in_progress(bool value) |
| 14499 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14500 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14501 | |
| 14502 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14503 | if (!hdd_ctx) { |
| 14504 | hdd_err("HDD context is NULL"); |
| 14505 | return; |
| 14506 | } |
| 14507 | |
| 14508 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14509 | hdd_debug("Roaming in Progress set to %d", value); |
Abhinav Kumar | 2b431b6 | 2019-03-18 20:23:58 +0530 | [diff] [blame] | 14510 | if (!hdd_ctx->roaming_in_progress) { |
| 14511 | /* Reset scan reject params on successful roam complete */ |
| 14512 | hdd_debug("Reset scan reject params"); |
| 14513 | hdd_init_scan_reject_params(hdd_ctx); |
| 14514 | } |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14515 | } |
| 14516 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14517 | bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14518 | { |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14519 | if (!hdd_ctx) { |
| 14520 | hdd_err("HDD context is NULL"); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14521 | return false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14522 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 14523 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14524 | hdd_debug("roaming_in_progress = %d", hdd_ctx->roaming_in_progress); |
| 14525 | |
| 14526 | return hdd_ctx->roaming_in_progress; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14527 | } |
| 14528 | |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14529 | bool hdd_is_connection_in_progress(uint8_t *out_vdev_id, |
| 14530 | enum scan_reject_states *out_reason) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14531 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 14532 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14533 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14534 | uint8_t sta_id = 0; |
| 14535 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14536 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14537 | mac_handle_t mac_handle; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14538 | |
| 14539 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14540 | if (!hdd_ctx) { |
| 14541 | hdd_err("HDD context is NULL"); |
| 14542 | return false; |
| 14543 | } |
| 14544 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14545 | mac_handle = hdd_ctx->mac_handle; |
| 14546 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14547 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 929afa4 | 2018-06-01 15:04:44 -0700 | [diff] [blame] | 14548 | hdd_debug("Adapter with device mode %s(%d) exists", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 14549 | qdf_opmode_str(adapter->device_mode), |
| 14550 | adapter->device_mode); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14551 | if (((QDF_STA_MODE == adapter->device_mode) |
| 14552 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 14553 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 14554 | && (eConnectionState_Connecting == |
| 14555 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 14556 | conn_info.conn_state)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14557 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14558 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14559 | adapter->vdev_id); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14560 | if (out_vdev_id && out_reason) { |
| 14561 | *out_vdev_id = adapter->vdev_id; |
| 14562 | *out_reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14563 | } |
| 14564 | return true; |
| 14565 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 14566 | /* |
| 14567 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 14568 | * hdd_is_roaming_in_progress is for LFR3 |
| 14569 | */ |
| 14570 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 14571 | sme_neighbor_middle_of_roaming( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14572 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14573 | adapter->vdev_id)) || |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14574 | hdd_is_roaming_in_progress(hdd_ctx)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14575 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14576 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14577 | adapter->vdev_id); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14578 | if (out_vdev_id && out_reason) { |
| 14579 | *out_vdev_id = adapter->vdev_id; |
| 14580 | *out_reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14581 | } |
| 14582 | return true; |
| 14583 | } |
| 14584 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 14585 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 14586 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 14587 | hdd_sta_ctx = |
| 14588 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 14589 | if ((eConnectionState_Associated == |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 14590 | hdd_sta_ctx->conn_info.conn_state) |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 14591 | && sme_is_sta_key_exchange_in_progress( |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14592 | mac_handle, adapter->vdev_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14593 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 14594 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14595 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14596 | " is in middle of WPS/EAPOL exchange.", |
| 14597 | MAC_ADDR_ARRAY(sta_mac)); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14598 | if (out_vdev_id && out_reason) { |
| 14599 | *out_vdev_id = adapter->vdev_id; |
| 14600 | *out_reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14601 | } |
| 14602 | return true; |
| 14603 | } |
| 14604 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 14605 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 14606 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 14607 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14608 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14609 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14610 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14611 | continue; |
| 14612 | |
| 14613 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14614 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 14615 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14616 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14617 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 14618 | MAC_ADDR_ARRAY(sta_mac)); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14619 | if (out_vdev_id && out_reason) { |
| 14620 | *out_vdev_id = adapter->vdev_id; |
| 14621 | *out_reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14622 | } |
| 14623 | return true; |
| 14624 | } |
| 14625 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14626 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14627 | return true; |
| 14628 | } |
| 14629 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14630 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14631 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14632 | return false; |
| 14633 | } |
| 14634 | |
| 14635 | /** |
| 14636 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14637 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14638 | * |
| 14639 | * Return: None |
| 14640 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14641 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14642 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 14643 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 14644 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14645 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14646 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | 8f8ceb9 | 2019-03-24 08:16:55 -0700 | [diff] [blame] | 14647 | struct sap_config *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14648 | void *sap_ctx; |
| 14649 | |
| 14650 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 14651 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 14652 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14653 | |
| 14654 | mutex_lock(&hdd_ctx->sap_lock); |
| 14655 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 14656 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14657 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 14658 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 14659 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 14660 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14661 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14662 | qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 14663 | SME_CMD_STOP_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14664 | |
| 14665 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14666 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14667 | goto end; |
| 14668 | } |
| 14669 | } |
| 14670 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14671 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14672 | ap_adapter->device_mode, ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14673 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14674 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14675 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14676 | |
| 14677 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14678 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14679 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14680 | eUPDATE_IE_ALL); |
| 14681 | goto end; |
| 14682 | } |
| 14683 | |
| 14684 | qdf_event_reset(&hostapd_state->qdf_event); |
| 14685 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 14686 | sap_config, |
| 14687 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14688 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14689 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14690 | eUPDATE_IE_ALL); |
| 14691 | goto end; |
| 14692 | } |
| 14693 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14694 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14695 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14696 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 14697 | SME_CMD_START_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14698 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14699 | eUPDATE_IE_ALL); |
| 14700 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14701 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14702 | goto end; |
| 14703 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14704 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14705 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14706 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14707 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14708 | ap_adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14709 | ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14710 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14711 | ap_adapter->device_mode, |
| 14712 | true); |
| 14713 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14714 | } |
| 14715 | end: |
| 14716 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14717 | } |
| 14718 | |
| 14719 | /** |
| 14720 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 14721 | * with non dfs acs |
| 14722 | * |
| 14723 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 14724 | * |
| 14725 | * Return: None |
| 14726 | */ |
| 14727 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 14728 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14729 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14730 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 14731 | struct cds_context *cds_ctx; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14732 | uint8_t restart_chan; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14733 | |
| 14734 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14735 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14736 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14737 | return; |
| 14738 | } |
| 14739 | |
| 14740 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 14741 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14742 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14743 | return; |
| 14744 | } |
| 14745 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14746 | if (policy_mgr_get_concurrency_mode(hdd_ctx->psoc) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14747 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 14748 | hdd_debug("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14749 | return; |
| 14750 | } |
| 14751 | |
| 14752 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14753 | if (ap_adapter && |
| 14754 | test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags) && |
| 14755 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, |
| 14756 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14757 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14758 | 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] | 14759 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14760 | restart_chan = |
| 14761 | hdd_get_safe_channel_from_pcl_and_acs_range(ap_adapter); |
| 14762 | if (!restart_chan || |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14763 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, restart_chan)) |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14764 | restart_chan = SAP_DEFAULT_5GHZ_CHANNEL; |
| 14765 | |
| 14766 | hdd_switch_sap_channel(ap_adapter, restart_chan, true); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14767 | } |
| 14768 | } |
| 14769 | |
| 14770 | /** |
| 14771 | * hdd_set_connection_in_progress() - to set the connection in |
| 14772 | * progress flag |
| 14773 | * @value: value to set |
| 14774 | * |
| 14775 | * This function will set the passed value to connection in progress flag. |
| 14776 | * If value is previously being set to true then no need to set it again. |
| 14777 | * |
| 14778 | * Return: true if value is being set correctly and false otherwise. |
| 14779 | */ |
| 14780 | bool hdd_set_connection_in_progress(bool value) |
| 14781 | { |
| 14782 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14783 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14784 | |
| 14785 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14786 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14787 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14788 | return false; |
| 14789 | } |
| 14790 | |
| 14791 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 14792 | /* |
| 14793 | * if the value is set to true previously and if someone is |
| 14794 | * trying to make it true again then it could be some race |
| 14795 | * condition being triggered. Avoid this situation by returning |
| 14796 | * false |
| 14797 | */ |
| 14798 | if (hdd_ctx->connection_in_progress && value) |
| 14799 | status = false; |
| 14800 | else |
| 14801 | hdd_ctx->connection_in_progress = value; |
| 14802 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 14803 | return status; |
| 14804 | } |
| 14805 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14806 | 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] | 14807 | { |
| 14808 | if (!adapter) { |
| 14809 | hdd_err("Invalid adapter"); |
| 14810 | return -EINVAL; |
| 14811 | } |
| 14812 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14813 | sme_cli_set_command(adapter->vdev_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14814 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 14815 | set_value, VDEV_CMD); |
| 14816 | return 0; |
| 14817 | |
| 14818 | } |
| 14819 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14820 | 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] | 14821 | { |
| 14822 | if (!adapter) { |
| 14823 | hdd_err("Invalid adapter"); |
| 14824 | return -EINVAL; |
| 14825 | } |
| 14826 | |
| 14827 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14828 | sme_cli_set_command(adapter->vdev_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14829 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 14830 | set_value, VDEV_CMD); |
| 14831 | return 0; |
| 14832 | } |
| 14833 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14834 | 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] | 14835 | *psoc, uint8_t vdev_id) |
| 14836 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14837 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14838 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 14839 | |
| 14840 | /* |
| 14841 | * Currently PSOC is not being used. But this logic will |
| 14842 | * change once we have the converged implementation of |
| 14843 | * HDD context per PSOC in place. This would break if |
| 14844 | * multiple vdev objects reuse the vdev id. |
| 14845 | */ |
| 14846 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 14847 | if (!adapter) |
| 14848 | hdd_err("Get adapter by vdev id failed"); |
| 14849 | |
| 14850 | return adapter; |
| 14851 | } |
| 14852 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14853 | 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] | 14854 | int8_t *rssi, int8_t *snr) |
| 14855 | { |
| 14856 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14857 | mac_handle_t mac_handle; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14858 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14859 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14860 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14861 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 14862 | status = sme_get_rssi_snr_by_bssid(mac_handle, |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14863 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14864 | if (QDF_STATUS_SUCCESS != status) { |
| 14865 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 14866 | return -EINVAL; |
| 14867 | } |
| 14868 | |
| 14869 | return 0; |
| 14870 | } |
| 14871 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14872 | /** |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14873 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 14874 | * @adapter - HDD adapter |
| 14875 | * |
| 14876 | * Return: 0 on success and non zero value on failure |
| 14877 | */ |
| 14878 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 14879 | { |
| 14880 | struct hdd_context *hdd_ctx; |
| 14881 | int ret; |
| 14882 | QDF_STATUS status; |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14883 | uint8_t sys_pref = 0; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14884 | |
| 14885 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 14886 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14887 | if (ret < 0) |
| 14888 | return ret; |
| 14889 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14890 | ucfg_policy_mgr_get_sys_pref(hdd_ctx->psoc, |
| 14891 | &sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14892 | /* set the system preferece to default */ |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14893 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->psoc, sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14894 | |
| 14895 | /* clear the bitmap */ |
| 14896 | adapter->active_ac = 0; |
| 14897 | |
| 14898 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14899 | adapter->vdev_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14900 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14901 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14902 | adapter->vdev_id, |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14903 | false, 0, 0, false); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14904 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14905 | hdd_err("failed to reset limit off chan params"); |
| 14906 | ret = -EINVAL; |
| 14907 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14908 | |
| 14909 | return ret; |
| 14910 | } |
| 14911 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14912 | /** |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14913 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 14914 | * @struct hdd_context *hdd_ctx |
| 14915 | * @struct hdd_adapter *padapter |
| 14916 | * @bool enble |
| 14917 | * |
| 14918 | * Return: none |
| 14919 | */ |
| 14920 | void hdd_set_rx_mode_rps(bool enable) |
| 14921 | { |
| 14922 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 14923 | struct hdd_context *hdd_ctx; |
| 14924 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14925 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 14926 | if (!cds_cfg) |
| 14927 | return; |
| 14928 | |
| 14929 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14930 | if (!hdd_ctx) |
| 14931 | return; |
| 14932 | |
| 14933 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 14934 | if (!adapter) |
| 14935 | return; |
| 14936 | |
| 14937 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14938 | if (enable && !cds_cfg->rps_enabled) |
| 14939 | hdd_send_rps_ind(adapter); |
| 14940 | else if (!enable && cds_cfg->rps_enabled) |
| 14941 | hdd_send_rps_disable_ind(adapter); |
| 14942 | } |
| 14943 | } |
| 14944 | |
Abhinav Kumar | 338e57d | 2019-02-04 17:30:10 +0530 | [diff] [blame] | 14945 | void hdd_hidden_ssid_enable_roaming(hdd_handle_t hdd_handle, uint8_t vdev_id) |
| 14946 | { |
| 14947 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
| 14948 | struct hdd_adapter *adapter; |
| 14949 | |
| 14950 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 14951 | |
| 14952 | if (!adapter) { |
| 14953 | hdd_err("Adapter is null"); |
| 14954 | return; |
| 14955 | } |
| 14956 | /* enable roaming on all adapters once hdd get hidden ssid rsp */ |
| 14957 | wlan_hdd_enable_roaming(adapter); |
| 14958 | } |
| 14959 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14960 | /* Register the module init/exit functions */ |
| 14961 | module_init(hdd_module_init); |
| 14962 | module_exit(hdd_module_exit); |
| 14963 | |
| 14964 | MODULE_LICENSE("Dual BSD/GPL"); |
| 14965 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 14966 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 14967 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14968 | static const struct kernel_param_ops con_mode_ops = { |
| 14969 | .set = con_mode_handler, |
| 14970 | .get = param_get_int, |
| 14971 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14972 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14973 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 14974 | .set = con_mode_handler_ftm, |
| 14975 | .get = param_get_int, |
| 14976 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14977 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 14978 | #ifdef WLAN_FEATURE_EPPING |
| 14979 | static const struct kernel_param_ops con_mode_epping_ops = { |
| 14980 | .set = con_mode_handler_epping, |
| 14981 | .get = param_get_int, |
| 14982 | }; |
| 14983 | #endif |
| 14984 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14985 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14986 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 14987 | .set = con_mode_handler_monitor, |
| 14988 | .get = param_get_int, |
| 14989 | }; |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14990 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14991 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14992 | static const struct kernel_param_ops fwpath_ops = { |
| 14993 | .set = fwpath_changed_handler, |
| 14994 | .get = param_get_string, |
| 14995 | }; |
| 14996 | |
| 14997 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 14998 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 14999 | |
| 15000 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 15001 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15002 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 15003 | #ifdef WLAN_FEATURE_EPPING |
| 15004 | module_param_cb(con_mode_epping, &con_mode_epping_ops, |
| 15005 | &con_mode_epping, 0644); |
| 15006 | #endif |
| 15007 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15008 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15009 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 15010 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15011 | #endif |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15012 | |
| 15013 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 15014 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15015 | |
| 15016 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15017 | |
| 15018 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15019 | |
| 15020 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |
Dustin Brown | 4bbd546 | 2019-03-22 11:18:13 -0700 | [diff] [blame] | 15021 | |
| 15022 | static int timer_multiplier_get_handler(char *buffer, |
| 15023 | const struct kernel_param *kp) |
| 15024 | { |
| 15025 | return scnprintf(buffer, PAGE_SIZE, "%u", qdf_timer_get_multiplier()); |
| 15026 | } |
| 15027 | |
| 15028 | static int timer_multiplier_set_handler(const char *kmessage, |
| 15029 | const struct kernel_param *kp) |
| 15030 | { |
| 15031 | QDF_STATUS status; |
| 15032 | uint32_t scalar; |
| 15033 | |
| 15034 | status = qdf_uint32_parse(kmessage, &scalar); |
| 15035 | if (QDF_IS_STATUS_ERROR(status)) |
| 15036 | return qdf_status_to_os_return(status); |
| 15037 | |
| 15038 | if (!cfg_in_range(CFG_TIMER_MULTIPLIER, scalar)) |
| 15039 | return -ERANGE; |
| 15040 | |
| 15041 | qdf_timer_set_multiplier(scalar); |
| 15042 | |
| 15043 | return 0; |
| 15044 | } |
| 15045 | |
| 15046 | static const struct kernel_param_ops timer_multiplier_ops = { |
| 15047 | .get = timer_multiplier_get_handler, |
| 15048 | .set = timer_multiplier_set_handler, |
| 15049 | }; |
| 15050 | |
| 15051 | module_param_cb(timer_multiplier, &timer_multiplier_ops, NULL, 0644); |
| 15052 | |