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" |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 29 | #include "wlan_dsc.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 30 | #include <wlan_hdd_includes.h> |
| 31 | #include <cds_api.h> |
| 32 | #include <cds_sched.h> |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 33 | #include <linux/cpu.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 34 | #include <linux/etherdevice.h> |
| 35 | #include <linux/firmware.h> |
| 36 | #include <wlan_hdd_tx_rx.h> |
| 37 | #include <wni_api.h> |
| 38 | #include <wlan_hdd_cfg.h> |
| 39 | #include <wlan_ptt_sock_svc.h> |
| 40 | #include <dbglog_host.h> |
| 41 | #include <wlan_logging_sock_svc.h> |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 42 | #include <wlan_roam_debug.h> |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 43 | #include "wlan_hdd_dsc.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 44 | #include <wlan_hdd_wowl.h> |
| 45 | #include <wlan_hdd_misc.h> |
| 46 | #include <wlan_hdd_wext.h> |
| 47 | #include "wlan_hdd_trace.h" |
| 48 | #include "wlan_hdd_ioctl.h" |
| 49 | #include "wlan_hdd_ftm.h" |
| 50 | #include "wlan_hdd_power.h" |
| 51 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 52 | #include "wlan_hdd_scan.h" |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 53 | #include "wlan_policy_mgr_ucfg.h" |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 54 | #include <wlan_osif_request_manager.h> |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 55 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 56 | #include "qdf_debug_domain.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 57 | #endif |
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 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 82 | #include <soc/qcom/subsystem_restart.h> |
| 83 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 84 | #include <wlan_hdd_hostapd.h> |
| 85 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 86 | #include <wlan_hdd_green_ap.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 87 | #include "qwlan_version.h" |
| 88 | #include "wma_types.h" |
| 89 | #include "wlan_hdd_tdls.h" |
| 90 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 91 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 92 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 93 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 94 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 95 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 96 | #include "wlan_hdd_nan.h" |
| 97 | #include "wlan_hdd_debugfs.h" |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 98 | #include "wlan_hdd_debugfs_csr.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 99 | #include "wlan_hdd_driver_ops.h" |
| 100 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 101 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 102 | |
| 103 | #include <wlan_hdd_ipa.h> |
| 104 | #include "hif.h" |
| 105 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 106 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 107 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 108 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 109 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 110 | #include "wlan_hdd_lpass.h" |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 111 | #include "wlan_nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 112 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 113 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 114 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 115 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 116 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 117 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 118 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 119 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 120 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 121 | #include "os_if_wifi_pos.h" |
| 122 | #include "wifi_pos_api.h" |
| 123 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 124 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 125 | #include "os_if_nan.h" |
| 126 | #include "nan_public_structs.h" |
Nachiket Kukade | 85aa378 | 2018-11-02 20:12:34 +0530 | [diff] [blame] | 127 | #include "nan_ucfg_api.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 128 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 129 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 130 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 131 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 132 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 133 | #include <cdp_txrx_cmn_struct.h> |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 134 | #include <dp_txrx.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 135 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 136 | #include "wlan_disa_ucfg_api.h" |
Wu Gao | 52084c1 | 2018-05-17 20:47:11 +0800 | [diff] [blame] | 137 | #include "wlan_disa_obj_mgmt_api.h" |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 138 | #include "wlan_action_oui_ucfg_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 139 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 140 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 141 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 142 | #include "wlan_hdd_apf.h" |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 143 | #include "wlan_hdd_twt.h" |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 144 | #include "qc_sap_ioctl.h" |
Sandeep Puligilla | c5609d5 | 2018-05-17 19:23:41 -0700 | [diff] [blame] | 145 | #include "wlan_mlme_main.h" |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 146 | #include "wlan_p2p_cfg_api.h" |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 147 | #include "wlan_cfg80211_p2p.h" |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 148 | #include "wlan_tdls_cfg_api.h" |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 149 | #include <wlan_hdd_rssi_monitor.h> |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 150 | #include "wlan_mlme_ucfg_api.h" |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 151 | #include "wlan_fwol_ucfg_api.h" |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 152 | #include "wlan_policy_mgr_ucfg.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 153 | #ifdef CNSS_GENL |
| 154 | #include <net/cnss_nl.h> |
| 155 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 156 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 157 | #include "wlan_ocb_ucfg_api.h" |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 158 | #include <wlan_hdd_spectralscan.h> |
gaurank kathpalia | 4a205fc | 2018-09-15 00:59:15 +0530 | [diff] [blame] | 159 | #include "wlan_green_ap_ucfg_api.h" |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 160 | #include <wlan_p2p_ucfg_api.h> |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 161 | #include <target_type.h> |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 162 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 163 | #ifdef MODULE |
| 164 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 165 | #else |
| 166 | #define WLAN_MODULE_NAME "wlan" |
| 167 | #endif |
| 168 | |
| 169 | #ifdef TIMER_MANAGER |
| 170 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 171 | #else |
| 172 | #define TIMER_MANAGER_STR "" |
| 173 | #endif |
| 174 | |
| 175 | #ifdef MEMORY_DEBUG |
| 176 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 177 | #else |
| 178 | #define MEMORY_DEBUG_STR "" |
| 179 | #endif |
| 180 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 181 | #ifdef PANIC_ON_BUG |
| 182 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 183 | #else |
| 184 | #define PANIC_ON_BUG_STR "" |
| 185 | #endif |
| 186 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 187 | bool g_is_system_reboot_triggered; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 188 | int wlan_start_ret_val; |
| 189 | static DECLARE_COMPLETION(wlan_start_comp); |
| 190 | static unsigned int dev_num = 1; |
| 191 | static struct cdev wlan_hdd_state_cdev; |
| 192 | static struct class *class; |
| 193 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 194 | #ifndef MODULE |
| 195 | static struct gwlan_loader *wlan_loader; |
| 196 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 197 | struct kobj_attribute *attr, |
| 198 | const char *buf, size_t count); |
| 199 | struct gwlan_loader { |
| 200 | bool loaded_state; |
| 201 | struct kobject *boot_wlan_obj; |
| 202 | struct attribute_group *attr_group; |
| 203 | }; |
| 204 | |
| 205 | static struct kobj_attribute wlan_boot_attribute = |
| 206 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 207 | |
| 208 | static struct attribute *attrs[] = { |
| 209 | &wlan_boot_attribute.attr, |
| 210 | NULL, |
| 211 | }; |
| 212 | |
| 213 | #define MODULE_INITIALIZED 1 |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 214 | |
| 215 | #ifdef MULTI_IF_NAME |
| 216 | #define WLAN_LOADER_NAME "boot_" MULTI_IF_NAME |
| 217 | #else |
| 218 | #define WLAN_LOADER_NAME "boot_wlan" |
| 219 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 220 | #endif |
| 221 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 222 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 223 | #define MAX_OPS_NAME_STRING_SIZE 20 |
| 224 | |
| 225 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 226 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 227 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 228 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 229 | /* the Android framework expects this param even though we don't use it */ |
| 230 | #define BUF_LEN 20 |
| 231 | static char fwpath_buffer[BUF_LEN]; |
| 232 | static struct kparam_string fwpath = { |
| 233 | .string = fwpath_buffer, |
| 234 | .maxlen = BUF_LEN, |
| 235 | }; |
| 236 | |
| 237 | static char *country_code; |
| 238 | static int enable_11d = -1; |
| 239 | static int enable_dfs_chan_scan = -1; |
| 240 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 241 | /* |
| 242 | * spinlock for synchronizing asynchronous request/response |
| 243 | * (full description of use in wlan_hdd_main.h) |
| 244 | */ |
| 245 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 246 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 247 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 248 | #define WLAN_NLINK_CESIUM 30 |
| 249 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 250 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 251 | |
| 252 | #define WOW_MAX_FILTER_LISTS 1 |
| 253 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 254 | #define WOW_MIN_PATTERN_SIZE 6 |
| 255 | #define WOW_MAX_PATTERN_SIZE 64 |
| 256 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 257 | /* max peer can be tdls peers + self peer + bss peer */ |
| 258 | #define HDD_MAX_VDEV_PEER_COUNT (HDD_MAX_NUM_TDLS_STA + 2) |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 259 | #define IS_IDLE_STOP (!cds_is_driver_unloading() && \ |
| 260 | !cds_is_driver_recovering() && !cds_is_driver_loading()) |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 261 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 262 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 263 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 264 | .flags = WIPHY_WOWLAN_ANY | |
| 265 | WIPHY_WOWLAN_MAGIC_PKT | |
| 266 | WIPHY_WOWLAN_DISCONNECT | |
| 267 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 268 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 269 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 270 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 271 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 272 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 273 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 274 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 275 | }; |
| 276 | #endif |
| 277 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 278 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 279 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 280 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 281 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 282 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 283 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 284 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 285 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 286 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 287 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 288 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 289 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 290 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 291 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 292 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 293 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 294 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 295 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 296 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 297 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 298 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 299 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 300 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 301 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 302 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 303 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 304 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 305 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 306 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 307 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 308 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 309 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 310 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 311 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 312 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 313 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 314 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 315 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 316 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 317 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 318 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 319 | [QDF_MODULE_ID_ACTION_OUI] = {QDF_TRACE_LEVEL_ALL}, |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 320 | [QDF_MODULE_ID_CONFIG] = {QDF_TRACE_LEVEL_ALL}, |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 321 | [QDF_MODULE_ID_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 8d039c8 | 2018-07-11 20:41:14 +0530 | [diff] [blame] | 322 | [QDF_MODULE_ID_TARGET] = {QDF_TRACE_LEVEL_ALL}, |
Kiran Kumar Lokere | 4ce4048 | 2018-08-30 16:31:00 -0700 | [diff] [blame] | 323 | [QDF_MODULE_ID_CRYPTO] = {QDF_TRACE_LEVEL_ALL}, |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 324 | [QDF_MODULE_ID_FWOL] = {QDF_TRACE_LEVEL_ALL}, |
Abhishek Singh | 0b0105f | 2018-09-25 10:44:16 +0530 | [diff] [blame] | 325 | [QDF_MODULE_ID_SM_ENGINE] = {QDF_TRACE_LEVEL_ALL}, |
| 326 | [QDF_MODULE_ID_CMN_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Nachiket Kukade | 089b983 | 2018-12-12 16:38:17 +0530 | [diff] [blame] | 327 | [QDF_MODULE_ID_NAN] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 328 | }; |
| 329 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 330 | struct notifier_block hdd_netdev_notifier; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 331 | struct notifier_block system_reboot_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 332 | |
| 333 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 334 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 335 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 336 | #endif |
| 337 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 338 | void hdd_start_complete(int ret) |
| 339 | { |
| 340 | wlan_start_ret_val = ret; |
| 341 | |
| 342 | complete(&wlan_start_comp); |
| 343 | } |
| 344 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 345 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 346 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 347 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 348 | * |
| 349 | * Return: none |
| 350 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 351 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 352 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 353 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 354 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 355 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 356 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 357 | } |
| 358 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 359 | #ifdef QCA_HL_NETDEV_FLOW_CONTROL |
| 360 | void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter, |
| 361 | enum netif_action_type action) |
| 362 | { |
| 363 | if (!adapter->tx_flow_timer_initialized) |
| 364 | return; |
| 365 | |
| 366 | if (action == WLAN_WAKE_NON_PRIORITY_QUEUE) { |
| 367 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 368 | } else if (action == WLAN_STOP_NON_PRIORITY_QUEUE) { |
| 369 | QDF_STATUS status = |
| 370 | qdf_mc_timer_start(&adapter->tx_flow_control_timer, |
| 371 | WLAN_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 372 | |
| 373 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 374 | hdd_err("Failed to start tx_flow_control_timer"); |
| 375 | else |
| 376 | adapter-> |
| 377 | hdd_stats.tx_rx_stats.txflow_timer_cnt++; |
| 378 | |
| 379 | adapter->hdd_stats.tx_rx_stats.txflow_pause_cnt++; |
| 380 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = true; |
| 381 | } |
| 382 | } |
| 383 | #endif /* QCA_HL_NETDEV_FLOW_CONTROL */ |
| 384 | |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 385 | #ifdef MSM_PLATFORM |
| 386 | void wlan_hdd_update_tcp_rx_param(struct hdd_context *hdd_ctx, void *data) |
| 387 | { |
| 388 | if (!hdd_ctx) { |
| 389 | hdd_err("HDD context is null"); |
| 390 | return; |
| 391 | } |
| 392 | |
| 393 | if (!data) { |
| 394 | hdd_err("Data is null"); |
| 395 | return; |
| 396 | } |
| 397 | if (hdd_ctx->config->enable_tcp_param_update) |
| 398 | wlan_hdd_send_tcp_param_update_event(hdd_ctx, data, 1); |
| 399 | else |
| 400 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 401 | WLAN_SVC_WLAN_TP_IND, |
| 402 | data, |
| 403 | sizeof(struct wlan_rx_tp_data)); |
| 404 | } |
| 405 | |
| 406 | void wlan_hdd_update_tcp_tx_param(struct hdd_context *hdd_ctx, void *data) |
| 407 | { |
| 408 | enum wlan_tp_level next_tx_level; |
| 409 | struct wlan_tx_tp_data *tx_tp_data; |
| 410 | |
| 411 | if (!hdd_ctx) { |
| 412 | hdd_err("HDD context is null"); |
| 413 | return; |
| 414 | } |
| 415 | |
| 416 | if (!data) { |
| 417 | hdd_err("Data is null"); |
| 418 | return; |
| 419 | } |
| 420 | |
| 421 | tx_tp_data = (struct wlan_tx_tp_data *)data; |
| 422 | next_tx_level = tx_tp_data->level; |
| 423 | |
| 424 | if (hdd_ctx->config->enable_tcp_param_update) |
| 425 | wlan_hdd_send_tcp_param_update_event(hdd_ctx, data, 0); |
| 426 | else |
| 427 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 428 | WLAN_SVC_WLAN_TP_TX_IND, |
| 429 | &next_tx_level, |
| 430 | sizeof(next_tx_level)); |
| 431 | } |
| 432 | |
| 433 | /** |
| 434 | * wlan_hdd_send_tcp_param_update_event() - Send vendor event to update |
| 435 | * TCP parameter through Wi-Fi HAL |
| 436 | * @hdd_ctx: Pointer to HDD context |
| 437 | * @data: Parameters to update |
| 438 | * @dir: Direction(tx/rx) to update |
| 439 | * |
| 440 | * Return: None |
| 441 | */ |
| 442 | void wlan_hdd_send_tcp_param_update_event(struct hdd_context *hdd_ctx, |
| 443 | void *data, |
| 444 | uint8_t dir) |
| 445 | { |
| 446 | struct sk_buff *vendor_event; |
| 447 | uint32_t event_len; |
| 448 | bool tcp_limit_output = false; |
| 449 | bool tcp_del_ack_ind_enabled = false; |
| 450 | bool tcp_adv_win_scl_enabled = false; |
| 451 | enum wlan_tp_level next_tp_level = WLAN_SVC_TP_NONE; |
| 452 | |
| 453 | event_len = sizeof(uint8_t) + sizeof(uint8_t) + NLMSG_HDRLEN; |
| 454 | |
| 455 | if (dir == 0) /*TX Flow */ { |
| 456 | struct wlan_tx_tp_data *tx_tp_data = |
| 457 | (struct wlan_tx_tp_data *)data; |
| 458 | |
| 459 | next_tp_level = tx_tp_data->level; |
| 460 | |
| 461 | if (tx_tp_data->tcp_limit_output) { |
| 462 | /* TCP_LIMIT_OUTPUT_BYTES */ |
| 463 | event_len += sizeof(uint32_t); |
| 464 | tcp_limit_output = true; |
| 465 | } |
| 466 | } else if (dir == 1) /* RX Flow */ { |
| 467 | struct wlan_rx_tp_data *rx_tp_data = |
| 468 | (struct wlan_rx_tp_data *)data; |
| 469 | |
| 470 | next_tp_level = rx_tp_data->level; |
| 471 | |
| 472 | if (rx_tp_data->rx_tp_flags & TCP_DEL_ACK_IND_MASK) { |
| 473 | event_len += sizeof(uint32_t); /* TCP_DELACK_SEG */ |
| 474 | tcp_del_ack_ind_enabled = true; |
| 475 | } |
| 476 | if (rx_tp_data->rx_tp_flags & TCP_ADV_WIN_SCL_MASK) { |
| 477 | event_len += sizeof(uint32_t); /* TCP_ADV_WIN_SCALE */ |
| 478 | tcp_adv_win_scl_enabled = true; |
| 479 | } |
| 480 | } else { |
| 481 | hdd_err("Invalid Direction [%d]", dir); |
| 482 | return; |
| 483 | } |
| 484 | |
| 485 | vendor_event = |
| 486 | cfg80211_vendor_event_alloc( |
| 487 | hdd_ctx->wiphy, |
| 488 | NULL, event_len, |
| 489 | QCA_NL80211_VENDOR_SUBCMD_THROUGHPUT_CHANGE_EVENT_INDEX, |
| 490 | GFP_KERNEL); |
| 491 | |
| 492 | if (!vendor_event) { |
| 493 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 494 | return; |
| 495 | } |
| 496 | |
| 497 | if (nla_put_u8( |
| 498 | vendor_event, |
| 499 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_DIRECTION, |
| 500 | dir)) |
| 501 | goto tcp_param_change_nla_failed; |
| 502 | |
| 503 | if (nla_put_u8( |
| 504 | vendor_event, |
| 505 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_THROUGHPUT_LEVEL, |
| 506 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 507 | QCA_WLAN_THROUGHPUT_LEVEL_LOW : |
| 508 | QCA_WLAN_THROUGHPUT_LEVEL_HIGH))) |
| 509 | goto tcp_param_change_nla_failed; |
| 510 | |
| 511 | if (tcp_limit_output && |
| 512 | nla_put_u32( |
| 513 | vendor_event, |
| 514 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_LIMIT_OUTPUT_BYTES, |
| 515 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 516 | TCP_LIMIT_OUTPUT_BYTES_LOW : |
| 517 | TCP_LIMIT_OUTPUT_BYTES_HI))) |
| 518 | goto tcp_param_change_nla_failed; |
| 519 | |
| 520 | if (tcp_del_ack_ind_enabled && |
| 521 | (nla_put_u32( |
| 522 | vendor_event, |
| 523 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_DELACK_SEG, |
| 524 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 525 | TCP_DEL_ACK_LOW : TCP_DEL_ACK_HI)))) |
| 526 | goto tcp_param_change_nla_failed; |
| 527 | |
| 528 | if (tcp_adv_win_scl_enabled && |
| 529 | (nla_put_u32( |
| 530 | vendor_event, |
| 531 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_ADV_WIN_SCALE, |
| 532 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 533 | WIN_SCALE_LOW : WIN_SCALE_HI)))) |
| 534 | goto tcp_param_change_nla_failed; |
| 535 | |
| 536 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 537 | return; |
| 538 | |
| 539 | tcp_param_change_nla_failed: |
| 540 | hdd_err("nla_put api failed"); |
| 541 | kfree_skb(vendor_event); |
| 542 | } |
| 543 | #endif /* MSM_PLATFORM */ |
| 544 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 545 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 546 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 547 | * @vdev_id: vdev_id |
| 548 | * @action: action type |
| 549 | * @reason: reason type |
| 550 | * |
| 551 | * Return: none |
| 552 | */ |
| 553 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 554 | enum netif_action_type action, enum netif_reason_type reason) |
| 555 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 556 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 557 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 558 | |
| 559 | if (!hdd_ctx) { |
| 560 | hdd_err("hdd ctx is NULL"); |
| 561 | return; |
| 562 | } |
| 563 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 564 | wlan_hdd_mod_fc_timer(adapter, action); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 565 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 569 | * Store WLAN driver version and timestamp info in global variables such that |
| 570 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 571 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 572 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 573 | #ifdef BUILD_TAG |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 574 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR "; " BUILD_TAG; |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 575 | #else |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 576 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 577 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 578 | |
| 579 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 580 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 581 | * @hdd_ctx: HDD context |
| 582 | * @chan_list: buf hold returned chan list |
| 583 | * @chan_num: input buf size and output returned chan num |
| 584 | * |
| 585 | * This function helps get current available chan list from regulatory |
| 586 | * module. It excludes the "disabled" and "invalid" channels. |
| 587 | * |
| 588 | * Return: 0 for success. |
| 589 | */ |
| 590 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 591 | uint8_t *chan_list, |
| 592 | uint32_t *chan_num) |
| 593 | { |
| 594 | int i = 0, j = 0; |
| 595 | struct regulatory_channel *cur_chan_list; |
| 596 | struct wlan_objmgr_pdev *pdev; |
| 597 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 598 | if (!hdd_ctx || !hdd_ctx->pdev || !chan_list || !chan_num) |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 599 | return -EINVAL; |
| 600 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 601 | pdev = hdd_ctx->pdev; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 602 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 603 | sizeof(struct regulatory_channel)); |
| 604 | if (!cur_chan_list) |
| 605 | return -ENOMEM; |
| 606 | |
| 607 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 608 | QDF_STATUS_SUCCESS) { |
| 609 | qdf_mem_free(cur_chan_list); |
| 610 | return -EINVAL; |
| 611 | } |
| 612 | |
| 613 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 614 | uint32_t ch = cur_chan_list[i].chan_num; |
| 615 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 616 | ch); |
| 617 | |
| 618 | if (state != CHANNEL_STATE_DISABLE && |
| 619 | state != CHANNEL_STATE_INVALID && |
| 620 | j < *chan_num) { |
| 621 | chan_list[j] = (uint8_t)ch; |
| 622 | j++; |
| 623 | } |
| 624 | } |
| 625 | *chan_num = j; |
| 626 | qdf_mem_free(cur_chan_list); |
| 627 | return 0; |
| 628 | } |
| 629 | |
| 630 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 631 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 632 | * @adapter: HDD adapter |
| 633 | * @chan_number: Channel number |
| 634 | * @chan_bw: Bandwidth |
| 635 | * |
| 636 | * Checks if the given bandwidth is valid for the given channel number. |
| 637 | * |
| 638 | * Return: 0 for success, non-zero for failure |
| 639 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 640 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 641 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 642 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 643 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 644 | uint8_t chan[NUM_CHANNELS]; |
| 645 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 646 | bool found = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 647 | mac_handle_t mac_handle; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 648 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 649 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 650 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 651 | if (!mac_handle) { |
| 652 | hdd_err("Invalid MAC handle"); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 653 | return -EINVAL; |
| 654 | } |
| 655 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 656 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 657 | &len); |
| 658 | if (ret) { |
| 659 | hdd_err("error %d in getting valid channel list", ret); |
| 660 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | for (i = 0; i < len; i++) { |
| 664 | if (chan[i] == chan_number) { |
| 665 | found = true; |
| 666 | break; |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | if (found == false) { |
| 671 | hdd_err("Channel not in driver's valid channel list"); |
| 672 | return -EOPNOTSUPP; |
| 673 | } |
| 674 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 675 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 676 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 677 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 678 | return -EINVAL; |
| 679 | } |
| 680 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 681 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 682 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 683 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 684 | return -EINVAL; |
| 685 | } |
| 686 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 687 | (chan_bw != CH_WIDTH_MAX)) { |
| 688 | hdd_err("Only BW20 possible on channel 14"); |
| 689 | return -EINVAL; |
| 690 | } |
| 691 | } |
| 692 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 693 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 694 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 695 | (chan_bw != CH_WIDTH_MAX)) { |
| 696 | hdd_err("Only BW20 possible on channel 165"); |
| 697 | return -EINVAL; |
| 698 | } |
| 699 | } |
| 700 | |
| 701 | return 0; |
| 702 | } |
| 703 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 704 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 705 | unsigned long state, void *data) |
| 706 | { |
| 707 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 708 | struct netdev_notifier_info *dev_notif_info = data; |
| 709 | struct net_device *dev = dev_notif_info->dev; |
| 710 | #else |
| 711 | struct net_device *dev = data; |
| 712 | #endif |
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 | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 717 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 718 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 719 | if (!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. */ |
| 736 | adapter = hdd_get_adapter_by_iface_name(hdd_ctx, dev->name); |
| 737 | if (!adapter) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 738 | hdd_debug("failed to look up adapter for '%s'", 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 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 742 | if (adapter != WLAN_HDD_GET_PRIV_PTR(dev)) { |
| 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 | |
| 757 | hdd_debug("%s New Net Device State = %lu", 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, |
| 785 | adapter->session_id, INVALID_SCAN_ID, |
| 786 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 787 | } |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 788 | hdd_objmgr_put_vdev(adapter); |
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 */ |
| 791 | wlan_hdd_cfg80211_scan_block_cb(&adapter->scan_block_work); |
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 | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 799 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, 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 |
| 813 | * @ndev: ndev pointer |
| 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, |
| 819 | void *ndev) |
| 820 | { |
| 821 | int ret; |
| 822 | |
| 823 | cds_ssr_protect(__func__); |
| 824 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 825 | cds_ssr_unprotect(__func__); |
| 826 | |
| 827 | return ret; |
| 828 | } |
| 829 | |
| 830 | struct notifier_block hdd_netdev_notifier = { |
| 831 | .notifier_call = hdd_netdev_notifier_call, |
| 832 | }; |
| 833 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 834 | static int system_reboot_notifier_call(struct notifier_block *nb, |
| 835 | unsigned long msg_type, void *_unused) |
| 836 | { |
| 837 | switch (msg_type) { |
| 838 | case SYS_DOWN: |
| 839 | case SYS_HALT: |
| 840 | case SYS_POWER_OFF: |
| 841 | g_is_system_reboot_triggered = true; |
| 842 | hdd_info("reboot, reason: %ld", msg_type); |
| 843 | break; |
| 844 | default: |
| 845 | break; |
| 846 | } |
| 847 | |
| 848 | return NOTIFY_OK; |
| 849 | } |
| 850 | |
| 851 | struct notifier_block system_reboot_notifier = { |
| 852 | .notifier_call = system_reboot_notifier_call, |
| 853 | }; |
| 854 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 855 | /* variable to hold the insmod parameters */ |
| 856 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 857 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 858 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 859 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 860 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 861 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 862 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 863 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 864 | /** |
| 865 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 866 | * @ch_width: NL channel width |
| 867 | * |
| 868 | * Converts the NL channel width to the driver's internal representation |
| 869 | * |
| 870 | * Return: Converted channel width. In case of non matching NL channel width, |
| 871 | * CH_WIDTH_MAX will be returned. |
| 872 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 873 | 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] | 874 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 875 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 876 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 877 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 878 | switch (ch_width) { |
| 879 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 880 | case NL80211_CHAN_WIDTH_20: |
| 881 | return CH_WIDTH_20MHZ; |
| 882 | case NL80211_CHAN_WIDTH_40: |
| 883 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 884 | case NL80211_CHAN_WIDTH_80: |
| 885 | return CH_WIDTH_80MHZ; |
| 886 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 887 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 888 | return CH_WIDTH_80P80MHZ; |
| 889 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 890 | return CH_WIDTH_160MHZ; |
| 891 | else |
| 892 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 893 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 894 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 895 | return CH_WIDTH_160MHZ; |
| 896 | else |
| 897 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 898 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 899 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 900 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 901 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 902 | default: |
| 903 | hdd_err("Invalid channel width %d, setting to default", |
| 904 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 905 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 906 | } |
| 907 | } |
| 908 | |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 909 | QDF_STATUS hdd_nl_to_qdf_iface_type(enum nl80211_iftype nl_type, |
| 910 | enum QDF_OPMODE *out_qdf_type) |
| 911 | { |
| 912 | switch (nl_type) { |
| 913 | case NL80211_IFTYPE_ADHOC: |
| 914 | *out_qdf_type = QDF_IBSS_MODE; |
| 915 | break; |
| 916 | case NL80211_IFTYPE_AP: |
| 917 | *out_qdf_type = QDF_SAP_MODE; |
| 918 | break; |
| 919 | case NL80211_IFTYPE_MONITOR: |
| 920 | *out_qdf_type = QDF_MONITOR_MODE; |
| 921 | break; |
| 922 | case NL80211_IFTYPE_OCB: |
| 923 | *out_qdf_type = QDF_OCB_MODE; |
| 924 | break; |
| 925 | case NL80211_IFTYPE_P2P_CLIENT: |
| 926 | *out_qdf_type = QDF_P2P_CLIENT_MODE; |
| 927 | break; |
| 928 | case NL80211_IFTYPE_P2P_DEVICE: |
| 929 | *out_qdf_type = QDF_P2P_DEVICE_MODE; |
| 930 | break; |
| 931 | case NL80211_IFTYPE_P2P_GO: |
| 932 | *out_qdf_type = QDF_P2P_GO_MODE; |
| 933 | break; |
| 934 | case NL80211_IFTYPE_STATION: |
| 935 | *out_qdf_type = QDF_STA_MODE; |
| 936 | break; |
| 937 | case NL80211_IFTYPE_WDS: |
| 938 | *out_qdf_type = QDF_WDS_MODE; |
| 939 | break; |
| 940 | default: |
| 941 | hdd_err("Invalid nl80211 interface type %d", nl_type); |
| 942 | return QDF_STATUS_E_INVAL; |
| 943 | } |
| 944 | |
| 945 | return QDF_STATUS_SUCCESS; |
| 946 | } |
| 947 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 948 | uint8_t wlan_hdd_find_opclass(mac_handle_t mac_handle, uint8_t channel, |
| 949 | uint8_t bw_offset) |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 950 | { |
| 951 | uint8_t opclass = 0; |
| 952 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 953 | sme_get_opclass(mac_handle, channel, bw_offset, &opclass); |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 954 | return opclass; |
| 955 | } |
| 956 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 957 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 958 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 959 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 960 | * @bitmask: Bitmask of log levels to be enabled |
| 961 | * |
| 962 | * Called immediately after the cfg.ini is read in order to configure |
| 963 | * the desired trace levels. |
| 964 | * |
| 965 | * Return: None |
| 966 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 967 | 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] | 968 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 969 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 970 | int qdf_print_idx = -1; |
| 971 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 972 | /* |
| 973 | * if the bitmask is the default value, then a bitmask was not |
| 974 | * specified in cfg.ini, so leave the logging level alone (it |
| 975 | * will remain at the "compiled in" default value) |
| 976 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 977 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 978 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 979 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 980 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 981 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 982 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 983 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 984 | QDF_TRACE_LEVEL_NONE, 0); |
| 985 | |
| 986 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 987 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 988 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 989 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 990 | while (0 != bitmask) { |
| 991 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 992 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 993 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 994 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 995 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 996 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 997 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 998 | level++; |
| 999 | bitmask >>= 1; |
| 1000 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1001 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1002 | } |
| 1003 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1004 | 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] | 1005 | { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1006 | if (!hdd_ctx) { |
| 1007 | hdd_err("HDD context is null (via %s)", func); |
| 1008 | return -ENODEV; |
| 1009 | } |
| 1010 | |
| 1011 | if (!hdd_ctx->config) { |
| 1012 | hdd_err("HDD config is null (via %s)", func); |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 1013 | return -ENODEV; |
| 1014 | } |
| 1015 | |
| 1016 | if (cds_is_driver_recovering()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1017 | hdd_debug("Recovery in progress (via %s); state:0x%x", |
| 1018 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1019 | return -EAGAIN; |
| 1020 | } |
| 1021 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 1022 | if (cds_is_load_or_unload_in_progress()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1023 | hdd_debug("Load/unload in progress (via %s); state:0x%x", |
| 1024 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1025 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 1026 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1027 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1028 | if (hdd_ctx->start_modules_in_progress) { |
| 1029 | hdd_debug("Start modules in progress (via %s)", func); |
| 1030 | return -EAGAIN; |
| 1031 | } |
| 1032 | |
| 1033 | if (hdd_ctx->stop_modules_in_progress) { |
| 1034 | hdd_debug("Stop modules in progress (via %s)", func); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1035 | return -EAGAIN; |
| 1036 | } |
| 1037 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1038 | if (cds_is_driver_in_bad_state()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1039 | hdd_debug("Driver in bad state (via %s); state:0x%x", |
| 1040 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 1041 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1042 | } |
| 1043 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 1044 | if (cds_is_fw_down()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1045 | hdd_debug("FW is down (via %s); state:0x%x", |
| 1046 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 1047 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 1048 | } |
| 1049 | |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 1050 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1051 | hdd_debug("Driver mode change in progress (via %s)", func); |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 1052 | return -EAGAIN; |
| 1053 | } |
| 1054 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1055 | return 0; |
| 1056 | } |
| 1057 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1058 | int __hdd_validate_adapter(struct hdd_adapter *adapter, const char *func) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1059 | { |
| 1060 | if (!adapter) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1061 | hdd_err("adapter is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1062 | return -EINVAL; |
| 1063 | } |
| 1064 | |
| 1065 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1066 | hdd_err("bad adapter magic (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1067 | return -EINVAL; |
| 1068 | } |
| 1069 | |
| 1070 | if (!adapter->dev) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1071 | hdd_err("adapter net_device is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1072 | return -EINVAL; |
| 1073 | } |
| 1074 | |
| 1075 | if (!(adapter->dev->flags & IFF_UP)) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1076 | hdd_debug_rl("adapter '%s' is not up (via %s)", |
| 1077 | adapter->dev->name, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1078 | return -EAGAIN; |
| 1079 | } |
| 1080 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1081 | return __wlan_hdd_validate_session_id(adapter->session_id, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1082 | } |
| 1083 | |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 1084 | int __wlan_hdd_validate_session_id(uint8_t session_id, const char *func) |
| 1085 | { |
| 1086 | if (session_id == CSR_SESSION_ID_INVALID) { |
| 1087 | hdd_debug_rl("adapter is not up (via %s)", func); |
| 1088 | return -EINVAL; |
| 1089 | } |
| 1090 | |
| 1091 | if (session_id >= CSR_ROAM_SESSION_MAX) { |
| 1092 | hdd_err("bad session Id:%u (via %s)", session_id, func); |
| 1093 | return -EINVAL; |
| 1094 | } |
| 1095 | |
| 1096 | return 0; |
| 1097 | } |
| 1098 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 1099 | QDF_STATUS __wlan_hdd_validate_mac_address(struct qdf_mac_addr *mac_addr, |
| 1100 | const char *func) |
| 1101 | { |
| 1102 | if (!mac_addr) { |
| 1103 | hdd_err("Received NULL mac address (via %s)", func); |
| 1104 | return QDF_STATUS_E_INVAL; |
| 1105 | } |
| 1106 | |
| 1107 | if (qdf_is_macaddr_zero(mac_addr)) { |
| 1108 | hdd_err("MAC is all zero (via %s)", func); |
| 1109 | return QDF_STATUS_E_INVAL; |
| 1110 | } |
| 1111 | |
| 1112 | if (qdf_is_macaddr_broadcast(mac_addr)) { |
| 1113 | hdd_err("MAC is Broadcast (via %s)", func); |
| 1114 | return QDF_STATUS_E_INVAL; |
| 1115 | } |
| 1116 | |
| 1117 | if (QDF_NET_IS_MAC_MULTICAST(mac_addr->bytes)) { |
| 1118 | hdd_err("MAC is Multicast (via %s)", func); |
| 1119 | return QDF_STATUS_E_INVAL; |
| 1120 | } |
| 1121 | |
| 1122 | return QDF_STATUS_SUCCESS; |
| 1123 | } |
| 1124 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1125 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1126 | * wlan_hdd_validate_modules_state() - Check modules status |
| 1127 | * @hdd_ctx: HDD context pointer |
| 1128 | * |
| 1129 | * Check's the driver module's state and returns true if the |
| 1130 | * modules are enabled returns false if modules are closed. |
| 1131 | * |
| 1132 | * Return: True if modules are enabled or false. |
| 1133 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1134 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1135 | { |
| 1136 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 1137 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1138 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 1139 | hdd_info("Modules not enabled, Present status: %d", |
| 1140 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1141 | return false; |
| 1142 | } |
| 1143 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 1144 | return true; |
| 1145 | } |
| 1146 | |
| 1147 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1148 | * 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] | 1149 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1150 | * |
| 1151 | * This function sets the IBSS power save config parameters to WMA |
| 1152 | * which will send it to firmware if FW supports IBSS power save |
| 1153 | * before vdev start. |
| 1154 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1155 | * 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] | 1156 | * on failure. |
| 1157 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1158 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1159 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1160 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1161 | |
| 1162 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1163 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1164 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1165 | } |
| 1166 | |
Manikandan Mohan | 2bd0977 | 2018-11-28 18:27:32 -0800 | [diff] [blame] | 1167 | return ucfg_mlme_ibss_power_save_setup(hdd_ctx->psoc, |
| 1168 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1169 | } |
| 1170 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1171 | #ifdef FEATURE_RUNTIME_PM |
| 1172 | /** |
| 1173 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1174 | * @hdd_ctx: HDD context |
| 1175 | * |
| 1176 | * Return: None |
| 1177 | */ |
| 1178 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1179 | { |
| 1180 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1181 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1182 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1183 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1184 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1185 | wlan_scan_runtime_pm_init(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | /** |
| 1189 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1190 | * @hdd_ctx: HDD Context |
| 1191 | * |
| 1192 | * Return: None |
| 1193 | */ |
| 1194 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1195 | { |
| 1196 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1197 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1198 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1199 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1200 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1201 | wlan_scan_runtime_pm_deinit(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1202 | } |
| 1203 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1204 | #else /* FEATURE_RUNTIME_PM */ |
| 1205 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1206 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1207 | #endif /* FEATURE_RUNTIME_PM */ |
| 1208 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1209 | #define INTF_MACADDR_MASK 0x7 |
| 1210 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1211 | void hdd_update_macaddr(struct hdd_context *hdd_ctx, |
| 1212 | struct qdf_mac_addr hw_macaddr, bool generate_mac_auto) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1213 | { |
| 1214 | int8_t i; |
| 1215 | uint8_t macaddr_b3, tmp_br3; |
| 1216 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1217 | /* |
| 1218 | * If "generate_mac_auto" is true, it indicates that all the |
| 1219 | * addresses are derived addresses, else the first addresses |
| 1220 | * is not derived address (It is provided by fw). |
| 1221 | */ |
| 1222 | if (!generate_mac_auto) { |
| 1223 | qdf_mem_copy(hdd_ctx->provisioned_mac_addr[0].bytes, |
| 1224 | hw_macaddr.bytes, QDF_MAC_ADDR_SIZE); |
| 1225 | hdd_ctx->num_provisioned_addr++; |
| 1226 | hdd_info("hdd_ctx->provisioned_mac_addr[0]: " |
| 1227 | MAC_ADDRESS_STR, |
| 1228 | MAC_ADDR_ARRAY(hdd_ctx-> |
| 1229 | provisioned_mac_addr[0].bytes)); |
| 1230 | } else { |
| 1231 | qdf_mem_copy(hdd_ctx->derived_mac_addr[0].bytes, |
| 1232 | hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1233 | QDF_MAC_ADDR_SIZE); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1234 | hdd_ctx->num_derived_addr++; |
| 1235 | hdd_info("hdd_ctx->derived_mac_addr[0]: " |
| 1236 | MAC_ADDRESS_STR, |
| 1237 | MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[0].bytes)); |
| 1238 | } |
| 1239 | for (i = hdd_ctx->num_derived_addr; i < (QDF_MAX_CONCURRENCY_PERSONA - |
| 1240 | hdd_ctx->num_provisioned_addr); |
| 1241 | i++) { |
| 1242 | qdf_mem_copy(hdd_ctx->derived_mac_addr[i].bytes, |
| 1243 | hw_macaddr.bytes, |
| 1244 | QDF_MAC_ADDR_SIZE); |
| 1245 | macaddr_b3 = hdd_ctx->derived_mac_addr[i].bytes[3]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1246 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1247 | INTF_MACADDR_MASK; |
| 1248 | macaddr_b3 += tmp_br3; |
| 1249 | |
| 1250 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1251 | * mac address range before collision |
| 1252 | */ |
| 1253 | macaddr_b3 ^= (1 << 7); |
| 1254 | |
| 1255 | /* Set locally administered bit */ |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1256 | hdd_ctx->derived_mac_addr[i].bytes[0] |= 0x02; |
| 1257 | hdd_ctx->derived_mac_addr[i].bytes[3] = macaddr_b3; |
| 1258 | hdd_info("hdd_ctx->derived_mac_addr[%d]: " |
| 1259 | MAC_ADDRESS_STR, i, |
| 1260 | MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes)); |
| 1261 | hdd_ctx->num_derived_addr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1262 | } |
| 1263 | } |
| 1264 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1265 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1266 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1267 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1268 | struct tdls_start_params tdls_cfg; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1269 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1270 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 1271 | |
| 1272 | /* Populate the nss chain params from ini for this vdev type */ |
| 1273 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 1274 | QDF_TDLS_MODE, |
| 1275 | hdd_ctx->num_rf_chains); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1276 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1277 | cfg_tdls_set_vdev_nss_2g(hdd_ctx->psoc, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1278 | vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1279 | cfg_tdls_set_vdev_nss_5g(hdd_ctx->psoc, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1280 | vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]); |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1281 | hdd_init_tdls_config(&tdls_cfg); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1282 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1283 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1284 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1285 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1286 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1287 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1288 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1289 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1290 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1291 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1292 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1293 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1294 | |
| 1295 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1296 | if (status != QDF_STATUS_SUCCESS) { |
| 1297 | hdd_err("failed pmo psoc configuration"); |
| 1298 | return -EINVAL; |
| 1299 | } |
| 1300 | |
| 1301 | hdd_ctx->tdls_umac_comp_active = true; |
| 1302 | /* enable napier specific tdls data path */ |
| 1303 | hdd_ctx->tdls_nap_active = true; |
| 1304 | |
| 1305 | return 0; |
| 1306 | } |
| 1307 | |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1308 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1309 | static void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1310 | struct wma_tgt_services *cfg) |
| 1311 | { |
| 1312 | bool roam_offload_enable; |
| 1313 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1314 | ucfg_mlme_get_roaming_offload(hdd_ctx->psoc, &roam_offload_enable); |
| 1315 | ucfg_mlme_set_roaming_offload(hdd_ctx->psoc, |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1316 | roam_offload_enable & |
| 1317 | cfg->en_roam_offload); |
| 1318 | } |
| 1319 | #else |
| 1320 | static inline void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1321 | struct wma_tgt_services *cfg) |
| 1322 | { |
| 1323 | } |
| 1324 | #endif |
| 1325 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1326 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1327 | struct wma_tgt_services *cfg) |
| 1328 | { |
| 1329 | struct hdd_config *config = hdd_ctx->config; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1330 | bool arp_offload_enable; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1331 | bool mawc_enabled; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1332 | #ifdef FEATURE_WLAN_TDLS |
| 1333 | bool tdls_support; |
| 1334 | bool tdls_off_channel; |
| 1335 | bool tdls_buffer_sta; |
| 1336 | uint32_t tdls_uapsd_mask; |
| 1337 | #endif |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1338 | bool value; |
| 1339 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1340 | /* Set up UAPSD */ |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 1341 | ucfg_mlme_set_sap_uapsd_flag(hdd_ctx->psoc, cfg->uapsd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1342 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1343 | /* 11AX mode support */ |
| 1344 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1345 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1346 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1347 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1348 | /* 11AC mode support */ |
| 1349 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1350 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1351 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1352 | |
| 1353 | /* ARP offload: override user setting if invalid */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1354 | arp_offload_enable = |
| 1355 | ucfg_pmo_is_arp_offload_enabled(hdd_ctx->psoc); |
| 1356 | ucfg_pmo_set_arp_offload_enabled(hdd_ctx->psoc, |
| 1357 | arp_offload_enable & cfg->arp_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1358 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1359 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1360 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1361 | if (cfg->pno_offload) |
Pragaspathi Thilagaraj | 24789d3 | 2018-12-10 22:28:03 +0530 | [diff] [blame] | 1362 | ucfg_scan_set_pno_offload(hdd_ctx->psoc, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1363 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1364 | #ifdef FEATURE_WLAN_TDLS |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1365 | cfg_tdls_get_support_enable(hdd_ctx->psoc, &tdls_support); |
| 1366 | cfg_tdls_set_support_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1367 | tdls_support & cfg->en_tdls); |
| 1368 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1369 | cfg_tdls_get_off_channel_enable(hdd_ctx->psoc, &tdls_off_channel); |
| 1370 | cfg_tdls_set_off_channel_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1371 | tdls_off_channel && |
| 1372 | cfg->en_tdls_offchan); |
| 1373 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1374 | cfg_tdls_get_buffer_sta_enable(hdd_ctx->psoc, &tdls_buffer_sta); |
| 1375 | cfg_tdls_set_buffer_sta_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1376 | tdls_buffer_sta && |
| 1377 | cfg->en_tdls_uapsd_buf_sta); |
| 1378 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1379 | cfg_tdls_get_uapsd_mask(hdd_ctx->psoc, &tdls_uapsd_mask); |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1380 | if (tdls_uapsd_mask && cfg->en_tdls_uapsd_sleep_sta) |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1381 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, true); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1382 | else |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1383 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1384 | #endif |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1385 | hdd_update_roam_offload(hdd_ctx, cfg); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1386 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 1387 | if (ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value) == |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1388 | QDF_STATUS_SUCCESS) |
| 1389 | value &= cfg->get_peer_info_enabled; |
| 1390 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1391 | ucfg_mlme_is_mawc_enabled(hdd_ctx->psoc, &mawc_enabled); |
| 1392 | ucfg_mlme_set_mawc_enabled(hdd_ctx->psoc, |
| 1393 | mawc_enabled & cfg->is_fw_mawc_capable); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1394 | hdd_update_tdls_config(hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1395 | sme_update_tgt_services(hdd_ctx->mac_handle, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1396 | } |
| 1397 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1398 | /** |
| 1399 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1400 | * @hdd_ctx: HDD context |
| 1401 | * |
| 1402 | * Sets the Nss per vdev type based on INI |
| 1403 | * |
| 1404 | * Return: None |
| 1405 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1406 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1407 | { |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1408 | uint8_t max_supp_nss = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1409 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1410 | QDF_STATUS status; |
| 1411 | bool bval; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1412 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1413 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1414 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1415 | hdd_err("unable to get vht_enable2x2"); |
| 1416 | |
| 1417 | if (bval && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1418 | max_supp_nss = 2; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1419 | |
| 1420 | hdd_debug("max nss %d", max_supp_nss); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1421 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1422 | mac_handle = hdd_ctx->mac_handle; |
| 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_2GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1425 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1426 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1427 | NSS_CHAINS_BAND_5GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1428 | } |
| 1429 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1430 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1431 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1432 | * @hdd_ctx: HDD context |
| 1433 | * |
| 1434 | * Updates wiphy vhtcap fields |
| 1435 | * |
| 1436 | * Return: None |
| 1437 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1438 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1439 | { |
| 1440 | struct ieee80211_supported_band *band_5g = |
| 1441 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1442 | QDF_STATUS status; |
| 1443 | uint8_t value = 0, value1 = 0; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1444 | |
| 1445 | if (!band_5g) { |
| 1446 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1447 | return; |
| 1448 | } |
| 1449 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1450 | status = ucfg_mlme_cfg_get_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 1451 | &value); |
| 1452 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1453 | hdd_err("unable to get tx_bfee_ant_supp"); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1454 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1455 | band_5g->vht_cap.cap |= |
| 1456 | (value << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1457 | |
| 1458 | value1 = NUM_OF_SOUNDING_DIMENSIONS; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1459 | band_5g->vht_cap.cap |= |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1460 | (value1 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1461 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 1462 | hdd_debug("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1463 | band_5g->vht_cap.cap, value, value1); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1464 | } |
| 1465 | |
| 1466 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1467 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1468 | * @hdd_ctx: HDD context |
| 1469 | * |
| 1470 | * Sets the DBS capability as per INI and firmware capability |
| 1471 | * |
| 1472 | * Return: None |
| 1473 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1474 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1475 | { |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1476 | uint8_t hw_dbs_capable = 0; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 1477 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
| 1478 | QDF_STATUS status; |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1479 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 1480 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 1481 | &dual_mac_feature); |
| 1482 | if (status != QDF_STATUS_SUCCESS) |
| 1483 | hdd_err("can't get dual_mac_feature value"); |
| 1484 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc)) { |
| 1485 | switch (dual_mac_feature) { |
| 1486 | case ENABLE_DBS_CXN_AND_SCAN: |
| 1487 | case ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF: |
| 1488 | case ENABLE_DBS_CXN_AND_DISABLE_SIMULTANEOUS_SCAN: |
| 1489 | hw_dbs_capable = 1; |
| 1490 | break; |
| 1491 | default: |
| 1492 | hw_dbs_capable = 0; |
| 1493 | break; |
| 1494 | } |
| 1495 | } |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1496 | sme_update_hw_dbs_capable(hdd_ctx->mac_handle, hw_dbs_capable); |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1497 | } |
| 1498 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1499 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1500 | struct wma_tgt_ht_cap *cfg) |
| 1501 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1502 | QDF_STATUS status; |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1503 | qdf_size_t value_len; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1504 | uint32_t value; |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1505 | uint8_t mpdu_density; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1506 | struct mlme_ht_capabilities_info ht_cap_info; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1507 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1508 | bool b_enable1x1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1509 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1510 | /* get the MPDU density */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1511 | status = ucfg_mlme_get_ht_mpdu_density(hdd_ctx->psoc, &mpdu_density); |
| 1512 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1513 | hdd_err("could not get HT MPDU Density"); |
| 1514 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1515 | } |
| 1516 | |
| 1517 | /* |
| 1518 | * MPDU density: |
| 1519 | * override user's setting if value is larger |
| 1520 | * than the one supported by target |
| 1521 | */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1522 | if (mpdu_density > cfg->mpdu_density) { |
| 1523 | status = ucfg_mlme_set_ht_mpdu_density(hdd_ctx->psoc, |
| 1524 | cfg->mpdu_density); |
| 1525 | if (QDF_IS_STATUS_ERROR(status)) |
| 1526 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1527 | } |
| 1528 | |
| 1529 | /* get the HT capability info */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1530 | 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] | 1531 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1532 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1533 | return; |
| 1534 | } |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1535 | |
| 1536 | /* check and update RX STBC */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1537 | if (ht_cap_info.rx_stbc && !cfg->ht_rx_stbc) |
| 1538 | ht_cap_info.rx_stbc = cfg->ht_rx_stbc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1539 | |
| 1540 | /* Set the LDPC capability */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1541 | ht_cap_info.adv_coding_cap = cfg->ht_rx_ldpc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1542 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1543 | if (ht_cap_info.short_gi_20_mhz && !cfg->ht_sgi_20) |
| 1544 | ht_cap_info.short_gi_20_mhz = cfg->ht_sgi_20; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1545 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1546 | if (ht_cap_info.short_gi_40_mhz && !cfg->ht_sgi_40) |
| 1547 | ht_cap_info.short_gi_40_mhz = cfg->ht_sgi_40; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1548 | |
| 1549 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1550 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1551 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1552 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &b_enable1x1); |
| 1553 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1554 | hdd_err("unable to get vht_enable2x2"); |
| 1555 | |
| 1556 | b_enable1x1 = b_enable1x1 && (cfg->num_rf_chains == 2); |
| 1557 | |
| 1558 | status = ucfg_mlme_set_vht_enable2x2(hdd_ctx->psoc, b_enable1x1); |
| 1559 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1560 | hdd_err("unable to set vht_enable2x2"); |
| 1561 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1562 | if (!b_enable1x1) { |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1563 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1564 | |
| 1565 | /* 1x1 */ |
| 1566 | /* Update Rx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1567 | status = ucfg_mlme_cfg_set_vht_rx_supp_data_rate( |
| 1568 | hdd_ctx->psoc, |
| 1569 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1570 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1571 | hdd_err("Failed to set rx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1572 | /* Update Tx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1573 | status = ucfg_mlme_cfg_set_vht_tx_supp_data_rate( |
| 1574 | hdd_ctx->psoc, |
| 1575 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1576 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1577 | hdd_err("Failed to set tx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1578 | } |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1579 | if (!(cfg->ht_tx_stbc && b_enable1x1)) |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1580 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1581 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1582 | 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] | 1583 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1584 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1585 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1586 | value_len = SIZE_OF_SUPPORTED_MCS_SET; |
| 1587 | if (ucfg_mlme_get_supported_mcs_set( |
| 1588 | hdd_ctx->psoc, mcs_set, |
| 1589 | &value_len) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1590 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1591 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1592 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1593 | |
| 1594 | if (b_enable1x1) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1595 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1596 | mcs_set[value] = |
| 1597 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1598 | |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1599 | status = ucfg_mlme_set_supported_mcs_set( |
| 1600 | hdd_ctx->psoc, |
| 1601 | mcs_set, |
| 1602 | (qdf_size_t)SIZE_OF_SUPPORTED_MCS_SET); |
| 1603 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1604 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1605 | } |
| 1606 | } |
| 1607 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1608 | } |
| 1609 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1610 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1611 | struct wma_tgt_vht_cap *cfg) |
| 1612 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1613 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1614 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1615 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1616 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1617 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1618 | struct wma_caps_per_phy caps_per_phy; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1619 | uint8_t val = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1620 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1621 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1622 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1623 | return; |
| 1624 | } |
| 1625 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1626 | status = ucfg_mlme_update_vht_cap(hdd_ctx->psoc, cfg); |
| 1627 | if (QDF_IS_STATUS_ERROR(status)) |
| 1628 | hdd_err("could not update vht capabilities"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1629 | |
| 1630 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1631 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1632 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1633 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1634 | else |
| 1635 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1636 | |
| 1637 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1638 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1639 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1640 | VHT_CAP_160_AND_80P80_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1641 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1642 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1643 | band_5g->vht_cap.cap |= |
| 1644 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1645 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1646 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1647 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1648 | VHT_CAP_160_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1649 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1650 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1651 | band_5g->vht_cap.cap |= |
| 1652 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1653 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1654 | } |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1655 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1656 | status = |
| 1657 | ucfg_mlme_cfg_get_vht_chan_width(hdd_ctx->psoc, &val); |
| 1658 | if (QDF_IS_STATUS_ERROR(status)) |
| 1659 | hdd_err("could not get channel_width"); |
| 1660 | |
| 1661 | val = QDF_MIN(val, ch_width); |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1662 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, val); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1663 | if (QDF_IS_STATUS_ERROR(status)) |
| 1664 | hdd_err("could not set the channel width"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1665 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1666 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1667 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1668 | hdd_debug("VHT RxLDPC capability is set"); |
| 1669 | } else { |
| 1670 | /* |
| 1671 | * Get the RX LDPC capability for the NON DBS |
| 1672 | * hardware mode for 5G band |
| 1673 | */ |
| 1674 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1675 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1676 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1677 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1678 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1679 | hdd_debug("VHT RX LDPC capability is set"); |
| 1680 | } |
| 1681 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1682 | |
| 1683 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1684 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1685 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1686 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1687 | |
| 1688 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1689 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1690 | |
| 1691 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1692 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1693 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1694 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1695 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1696 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1697 | |
| 1698 | band_5g->vht_cap.cap |= |
| 1699 | (cfg->vht_max_ampdu_len_exp << |
| 1700 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1701 | |
| 1702 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1703 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1704 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1705 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1706 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1707 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1708 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1709 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1710 | |
| 1711 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1712 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1713 | |
| 1714 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1715 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1716 | /** |
| 1717 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1718 | * @hdd_ctx: Pointer to the HDD context |
| 1719 | * |
| 1720 | * Auto-generate mac address using device serial number. |
| 1721 | * Keep the first 3 bytes of OUI as before and replace |
| 1722 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1723 | * |
| 1724 | * Return: 0 for success |
| 1725 | * Non zero failure code for errors |
| 1726 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1727 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1728 | { |
| 1729 | unsigned int serialno = 0; |
| 1730 | struct qdf_mac_addr mac_addr = { |
| 1731 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1732 | }; |
| 1733 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1734 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1735 | if (serialno == 0) |
| 1736 | return -EINVAL; |
| 1737 | |
| 1738 | serialno &= 0x00ffffff; |
| 1739 | |
| 1740 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1741 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1742 | mac_addr.bytes[5] = serialno & 0xff; |
| 1743 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1744 | hdd_update_macaddr(hdd_ctx, mac_addr, true); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1745 | return 0; |
| 1746 | } |
| 1747 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1748 | /** |
| 1749 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1750 | * configuration to cfg_ini in HDD |
| 1751 | * @hdd_ctx: Pointer to hdd_ctx |
| 1752 | * @cfg: target configuration |
| 1753 | * |
| 1754 | * Return: None |
| 1755 | */ |
| 1756 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1757 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1758 | struct wma_tgt_cfg *cfg) |
| 1759 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 1760 | ucfg_fwol_set_is_rate_limit_enabled(hdd_ctx->psoc, |
| 1761 | cfg->is_ra_rate_limit_enabled); |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1762 | } |
| 1763 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1764 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1765 | struct wma_tgt_cfg *cfg) |
| 1766 | { |
| 1767 | } |
| 1768 | #endif |
| 1769 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1770 | static void hdd_sar_target_config(struct hdd_context *hdd_ctx, |
| 1771 | struct wma_tgt_cfg *cfg) |
| 1772 | { |
| 1773 | hdd_ctx->sar_version = cfg->sar_version; |
| 1774 | } |
| 1775 | |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1776 | static void hdd_update_vhtcap_2g(struct hdd_context *hdd_ctx) |
| 1777 | { |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1778 | uint32_t chip_mode = 0; |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1779 | QDF_STATUS status; |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1780 | bool b2g_vht_cfg = false; |
| 1781 | bool b2g_vht_target = false; |
| 1782 | struct wma_caps_per_phy caps_per_phy; |
| 1783 | struct wmi_unified *wmi_handle; |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1784 | |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1785 | wmi_handle = get_wmi_unified_hdl_from_psoc(hdd_ctx->psoc); |
| 1786 | if (!wmi_handle) { |
| 1787 | hdd_err("wmi handle is NULL"); |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1788 | return; |
| 1789 | } |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1790 | |
| 1791 | 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] | 1792 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1793 | hdd_err("Failed to get 2g vht mode"); |
| 1794 | return; |
| 1795 | } |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1796 | if (wmi_service_enabled(wmi_handle, wmi_service_ext_msg)) { |
| 1797 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1798 | HW_MODE_DBS_NONE, |
| 1799 | CDS_BAND_ALL); |
| 1800 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1801 | hdd_err("Failed to get phy caps"); |
| 1802 | return; |
| 1803 | } |
| 1804 | if (caps_per_phy.vht_2g) |
| 1805 | b2g_vht_target = true; |
| 1806 | } else { |
| 1807 | status = wlan_reg_get_chip_mode(hdd_ctx->pdev, &chip_mode); |
| 1808 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1809 | hdd_err("Failed to get chip mode"); |
| 1810 | return; |
| 1811 | } |
| 1812 | b2g_vht_target = |
| 1813 | (chip_mode & WMI_HOST_REGDMN_MODE_11AC_VHT20_2G) ? |
| 1814 | true : false; |
| 1815 | } |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1816 | |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1817 | b2g_vht_cfg = b2g_vht_cfg && b2g_vht_target; |
| 1818 | hdd_debug("vht 2g target: %d, cfg: %d", b2g_vht_target, b2g_vht_cfg); |
| 1819 | 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] | 1820 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1821 | hdd_err("Failed to update 2g vht mode"); |
| 1822 | return; |
| 1823 | } |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1824 | } |
| 1825 | |
Jeff Johnson | 8abc593 | 2018-06-02 22:51:37 -0700 | [diff] [blame] | 1826 | 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] | 1827 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1828 | int ret; |
Jeff Johnson | ea70b94 | 2018-07-02 09:42:31 -0700 | [diff] [blame] | 1829 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1830 | uint8_t temp_band_cap, band_capability; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1831 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1832 | uint8_t antenna_mode; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1833 | uint8_t sub_20_chan_width; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1834 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1835 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1836 | bool bval = false; |
| 1837 | uint8_t value = 0; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1838 | uint32_t fine_time_meas_cap = 0; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1839 | |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1840 | if (!hdd_ctx) { |
| 1841 | hdd_err("HDD context is NULL"); |
| 1842 | return; |
| 1843 | } |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1844 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1845 | if (ret) { |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1846 | QDF_DEBUG_PANIC("Failed to create pdev; errno:%d", ret); |
| 1847 | return; |
| 1848 | } |
| 1849 | |
| 1850 | hdd_debug("New pdev has been created with pdev_id = %u", |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1851 | hdd_ctx->pdev->pdev_objmgr.wlan_pdev_id); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1852 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1853 | status = dispatcher_pdev_open(hdd_ctx->pdev); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1854 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1855 | QDF_DEBUG_PANIC("dispatcher pdev open failed; status:%d", |
| 1856 | status); |
| 1857 | return; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1858 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1859 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 1860 | status = hdd_component_pdev_open(hdd_ctx->pdev); |
| 1861 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1862 | QDF_DEBUG_PANIC("hdd component pdev open failed; status:%d", |
| 1863 | status); |
| 1864 | return; |
| 1865 | } |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1866 | cdp_pdev_set_ctrl_pdev(cds_get_context(QDF_MODULE_ID_SOC), |
| 1867 | cds_get_context(QDF_MODULE_ID_TXRX), |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1868 | (struct cdp_ctrl_objmgr_pdev *)hdd_ctx->pdev); |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1869 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1870 | wlan_pdev_set_dp_handle(hdd_ctx->pdev, |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1871 | cds_get_context(QDF_MODULE_ID_TXRX)); |
| 1872 | |
Will Huang | 0724417 | 2018-05-14 14:23:30 +0800 | [diff] [blame] | 1873 | hdd_objmgr_update_tgt_max_vdev_psoc(hdd_ctx, cfg->max_intf_count); |
| 1874 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1875 | ucfg_ipa_set_dp_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1876 | cds_get_context(QDF_MODULE_ID_SOC)); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1877 | ucfg_ipa_set_txrx_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1878 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1879 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1880 | hdd_softap_hard_start_xmit); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1881 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1882 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1883 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1884 | status = ucfg_mlme_get_sub_20_chan_width(hdd_ctx->psoc, |
| 1885 | &sub_20_chan_width); |
| 1886 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1887 | hdd_err("Failed to get sub_20_chan_width config"); |
| 1888 | return; |
| 1889 | } |
| 1890 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1891 | if (cds_cfg) { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1892 | if (sub_20_chan_width != |
| 1893 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1894 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1895 | cds_cfg->sub_20_channel_width = |
| 1896 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1897 | } else { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1898 | cds_cfg->sub_20_channel_width = sub_20_chan_width; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1899 | } |
| 1900 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1901 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1902 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 1903 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1904 | hdd_err("Failed to get MLME band capability"); |
| 1905 | return; |
| 1906 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1907 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1908 | /* first store the INI band capability */ |
| 1909 | temp_band_cap = band_capability; |
| 1910 | |
| 1911 | band_capability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1912 | hdd_ctx->is_fils_roaming_supported = |
| 1913 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1914 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1915 | hdd_ctx->config->is_11k_offload_supported = |
| 1916 | cfg->services.is_11k_offload_supported; |
| 1917 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1918 | /* |
| 1919 | * now overwrite the target band capability with INI |
| 1920 | * setting if INI setting is a subset |
| 1921 | */ |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1922 | if ((band_capability == BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1923 | (temp_band_cap != BAND_ALL)) |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1924 | band_capability = temp_band_cap; |
| 1925 | else if ((band_capability != BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1926 | (temp_band_cap != BAND_ALL) && |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1927 | (band_capability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1928 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1929 | } |
| 1930 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1931 | status = ucfg_mlme_set_band_capability(hdd_ctx->psoc, band_capability); |
| 1932 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1933 | hdd_err("Failed to set MLME Band Capability"); |
| 1934 | return; |
| 1935 | } |
| 1936 | |
| 1937 | hdd_ctx->curr_band = band_capability; |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1938 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1939 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1940 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1941 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1942 | } |
| 1943 | |
| 1944 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1945 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1946 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) |
| 1947 | qdf_mem_copy(&hdd_ctx->hw_macaddr, &cfg->hw_macaddr, |
| 1948 | QDF_MAC_ADDR_SIZE); |
| 1949 | else |
| 1950 | hdd_info("hw_mac is zero"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1951 | |
| 1952 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1953 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1954 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 1955 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 1956 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 1957 | sizeof(cfg->hw_bd_info)); |
| 1958 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 1959 | if (cfg->max_intf_count > CSR_ROAM_SESSION_MAX) { |
| 1960 | hdd_err("fw max vdevs (%u) > host max vdevs (%u); using %u", |
| 1961 | cfg->max_intf_count, CSR_ROAM_SESSION_MAX, |
| 1962 | CSR_ROAM_SESSION_MAX); |
| 1963 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 1964 | } else { |
| 1965 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1966 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1967 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1968 | hdd_sar_target_config(hdd_ctx, cfg); |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1969 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1970 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1971 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1972 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1973 | |
| 1974 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1975 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1976 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1977 | if (cfg->services.en_11ax) { |
| 1978 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1979 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1980 | } |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 1981 | hdd_update_tgt_twt_cap(hdd_ctx, cfg); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1982 | |
| 1983 | hdd_update_vdev_nss(hdd_ctx); |
| 1984 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1985 | hdd_update_hw_dbs_capable(hdd_ctx); |
gaurank kathpalia | 5fcefa9 | 2018-10-24 15:03:15 +0530 | [diff] [blame] | 1986 | hdd_ctx->dynamic_nss_chains_support = |
| 1987 | cfg->dynamic_nss_chains_support; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1988 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, &fine_time_meas_cap); |
| 1989 | fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
| 1990 | status = ucfg_mlme_set_fine_time_meas_cap(hdd_ctx->psoc, |
| 1991 | fine_time_meas_cap); |
| 1992 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1993 | hdd_err("failed to set fine_time_meas_cap, 0x%x, ox%x", |
| 1994 | fine_time_meas_cap, cfg->fine_time_measurement_cap); |
| 1995 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 1996 | &fine_time_meas_cap); |
| 1997 | } |
| 1998 | |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1999 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 2000 | hdd_debug("fine_time_meas_cap: 0x%x", fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2001 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2002 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 2003 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 2004 | hdd_err("unable to get vht_enable2x2"); |
| 2005 | |
| 2006 | antenna_mode = (bval == 0x01) ? |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 2007 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 2008 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2009 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2010 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2011 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 2012 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 2013 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 2014 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2015 | 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] | 2016 | &value); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2017 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2018 | status = false; |
| 2019 | hdd_err("set tx_bfee_ant_supp failed"); |
| 2020 | } |
| 2021 | |
| 2022 | if ((value > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2023 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2024 | !cfg->tx_bfee_8ss_enabled) { |
| 2025 | status = |
| 2026 | ucfg_mlme_cfg_set_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 2027 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF); |
| 2028 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2029 | status = false; |
| 2030 | hdd_err("set tx_bfee_ant_supp failed"); |
| 2031 | } |
| 2032 | } |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2033 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2034 | mac_handle = hdd_ctx->mac_handle; |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2035 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2036 | hdd_debug("txBFCsnValue %d", value); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2037 | |
| 2038 | /* |
| 2039 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2040 | */ |
| 2041 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2042 | |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 2043 | hdd_update_vhtcap_2g(hdd_ctx); |
| 2044 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2045 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2046 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 2047 | /* |
| 2048 | * This needs to be done after HDD pdev is created and stored since |
| 2049 | * it will access the HDD pdev object lock. |
| 2050 | */ |
| 2051 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2052 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2053 | /* Configure NAN datapath features */ |
| 2054 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Nachiket Kukade | 85aa378 | 2018-11-02 20:12:34 +0530 | [diff] [blame] | 2055 | ucfg_nan_set_tgt_caps(hdd_ctx->psoc, &cfg->nan_caps); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2056 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2057 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 2058 | hdd_ctx->obss_scan_offload = cfg->services.obss_scan_offload; |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 2059 | status = ucfg_mlme_set_obss_detection_offload_enabled( |
| 2060 | hdd_ctx->psoc, cfg->obss_detection_offloaded); |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2061 | if (QDF_IS_STATUS_ERROR(status)) |
| 2062 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2063 | |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 2064 | status = ucfg_mlme_set_obss_color_collision_offload_enabled( |
| 2065 | hdd_ctx->psoc, cfg->obss_color_collision_offloaded); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2066 | if (QDF_IS_STATUS_ERROR(status)) |
| 2067 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2068 | } |
| 2069 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2070 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2071 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2072 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2073 | struct hdd_ap_ctx *ap_ctx; |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2074 | bool dfs_disable_channel_switch = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2075 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2076 | if (!hdd_ctx) { |
| 2077 | hdd_info("Couldn't get hdd_ctx"); |
| 2078 | return true; |
| 2079 | } |
| 2080 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2081 | ucfg_mlme_get_dfs_disable_channel_switch(hdd_ctx->psoc, |
| 2082 | &dfs_disable_channel_switch); |
| 2083 | if (dfs_disable_channel_switch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2084 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2085 | hdd_ctx, dfs_disable_channel_switch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2086 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2087 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2088 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2089 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2090 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2091 | |
| 2092 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2093 | QDF_P2P_GO_MODE == adapter->device_mode) && |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2094 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2095 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2096 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2097 | true; |
| 2098 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2099 | adapter->session_id); |
bings | 6fb9bf6 | 2018-07-05 14:01:53 +0800 | [diff] [blame] | 2100 | if (adapter->txrx_vdev) |
| 2101 | cdp_fc_vdev_flush( |
| 2102 | cds_get_context(QDF_MODULE_ID_SOC), |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2103 | adapter->txrx_vdev); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2104 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2105 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2106 | |
| 2107 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2108 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2109 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2110 | bool hdd_is_valid_mac_address(const uint8_t *mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2111 | { |
| 2112 | int xdigit = 0; |
| 2113 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2114 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2115 | while (*mac_addr) { |
| 2116 | if (isxdigit(*mac_addr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2117 | xdigit++; |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2118 | } else if (':' == *mac_addr) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2119 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2120 | break; |
| 2121 | |
| 2122 | ++separator; |
| 2123 | } else { |
| 2124 | /* Invalid MAC found */ |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2125 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2126 | } |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2127 | ++mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2128 | } |
| 2129 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2130 | } |
| 2131 | |
| 2132 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2133 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2134 | * @dev: Handle to struct net_device to be updated. |
| 2135 | * |
| 2136 | * Return: None |
| 2137 | */ |
| 2138 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2139 | { |
| 2140 | dev->header_ops = NULL; |
| 2141 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2142 | dev->hard_header_len = ETH_HLEN; |
| 2143 | dev->mtu = ETH_DATA_LEN; |
| 2144 | dev->addr_len = ETH_ALEN; |
| 2145 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2146 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2147 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2148 | |
| 2149 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2150 | } |
| 2151 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2152 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2153 | /** |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2154 | * hdd_mon_turn_off_ps_and_wow() - Update monitor mode struct net_device. |
| 2155 | * @hdd_ctx: Pointer to HDD context. |
| 2156 | * |
| 2157 | * Return: None |
| 2158 | */ |
| 2159 | static void hdd_mon_turn_off_ps_and_wow(struct hdd_context *hdd_ctx) |
| 2160 | { |
| 2161 | ucfg_pmo_set_power_save_mode(hdd_ctx->psoc, PS_NOT_SUPPORTED); |
| 2162 | ucfg_pmo_set_wow_enable(hdd_ctx->psoc, PMO_WOW_DISABLE_BOTH); |
| 2163 | } |
| 2164 | |
| 2165 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2166 | * __hdd__mon_open() - HDD Open function |
| 2167 | * @dev: Pointer to net_device structure |
| 2168 | * |
| 2169 | * This is called in response to ifconfig up |
| 2170 | * |
| 2171 | * Return: 0 for success; non-zero for failure |
| 2172 | */ |
| 2173 | static int __hdd_mon_open(struct net_device *dev) |
| 2174 | { |
| 2175 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2176 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2177 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2178 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2179 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2180 | |
| 2181 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2182 | if (ret) |
| 2183 | return ret; |
| 2184 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2185 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2186 | |
| 2187 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 2188 | ret = hdd_psoc_idle_restart(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2189 | if (ret) { |
| 2190 | hdd_err("Failed to start WLAN modules return"); |
| 2191 | return ret; |
| 2192 | } |
| 2193 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2194 | |
| 2195 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2196 | ret = hdd_start_adapter(adapter); |
| 2197 | if (ret) { |
| 2198 | hdd_err("Failed to start adapter :%d", |
| 2199 | adapter->device_mode); |
| 2200 | return ret; |
| 2201 | } |
| 2202 | hdd_err("hdd_start_adapters() successful !"); |
| 2203 | } |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2204 | hdd_mon_turn_off_ps_and_wow(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2205 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2206 | } |
| 2207 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2208 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2209 | |
| 2210 | if (!ret) |
| 2211 | ret = hdd_enable_monitor_mode(dev); |
| 2212 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2213 | return ret; |
| 2214 | } |
| 2215 | |
| 2216 | /** |
| 2217 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2218 | * @dev: Pointer to net_device structure |
| 2219 | * |
| 2220 | * This is called in response to ifconfig up |
| 2221 | * |
| 2222 | * Return: 0 for success; non-zero for failure |
| 2223 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2224 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2225 | { |
| 2226 | int ret; |
| 2227 | |
| 2228 | cds_ssr_protect(__func__); |
| 2229 | ret = __hdd_mon_open(dev); |
| 2230 | cds_ssr_unprotect(__func__); |
| 2231 | |
| 2232 | return ret; |
| 2233 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2234 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2235 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2236 | static QDF_STATUS |
| 2237 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2238 | { |
| 2239 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2240 | QDF_STATUS status; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2241 | uint32_t chnl_sel_logic_conc = 0; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2242 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2243 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2244 | |
| 2245 | if (!hdd_ctx) { |
| 2246 | hdd_err("HDD context is NULL"); |
| 2247 | return QDF_STATUS_E_FAILURE; |
| 2248 | } |
| 2249 | |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2250 | /* |
| 2251 | * ROME platform doesn't support any DBS related commands in FW, |
| 2252 | * so if driver sends wmi command with dual_mac_config with all set to |
| 2253 | * 0 then FW wouldn't respond back and driver would timeout on waiting |
| 2254 | * for response. Check if FW supports DBS to eliminate ROME vs |
| 2255 | * NON-ROME platform. |
| 2256 | */ |
| 2257 | if (!policy_mgr_find_if_fw_supports_dbs(hdd_ctx->psoc)) |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2258 | return QDF_STATUS_SUCCESS; |
| 2259 | |
| 2260 | cfg.scan_config = 0; |
| 2261 | cfg.fw_mode_config = 0; |
| 2262 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2263 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc)) { |
| 2264 | status = |
| 2265 | ucfg_policy_mgr_get_chnl_select_plcy(hdd_ctx->psoc, |
| 2266 | &chnl_sel_logic_conc); |
| 2267 | if (status != QDF_STATUS_SUCCESS) { |
| 2268 | hdd_err("can't get chnl sel policy, use def"); |
| 2269 | return status; |
| 2270 | } |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2271 | } |
| 2272 | status = |
| 2273 | ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 2274 | &dual_mac_feature); |
| 2275 | if (status != QDF_STATUS_SUCCESS) { |
| 2276 | hdd_err("ucfg_policy_mgr_get_dual_mac_feature failed, use def"); |
| 2277 | return status; |
| 2278 | } |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2279 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2280 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2281 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2282 | hdd_ctx->psoc, &cfg.scan_config, |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2283 | &cfg.fw_mode_config, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2284 | dual_mac_feature, |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2285 | chnl_sel_logic_conc); |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2286 | |
| 2287 | if (status != QDF_STATUS_SUCCESS) { |
| 2288 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2289 | status); |
| 2290 | return status; |
| 2291 | } |
| 2292 | } |
| 2293 | |
| 2294 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2295 | cfg.scan_config, cfg.fw_mode_config); |
| 2296 | |
| 2297 | status = sme_soc_set_dual_mac_config(cfg); |
| 2298 | if (status != QDF_STATUS_SUCCESS) { |
| 2299 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2300 | return status; |
| 2301 | } |
| 2302 | |
| 2303 | return QDF_STATUS_SUCCESS; |
| 2304 | } |
| 2305 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2306 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2307 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2308 | * @adapter: pointer to HDD adapter |
| 2309 | * |
| 2310 | * This function is called to start the device specific adapter for |
| 2311 | * the mode passed in the adapter's device_mode. |
| 2312 | * |
| 2313 | * Return: 0 for success; non-zero for failure |
| 2314 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2315 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2316 | { |
| 2317 | |
| 2318 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2319 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2320 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2321 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2322 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2323 | |
| 2324 | switch (device_mode) { |
| 2325 | case QDF_P2P_CLIENT_MODE: |
| 2326 | case QDF_P2P_DEVICE_MODE: |
| 2327 | case QDF_OCB_MODE: |
| 2328 | case QDF_STA_MODE: |
| 2329 | case QDF_MONITOR_MODE: |
| 2330 | ret = hdd_start_station_adapter(adapter); |
| 2331 | if (ret) |
| 2332 | goto err_start_adapter; |
Alok Kumar | 81e1d73 | 2018-09-04 11:10:36 +0530 | [diff] [blame] | 2333 | |
| 2334 | hdd_nud_ignore_tracking(adapter, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2335 | break; |
| 2336 | case QDF_P2P_GO_MODE: |
| 2337 | case QDF_SAP_MODE: |
| 2338 | ret = hdd_start_ap_adapter(adapter); |
| 2339 | if (ret) |
| 2340 | goto err_start_adapter; |
| 2341 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2342 | case QDF_IBSS_MODE: |
| 2343 | /* |
| 2344 | * For IBSS interface is initialized as part of |
| 2345 | * hdd_init_station_mode() |
| 2346 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2347 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2348 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2349 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2350 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2351 | default: |
| 2352 | hdd_err("Invalid session type %d", device_mode); |
| 2353 | QDF_ASSERT(0); |
| 2354 | goto err_start_adapter; |
| 2355 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2356 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2357 | if (hdd_set_fw_params(adapter)) |
| 2358 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2359 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2360 | if (adapter->session_id != HDD_SESSION_ID_INVALID) { |
| 2361 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2362 | if (ret < 0) { |
| 2363 | hdd_err("Failed to register frames - ret %d", ret); |
| 2364 | goto err_start_adapter; |
| 2365 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2366 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2367 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2368 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2369 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2370 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2371 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2372 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2373 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2374 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2375 | err_start_adapter: |
| 2376 | return -EINVAL; |
| 2377 | } |
| 2378 | |
| 2379 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2380 | * hdd_enable_power_management() - API to Enable Power Management |
| 2381 | * |
| 2382 | * API invokes Bus Interface Layer power management functionality |
| 2383 | * |
| 2384 | * Return: None |
| 2385 | */ |
| 2386 | static void hdd_enable_power_management(void) |
| 2387 | { |
| 2388 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2389 | |
| 2390 | if (!hif_ctx) { |
| 2391 | hdd_err("Bus Interface Context is Invalid"); |
| 2392 | return; |
| 2393 | } |
| 2394 | |
| 2395 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2396 | } |
| 2397 | |
| 2398 | /** |
| 2399 | * hdd_disable_power_management() - API to disable Power Management |
| 2400 | * |
| 2401 | * API disable Bus Interface Layer Power management functionality |
| 2402 | * |
| 2403 | * Return: None |
| 2404 | */ |
| 2405 | static void hdd_disable_power_management(void) |
| 2406 | { |
| 2407 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2408 | |
| 2409 | if (!hif_ctx) { |
| 2410 | hdd_err("Bus Interface Context is Invalid"); |
| 2411 | return; |
| 2412 | } |
| 2413 | |
| 2414 | hif_disable_power_management(hif_ctx); |
| 2415 | } |
| 2416 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2417 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2418 | { |
| 2419 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2420 | size_t target_hw_name_len; |
| 2421 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2422 | uint8_t *buf; |
| 2423 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2424 | |
| 2425 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2426 | if (!hif_sc) { |
| 2427 | hdd_err("HIF context is NULL"); |
| 2428 | return; |
| 2429 | } |
| 2430 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2431 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2432 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2433 | &target_hw_name); |
| 2434 | |
| 2435 | if (hdd_ctx->target_hw_name) |
| 2436 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2437 | |
| 2438 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2439 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2440 | if (hdd_ctx->target_hw_name) |
| 2441 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2442 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2443 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2444 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2445 | if (buf) { |
| 2446 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2447 | hdd_info("%s", buf); |
| 2448 | qdf_mem_free(buf); |
| 2449 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2450 | } |
| 2451 | |
| 2452 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2453 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2454 | * @hdd_ctx: Pointer to hdd context |
| 2455 | * |
| 2456 | * Return: none |
| 2457 | */ |
| 2458 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2459 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2460 | { |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2461 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM] = {0}; |
| 2462 | qdf_size_t out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2463 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2464 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2465 | |
| 2466 | if (NULL == hdd_ctx) |
| 2467 | return; |
| 2468 | |
| 2469 | if (NULL == hdd_ctx->config) { |
| 2470 | /* Do nothing if hdd_ctx is invalid */ |
| 2471 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2472 | return; |
| 2473 | } |
| 2474 | |
| 2475 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2476 | |
| 2477 | if (!cds_ctx) { |
| 2478 | hdd_err("Invalid CDS Context"); |
| 2479 | return; |
| 2480 | } |
| 2481 | |
| 2482 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2483 | switch (i) { |
| 2484 | case OL_TX_WMM_AC_BE: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2485 | qdf_uint8_array_parse( |
| 2486 | cfg_get(hdd_ctx->psoc, |
| 2487 | CFG_DP_ENABLE_TX_SCHED_WRR_BE), |
| 2488 | tx_sched_wrr_param, |
| 2489 | sizeof(tx_sched_wrr_param), |
| 2490 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2491 | break; |
| 2492 | case OL_TX_WMM_AC_BK: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2493 | qdf_uint8_array_parse( |
| 2494 | cfg_get(hdd_ctx->psoc, |
| 2495 | CFG_DP_ENABLE_TX_SCHED_WRR_BK), |
| 2496 | tx_sched_wrr_param, |
| 2497 | sizeof(tx_sched_wrr_param), |
| 2498 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2499 | break; |
| 2500 | case OL_TX_WMM_AC_VI: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2501 | qdf_uint8_array_parse( |
| 2502 | cfg_get(hdd_ctx->psoc, |
| 2503 | CFG_DP_ENABLE_TX_SCHED_WRR_VI), |
| 2504 | tx_sched_wrr_param, |
| 2505 | sizeof(tx_sched_wrr_param), |
| 2506 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2507 | break; |
| 2508 | case OL_TX_WMM_AC_VO: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2509 | qdf_uint8_array_parse( |
| 2510 | cfg_get(hdd_ctx->psoc, |
| 2511 | CFG_DP_ENABLE_TX_SCHED_WRR_VO), |
| 2512 | tx_sched_wrr_param, |
| 2513 | sizeof(tx_sched_wrr_param), |
| 2514 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2515 | break; |
| 2516 | default: |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2517 | break; |
| 2518 | } |
| 2519 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2520 | if (out_size == TX_SCHED_WRR_PARAMS_NUM) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2521 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2522 | tx_sched_wrr_param[0]; |
| 2523 | cds_ctx->ac_specs[i].credit_threshold = |
| 2524 | tx_sched_wrr_param[1]; |
| 2525 | cds_ctx->ac_specs[i].send_limit = |
| 2526 | tx_sched_wrr_param[2]; |
| 2527 | cds_ctx->ac_specs[i].credit_reserve = |
| 2528 | tx_sched_wrr_param[3]; |
| 2529 | cds_ctx->ac_specs[i].discard_weight = |
| 2530 | tx_sched_wrr_param[4]; |
| 2531 | } |
| 2532 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2533 | out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2534 | } |
| 2535 | } |
| 2536 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2537 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2538 | const size_t version_len, uint8_t *version) |
| 2539 | { |
| 2540 | uint32_t size; |
| 2541 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2542 | |
| 2543 | if (!hdd_ctx) { |
| 2544 | hdd_err("Invalid context, HDD context is null"); |
| 2545 | return 0; |
| 2546 | } |
| 2547 | |
Ashish Kumar Dhanotiya | 7353f88 | 2018-05-15 12:50:19 +0530 | [diff] [blame] | 2548 | if (!version || version_len == 0) { |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2549 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2550 | return 0; |
| 2551 | } |
| 2552 | |
| 2553 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2554 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2555 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2556 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2557 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2558 | |
| 2559 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2560 | "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] | 2561 | QWLAN_VERSIONSTR, |
| 2562 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2563 | hdd_ctx->target_hw_name, |
| 2564 | hdd_ctx->hw_bd_info.bdf_version, |
| 2565 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2566 | hdd_ctx->hw_bd_info.customer_id, |
| 2567 | hdd_ctx->hw_bd_info.project_id, |
| 2568 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2569 | |
| 2570 | return size; |
| 2571 | } |
| 2572 | |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2573 | int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, |
| 2574 | struct sap_config *sap_config) |
| 2575 | { |
| 2576 | uint8_t preamble = 0, nss = 0, rix = 0; |
| 2577 | int ret; |
| 2578 | mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle; |
| 2579 | |
| 2580 | if (!sap_config) { |
| 2581 | if (!sme_is_feature_supported_by_fw(DOT11AX)) { |
| 2582 | hdd_err("Target does not support 11ax"); |
| 2583 | return -EIO; |
| 2584 | } |
| 2585 | } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax && |
| 2586 | sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) { |
| 2587 | hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d", |
| 2588 | sap_config->SapHw_mode, sap_config->channel); |
| 2589 | return -EIO; |
| 2590 | } |
| 2591 | |
| 2592 | if (set_value != 0xff) { |
| 2593 | rix = RC_2_RATE_IDX_11AX(set_value); |
| 2594 | preamble = WMI_RATE_PREAMBLE_HE; |
| 2595 | nss = HT_RC_2_STREAMS_11AX(set_value); |
| 2596 | |
| 2597 | set_value = hdd_assemble_rate_code(preamble, nss, rix); |
| 2598 | } else { |
| 2599 | ret = sme_set_auto_rate_he_ltf(mac_handle, adapter->session_id, |
| 2600 | QCA_WLAN_HE_LTF_AUTO); |
| 2601 | } |
| 2602 | |
| 2603 | hdd_info("SET_11AX_RATE val %d rix %d preamble %x nss %d", |
| 2604 | set_value, rix, preamble, nss); |
| 2605 | |
| 2606 | ret = wma_cli_set_command(adapter->session_id, |
| 2607 | WMI_VDEV_PARAM_FIXED_RATE, |
| 2608 | set_value, VDEV_CMD); |
| 2609 | |
| 2610 | return ret; |
| 2611 | } |
| 2612 | |
| 2613 | int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate) |
| 2614 | { |
| 2615 | int set_value; |
| 2616 | |
| 2617 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 2618 | set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble); |
| 2619 | else |
| 2620 | set_value = (preamble << 6) | (nss << 4) | rate; |
| 2621 | |
| 2622 | return set_value; |
| 2623 | } |
| 2624 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2625 | #ifdef FEATURE_WLAN_WAPI |
| 2626 | /** |
| 2627 | * hdd_wapi_security_sta_exist() - return wapi security sta exist or not |
| 2628 | * |
| 2629 | * This API returns the wapi security station exist or not |
| 2630 | * |
| 2631 | * Return: true - wapi security station exist |
| 2632 | */ |
| 2633 | static bool hdd_wapi_security_sta_exist(void) |
| 2634 | { |
| 2635 | struct hdd_adapter *adapter = NULL; |
| 2636 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2637 | |
| 2638 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2639 | if ((adapter->device_mode == QDF_STA_MODE) && |
| 2640 | adapter->wapi_info.wapi_mode && |
| 2641 | (adapter->wapi_info.wapi_auth_mode != WAPI_AUTH_MODE_OPEN)) |
| 2642 | return true; |
| 2643 | } |
| 2644 | return false; |
| 2645 | } |
| 2646 | #else |
| 2647 | static bool hdd_wapi_security_sta_exist(void) |
| 2648 | { |
| 2649 | return false; |
| 2650 | } |
| 2651 | #endif |
| 2652 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2653 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2654 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2655 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2656 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2657 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2658 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2659 | |
| 2660 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2661 | if (!adapter) { |
| 2662 | hdd_err("Adapter is NULL"); |
| 2663 | return PM_MAX_NUM_OF_MODE; |
| 2664 | } |
| 2665 | |
| 2666 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2667 | adapter->device_mode); |
| 2668 | } |
| 2669 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2670 | static void hdd_register_policy_manager_callback( |
| 2671 | struct wlan_objmgr_psoc *psoc) |
| 2672 | { |
| 2673 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2674 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2675 | qdf_mem_zero(&hdd_cbacks, sizeof(hdd_cbacks)); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2676 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2677 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2678 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2679 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2680 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2681 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2682 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2683 | hdd_cbacks.hdd_wapi_security_sta_exist = |
| 2684 | hdd_wapi_security_sta_exist; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2685 | if (QDF_STATUS_SUCCESS != |
| 2686 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2687 | hdd_err("HDD callback registration with policy manager failed"); |
| 2688 | } |
| 2689 | } |
| 2690 | #else |
| 2691 | static void hdd_register_policy_manager_callback( |
| 2692 | struct wlan_objmgr_psoc *psoc) |
| 2693 | { |
| 2694 | } |
| 2695 | #endif |
| 2696 | |
Nachiket Kukade | 2fb1fdb | 2019-01-08 15:35:27 +0530 | [diff] [blame^] | 2697 | #ifdef WLAN_FEATURE_NAN |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2698 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2699 | { |
| 2700 | struct nan_callbacks cb_obj = {0}; |
| 2701 | |
| 2702 | cb_obj.ndi_open = hdd_ndi_open; |
| 2703 | cb_obj.ndi_close = hdd_ndi_close; |
| 2704 | cb_obj.ndi_start = hdd_ndi_start; |
| 2705 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2706 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2707 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2708 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2709 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2710 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2711 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2712 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2713 | os_if_nan_register_hdd_callbacks(hdd_ctx->psoc, &cb_obj); |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2714 | } |
jiad | ff1ac13 | 2018-11-26 16:27:48 +0800 | [diff] [blame] | 2715 | #else |
| 2716 | static inline void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
| 2717 | { |
| 2718 | } |
| 2719 | #endif |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2720 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2721 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2722 | /** |
| 2723 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2724 | * @hdd_ctx: the global HDD context |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2725 | * @is_ssr: true if SSR is in progress |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2726 | * |
| 2727 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2728 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2729 | * |
| 2730 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2731 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2732 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2733 | * fixed. |
| 2734 | * |
| 2735 | * Return: None |
| 2736 | */ |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2737 | 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] | 2738 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2739 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2740 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2741 | wlan_objmgr_psoc_check_for_peer_leaks(hdd_ctx->psoc); |
| 2742 | wlan_objmgr_psoc_check_for_vdev_leaks(hdd_ctx->psoc); |
| 2743 | wlan_objmgr_psoc_check_for_pdev_leaks(hdd_ctx->psoc); |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2744 | |
| 2745 | /* many adapter resources are not freed by design during SSR */ |
| 2746 | if (is_ssr) |
| 2747 | return; |
| 2748 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2749 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2750 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2751 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2752 | } |
| 2753 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2754 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2755 | #else |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2756 | static inline void hdd_check_for_leaks(struct hdd_context *hdd_ctx, bool is_ssr) |
| 2757 | { } |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2758 | |
| 2759 | #define hdd_debug_domain_set(domain) |
| 2760 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2761 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2762 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2763 | * hdd_update_country_code - Update country code |
| 2764 | * @hdd_ctx: HDD context |
| 2765 | * |
| 2766 | * Update country code based on module parameter country_code |
| 2767 | * |
| 2768 | * Return: 0 on success and errno on failure |
| 2769 | */ |
| 2770 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2771 | { |
| 2772 | if (!country_code) |
| 2773 | return 0; |
| 2774 | |
| 2775 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2776 | } |
| 2777 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2778 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2779 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2780 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2781 | qdf_device_t qdf_dev; |
| 2782 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2783 | bool unint = false; |
| 2784 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2785 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2786 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2787 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2788 | if (!qdf_dev) { |
| 2789 | hdd_err("QDF Device Context is Invalid return"); |
| 2790 | return -EINVAL; |
| 2791 | } |
| 2792 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 2793 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2794 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2795 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2796 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2797 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2798 | hdd_debug("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2799 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2800 | return 0; |
| 2801 | } |
| 2802 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2803 | hdd_ctx->start_modules_in_progress = true; |
| 2804 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2805 | switch (hdd_ctx->driver_status) { |
| 2806 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2807 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2808 | unint = true; |
| 2809 | /* Fall through dont add break here */ |
| 2810 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2811 | hdd_info("Wlan transitioning (CLOSED -> ENABLED)"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2812 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2813 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2814 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2815 | if (!reinit && !unint) { |
| 2816 | ret = pld_power_on(qdf_dev->dev); |
| 2817 | if (ret) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2818 | hdd_err("Failed to power up device; errno:%d", |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2819 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2820 | goto release_lock; |
| 2821 | } |
| 2822 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2823 | |
| 2824 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2825 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2826 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2827 | qdf_dev->bus_type, |
| 2828 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2829 | HIF_ENABLE_TYPE_PROBE); |
| 2830 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2831 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2832 | goto power_down; |
| 2833 | } |
| 2834 | |
| 2835 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2836 | if (!hif_ctx) { |
| 2837 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2838 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2839 | goto power_down; |
| 2840 | } |
| 2841 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2842 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2843 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2844 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2845 | status); |
| 2846 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2847 | goto hif_close; |
| 2848 | } |
| 2849 | |
jitiphil | 4c256a3 | 2018-09-07 08:51:52 +0530 | [diff] [blame] | 2850 | ucfg_ipa_component_config_update(hdd_ctx->psoc); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2851 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2852 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2853 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2854 | status = hdd_component_psoc_open(hdd_ctx->psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2855 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2856 | hdd_err("Failed to Open legacy components; status: %d", |
| 2857 | status); |
| 2858 | ret = qdf_status_to_os_return(status); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 2859 | goto cds_free; |
| 2860 | } |
| 2861 | |
| 2862 | ret = hdd_update_config(hdd_ctx); |
| 2863 | if (ret) { |
| 2864 | hdd_err("Failed to update configuration; errno: %d", |
| 2865 | ret); |
| 2866 | goto cds_free; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2867 | } |
| 2868 | |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 2869 | status = wbuff_module_init(); |
| 2870 | if (QDF_IS_STATUS_ERROR(status)) |
| 2871 | hdd_err("WBUFF init unsuccessful; status: %d", status); |
| 2872 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2873 | status = cds_open(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2874 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2875 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2876 | ret = qdf_status_to_os_return(status); |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 2877 | goto psoc_close; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2878 | } |
| 2879 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 2880 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 2881 | |
Manjunathappa Prakash | b6b4ff1 | 2018-06-04 12:32:33 -0700 | [diff] [blame] | 2882 | if (hdd_ctx->config->rx_thread_affinity_mask) |
| 2883 | cds_set_rx_thread_cpu_mask( |
| 2884 | hdd_ctx->config->rx_thread_affinity_mask); |
| 2885 | |
| 2886 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2887 | ret = hdd_update_components_config(hdd_ctx); |
| 2888 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2889 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2890 | ret); |
| 2891 | goto close; |
| 2892 | } |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2893 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2894 | status = cds_dp_open(hdd_ctx->psoc); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2895 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2896 | hdd_err("Failed to Open cds post open; status: %d", |
| 2897 | status); |
| 2898 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2899 | goto close; |
| 2900 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2901 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2902 | ret = hdd_register_cb(hdd_ctx); |
| 2903 | if (ret) { |
| 2904 | hdd_err("Failed to register HDD callbacks!"); |
| 2905 | goto cds_txrx_free; |
| 2906 | } |
| 2907 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2908 | /* |
| 2909 | * NAN compoenet requires certian operations like, open adapter, |
| 2910 | * close adapter, etc. to be initiated by HDD, for those |
| 2911 | * register HDD callbacks with UMAC's NAN componenet. |
| 2912 | */ |
| 2913 | hdd_nan_register_callbacks(hdd_ctx); |
| 2914 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2915 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2916 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2917 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2918 | ret = qdf_status_to_os_return(status); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2919 | goto deregister_cb; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2920 | } |
| 2921 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2922 | hdd_register_policy_manager_callback( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2923 | hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2924 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2925 | hdd_sysfs_create_driver_root_obj(); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2926 | hdd_sysfs_create_version_interface(hdd_ctx->psoc); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2927 | hdd_sysfs_create_powerstats_interface(); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2928 | hdd_update_hw_sw_info(hdd_ctx); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2929 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2930 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2931 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2932 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2933 | break; |
| 2934 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2935 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2936 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2937 | if (ret) { |
| 2938 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2939 | goto destroy_driver_sysfs; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2940 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2941 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2942 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2943 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2944 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2945 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2946 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2947 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2948 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2949 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2950 | goto release_lock; |
| 2951 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2952 | |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2953 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 2954 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 2955 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2956 | hdd_ctx->start_modules_in_progress = false; |
Dustin Brown | ad698ae | 2018-09-05 17:19:30 -0700 | [diff] [blame] | 2957 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2958 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2959 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2960 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2961 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2962 | return 0; |
| 2963 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2964 | destroy_driver_sysfs: |
| 2965 | hdd_sysfs_destroy_powerstats_interface(); |
| 2966 | hdd_sysfs_destroy_version_interface(); |
| 2967 | hdd_sysfs_destroy_driver_root_obj(); |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2968 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2969 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2970 | deregister_cb: |
| 2971 | hdd_deregister_cb(hdd_ctx); |
| 2972 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2973 | cds_txrx_free: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2974 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2975 | |
| 2976 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 2977 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2978 | dispatcher_pdev_close(hdd_ctx->pdev); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2979 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 2980 | } |
| 2981 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2982 | cds_dp_close(hdd_ctx->psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2983 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2984 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2985 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2986 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2987 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2988 | cds_close(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2989 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 2990 | psoc_close: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2991 | hdd_component_psoc_close(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2992 | cds_deinit_ini_config(); |
| 2993 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2994 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2995 | ol_cds_free(); |
| 2996 | |
| 2997 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2998 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2999 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3000 | power_down: |
| 3001 | if (!reinit && !unint) |
| 3002 | pld_power_off(qdf_dev->dev); |
| 3003 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 3004 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3005 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Abhinav Kumar | 7ae9b7b | 2017-12-19 15:11:54 +0530 | [diff] [blame] | 3006 | if (hdd_ctx->target_hw_name) { |
| 3007 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 3008 | hdd_ctx->target_hw_name = NULL; |
| 3009 | } |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 3010 | |
| 3011 | hdd_check_for_leaks(hdd_ctx, reinit); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 3012 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 3013 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3014 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3015 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 3016 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3017 | } |
| 3018 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3019 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3020 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3021 | { |
| 3022 | int ret = os_if_wifi_pos_register_nl(); |
| 3023 | |
| 3024 | if (ret) |
| 3025 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 3026 | |
| 3027 | return ret; |
| 3028 | } |
| 3029 | |
| 3030 | static int hdd_deactivate_wifi_pos(void) |
| 3031 | { |
| 3032 | int ret = os_if_wifi_pos_deregister_nl(); |
| 3033 | |
| 3034 | if (ret) |
| 3035 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 3036 | |
| 3037 | return ret; |
| 3038 | } |
| 3039 | |
| 3040 | /** |
| 3041 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 3042 | * @hdd_ctx: hdd context |
| 3043 | * |
| 3044 | * Return: status of operation |
| 3045 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3046 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3047 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3048 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3049 | uint16_t neighbor_scan_max_chan_time; |
| 3050 | uint16_t neighbor_scan_min_chan_time; |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3051 | |
| 3052 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 3053 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 3054 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 3055 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 3056 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 3057 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3058 | ucfg_mlme_get_neighbor_scan_max_chan_time(psoc, |
| 3059 | &neighbor_scan_max_chan_time); |
| 3060 | ucfg_mlme_get_neighbor_scan_min_chan_time(psoc, |
| 3061 | &neighbor_scan_min_chan_time); |
| 3062 | wifi_pos_set_dwell_time_min(psoc, neighbor_scan_min_chan_time); |
| 3063 | wifi_pos_set_dwell_time_max(psoc, neighbor_scan_max_chan_time); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3064 | } |
| 3065 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3066 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3067 | { |
| 3068 | return oem_activate_service(hdd_ctx); |
| 3069 | } |
| 3070 | |
| 3071 | static int hdd_deactivate_wifi_pos(void) |
| 3072 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 3073 | return oem_deactivate_service(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3074 | } |
| 3075 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3076 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3077 | { |
| 3078 | } |
| 3079 | #endif |
| 3080 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3081 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3082 | * __hdd_open() - HDD Open function |
| 3083 | * @dev: Pointer to net_device structure |
| 3084 | * |
| 3085 | * This is called in response to ifconfig up |
| 3086 | * |
| 3087 | * Return: 0 for success; non-zero for failure |
| 3088 | */ |
| 3089 | static int __hdd_open(struct net_device *dev) |
| 3090 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3091 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3092 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3093 | int ret; |
| 3094 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3095 | hdd_enter_dev(dev); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3096 | |
| 3097 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3098 | TRACE_CODE_HDD_OPEN_REQUEST, |
| 3099 | adapter->session_id, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3100 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 3101 | /* Nothing to be done if device is unloading */ |
| 3102 | if (cds_is_driver_unloading()) { |
| 3103 | hdd_err("Driver is unloading can not open the hdd"); |
| 3104 | return -EBUSY; |
| 3105 | } |
| 3106 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 3107 | if (cds_is_driver_recovering()) { |
| 3108 | hdd_err("WLAN is currently recovering; Please try again."); |
| 3109 | return -EBUSY; |
| 3110 | } |
| 3111 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3112 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 3113 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 3114 | return -EBUSY; |
| 3115 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3116 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3117 | mutex_lock(&hdd_init_deinit_lock); |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 3118 | hdd_start_driver_ops_timer(HDD_DRV_OP_IFF_UP); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3119 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3120 | /* |
| 3121 | * This scenario can be hit in cases where in the wlan driver after |
| 3122 | * registering the netdevices and there is a failure in driver |
| 3123 | * initialization. So return error gracefully because the netdevices |
| 3124 | * will be de-registered as part of the load failure. |
| 3125 | */ |
| 3126 | |
| 3127 | if (!cds_is_driver_loaded()) { |
| 3128 | hdd_err("Failed to start the wlan driver!!"); |
| 3129 | ret = -EIO; |
| 3130 | goto err_hdd_hdd_init_deinit_lock; |
| 3131 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3132 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 3133 | ret = hdd_psoc_idle_restart(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3134 | if (ret) { |
| 3135 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3136 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3137 | } |
| 3138 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3139 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3140 | ret = hdd_start_adapter(adapter); |
| 3141 | if (ret) { |
| 3142 | hdd_err("Failed to start adapter :%d", |
| 3143 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3144 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3145 | } |
| 3146 | } |
| 3147 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3148 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3149 | 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] | 3150 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3151 | /* Enable TX queues only when we are connected */ |
| 3152 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3153 | WLAN_START_ALL_NETIF_QUEUE, |
| 3154 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3155 | } |
| 3156 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3157 | /* Enable carrier and transmit queues for NDI */ |
| 3158 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3159 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3160 | wlan_hdd_netif_queue_control(adapter, |
| 3161 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3162 | WLAN_CONTROL_PATH); |
| 3163 | } |
| 3164 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3165 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3166 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3167 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3168 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3169 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3170 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3171 | return ret; |
| 3172 | } |
| 3173 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3174 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3175 | /** |
| 3176 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 3177 | * @dev: Pointer to net_device structure |
| 3178 | * |
| 3179 | * This is called in response to ifconfig up |
| 3180 | * |
| 3181 | * Return: 0 for success; non-zero for failure |
| 3182 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3183 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3184 | { |
| 3185 | int ret; |
| 3186 | |
| 3187 | cds_ssr_protect(__func__); |
| 3188 | ret = __hdd_open(dev); |
| 3189 | cds_ssr_unprotect(__func__); |
| 3190 | |
| 3191 | return ret; |
| 3192 | } |
| 3193 | |
| 3194 | /** |
| 3195 | * __hdd_stop() - HDD stop function |
| 3196 | * @dev: Pointer to net_device structure |
| 3197 | * |
| 3198 | * This is called in response to ifconfig down |
| 3199 | * |
| 3200 | * Return: 0 for success; non-zero for failure |
| 3201 | */ |
| 3202 | static int __hdd_stop(struct net_device *dev) |
| 3203 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3204 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3205 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3206 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3207 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3208 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3209 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3210 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3211 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3212 | TRACE_CODE_HDD_STOP_REQUEST, |
| 3213 | adapter->session_id, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3214 | |
| 3215 | ret = wlan_hdd_validate_context(hdd_ctx); |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3216 | if (ret) { |
| 3217 | set_bit(DOWN_DURING_SSR, &adapter->event_flags); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3218 | return ret; |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3219 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3220 | |
| 3221 | /* Nothing to be done if the interface is not opened */ |
| 3222 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3223 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3224 | return -ENODEV; |
| 3225 | } |
| 3226 | |
| 3227 | /* Make sure the interface is marked as closed */ |
| 3228 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3229 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3230 | mac_handle = hdd_ctx->mac_handle; |
| 3231 | |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3232 | hdd_debug("Disabling Auto Power save timer"); |
| 3233 | sme_ps_disable_auto_ps_timer( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3234 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3235 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3236 | |
| 3237 | /* |
| 3238 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3239 | * be called on that interface |
| 3240 | */ |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 3241 | hdd_debug("Disabling queues, adapter device mode: %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 3242 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3243 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3244 | wlan_hdd_netif_queue_control(adapter, |
| 3245 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3246 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3247 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3248 | if (adapter->device_mode == QDF_STA_MODE) |
| 3249 | hdd_lpass_notify_stop(hdd_ctx); |
| 3250 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3251 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3252 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3253 | * bursty in nature and depends on the need to transfer. The service |
| 3254 | * layer may down the interface after the usage and up again when |
| 3255 | * required. In some sense, the NDI is expected to be available |
| 3256 | * (like SAP) iface until NDI delete request is issued by the service |
| 3257 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3258 | * interface (NDI). |
| 3259 | */ |
| 3260 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3261 | return 0; |
| 3262 | |
| 3263 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3264 | * The interface is marked as down for outside world (aka kernel) |
| 3265 | * But the driver is pretty much alive inside. The driver needs to |
| 3266 | * tear down the existing connection on the netdev (session) |
| 3267 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3268 | * for this interface. The call also needs to wait until the above |
| 3269 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3270 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3271 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3272 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3273 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3274 | |
| 3275 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3276 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3277 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3278 | if (!hdd_is_any_interface_open(hdd_ctx)) |
| 3279 | hdd_psoc_idle_timer_start(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3280 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3281 | hdd_exit(); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3282 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3283 | return 0; |
| 3284 | } |
| 3285 | |
| 3286 | /** |
| 3287 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3288 | * @dev: pointer to net_device structure |
| 3289 | * |
| 3290 | * This is called in response to ifconfig down |
| 3291 | * |
| 3292 | * Return: 0 for success and error number for failure |
| 3293 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3294 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3295 | { |
| 3296 | int ret; |
| 3297 | |
| 3298 | cds_ssr_protect(__func__); |
| 3299 | ret = __hdd_stop(dev); |
| 3300 | cds_ssr_unprotect(__func__); |
| 3301 | |
| 3302 | return ret; |
| 3303 | } |
| 3304 | |
| 3305 | /** |
| 3306 | * __hdd_uninit() - HDD uninit function |
| 3307 | * @dev: Pointer to net_device structure |
| 3308 | * |
| 3309 | * This is called during the netdev unregister to uninitialize all data |
| 3310 | * associated with the device |
| 3311 | * |
| 3312 | * Return: None |
| 3313 | */ |
| 3314 | static void __hdd_uninit(struct net_device *dev) |
| 3315 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3316 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3317 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3318 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3319 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3320 | |
| 3321 | do { |
| 3322 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3323 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3324 | break; |
| 3325 | } |
| 3326 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3327 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3328 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3329 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3330 | break; |
| 3331 | } |
| 3332 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3333 | if (dev != adapter->dev) |
| 3334 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3335 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3336 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3337 | |
| 3338 | /* after uninit our adapter structure will no longer be valid */ |
| 3339 | adapter->dev = NULL; |
| 3340 | adapter->magic = 0; |
| 3341 | } while (0); |
| 3342 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3343 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3344 | } |
| 3345 | |
| 3346 | /** |
| 3347 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3348 | * @dev: pointer to net_device structure |
| 3349 | * |
| 3350 | * This is called during the netdev unregister to uninitialize all data |
| 3351 | * associated with the device |
| 3352 | * |
| 3353 | * Return: none |
| 3354 | */ |
| 3355 | static void hdd_uninit(struct net_device *dev) |
| 3356 | { |
| 3357 | cds_ssr_protect(__func__); |
| 3358 | __hdd_uninit(dev); |
| 3359 | cds_ssr_unprotect(__func__); |
| 3360 | } |
| 3361 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3362 | static int hdd_open_cesium_nl_sock(void) |
| 3363 | { |
| 3364 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3365 | struct netlink_kernel_cfg cfg = { |
| 3366 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3367 | .input = NULL |
| 3368 | }; |
| 3369 | #endif |
| 3370 | int ret = 0; |
| 3371 | |
| 3372 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3373 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3374 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3375 | THIS_MODULE, |
| 3376 | #endif |
| 3377 | &cfg); |
| 3378 | #else |
| 3379 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3380 | WLAN_NLINK_MCAST_GRP_ID, |
| 3381 | NULL, NULL, THIS_MODULE); |
| 3382 | #endif |
| 3383 | |
| 3384 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3385 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3386 | ret = -ECONNREFUSED; |
| 3387 | } |
| 3388 | |
| 3389 | return ret; |
| 3390 | } |
| 3391 | |
| 3392 | static void hdd_close_cesium_nl_sock(void) |
| 3393 | { |
| 3394 | if (NULL != cesium_nl_srv_sock) { |
| 3395 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3396 | cesium_nl_srv_sock = NULL; |
| 3397 | } |
| 3398 | } |
| 3399 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3400 | void hdd_update_dynamic_mac(struct hdd_context *hdd_ctx, |
| 3401 | struct qdf_mac_addr *curr_mac_addr, |
| 3402 | struct qdf_mac_addr *new_mac_addr) |
| 3403 | { |
| 3404 | uint8_t i; |
| 3405 | |
| 3406 | hdd_enter(); |
| 3407 | |
| 3408 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3409 | if (!qdf_mem_cmp( |
| 3410 | curr_mac_addr->bytes, |
| 3411 | &hdd_ctx->dynamic_mac_list[i].dynamic_mac.bytes[0], |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3412 | sizeof(struct qdf_mac_addr))) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3413 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[i].dynamic_mac, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3414 | new_mac_addr->bytes, |
| 3415 | sizeof(struct qdf_mac_addr)); |
| 3416 | break; |
| 3417 | } |
| 3418 | } |
| 3419 | |
| 3420 | hdd_exit(); |
| 3421 | } |
| 3422 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3423 | /** |
| 3424 | * __hdd_set_mac_address() - set the user specified mac address |
| 3425 | * @dev: Pointer to the net device. |
| 3426 | * @addr: Pointer to the sockaddr. |
| 3427 | * |
| 3428 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3429 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3430 | * |
| 3431 | * Return: 0 for success, non zero for failure |
| 3432 | */ |
| 3433 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3434 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3435 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3436 | struct hdd_adapter *adapter_temp; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3437 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3438 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3439 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3440 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3441 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3442 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3443 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3444 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3445 | if (netif_running(dev)) { |
| 3446 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3447 | return -EBUSY; |
| 3448 | } |
| 3449 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3450 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3451 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3452 | if (0 != ret) |
| 3453 | return ret; |
| 3454 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3455 | 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] | 3456 | adapter_temp = hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes); |
| 3457 | if (adapter_temp) { |
| 3458 | if (!qdf_str_cmp(adapter_temp->dev->name, dev->name)) |
| 3459 | return 0; |
| 3460 | hdd_err("%s adapter exist with same address " MAC_ADDRESS_STR, |
| 3461 | adapter_temp->dev->name, |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3462 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 3463 | return -EINVAL; |
| 3464 | } |
| 3465 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 3466 | qdf_ret_status = wlan_hdd_validate_mac_address(&mac_addr); |
| 3467 | if (QDF_IS_STATUS_ERROR(qdf_ret_status)) |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3468 | return -EINVAL; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3469 | |
Ashish Kumar Dhanotiya | 8bfef12 | 2018-04-18 16:48:27 +0530 | [diff] [blame] | 3470 | hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ", |
| 3471 | MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3472 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3473 | hdd_update_dynamic_mac(hdd_ctx, &adapter->mac_addr, &mac_addr); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3474 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3475 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3476 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3477 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3478 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3479 | } |
| 3480 | |
| 3481 | /** |
| 3482 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3483 | * function from SSR |
| 3484 | * @dev: pointer to net_device structure |
| 3485 | * @addr: Pointer to the sockaddr |
| 3486 | * |
| 3487 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3488 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3489 | * |
| 3490 | * Return: 0 for success. |
| 3491 | */ |
| 3492 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3493 | { |
| 3494 | int ret; |
| 3495 | |
| 3496 | cds_ssr_protect(__func__); |
| 3497 | ret = __hdd_set_mac_address(dev, addr); |
| 3498 | cds_ssr_unprotect(__func__); |
| 3499 | |
| 3500 | return ret; |
| 3501 | } |
| 3502 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3503 | 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] | 3504 | { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3505 | int i, j; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3506 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3507 | i = qdf_ffz(hdd_ctx->derived_intf_addr_mask); |
| 3508 | if (i < 0 || i >= hdd_ctx->num_derived_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3509 | return NULL; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3510 | qdf_atomic_set_bit(i, &hdd_ctx->derived_intf_addr_mask); |
| 3511 | hdd_info("Assigning MAC from derived list" MAC_ADDRESS_STR, |
| 3512 | MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3513 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3514 | /* Copy the mac in dynamic mac list at first free position */ |
| 3515 | for (j = 0; j < QDF_MAX_CONCURRENCY_PERSONA; j++) { |
| 3516 | if (qdf_is_macaddr_zero(&hdd_ctx-> |
| 3517 | dynamic_mac_list[j].dynamic_mac)) |
| 3518 | break; |
| 3519 | } |
| 3520 | if (j == QDF_MAX_CONCURRENCY_PERSONA) { |
| 3521 | hdd_err("Max interfaces are up"); |
| 3522 | return NULL; |
| 3523 | } |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 3524 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3525 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[j].dynamic_mac.bytes, |
| 3526 | &hdd_ctx->derived_mac_addr[i].bytes, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3527 | sizeof(struct qdf_mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3528 | hdd_ctx->dynamic_mac_list[j].is_provisioned_mac = false; |
| 3529 | hdd_ctx->dynamic_mac_list[j].bit_position = i; |
| 3530 | |
| 3531 | return hdd_ctx->derived_mac_addr[i].bytes; |
| 3532 | } |
| 3533 | |
| 3534 | static uint8_t *wlan_hdd_get_provisioned_intf_addr(struct hdd_context *hdd_ctx) |
| 3535 | { |
| 3536 | int i, j; |
| 3537 | |
| 3538 | i = qdf_ffz(hdd_ctx->provisioned_intf_addr_mask); |
| 3539 | if (i < 0 || i >= hdd_ctx->num_provisioned_addr) |
| 3540 | return NULL; |
| 3541 | qdf_atomic_set_bit(i, &hdd_ctx->provisioned_intf_addr_mask); |
| 3542 | hdd_info("Assigning MAC from provisioned list" MAC_ADDRESS_STR, |
| 3543 | MAC_ADDR_ARRAY(hdd_ctx->provisioned_mac_addr[i].bytes)); |
| 3544 | |
| 3545 | /* Copy the mac in dynamic mac list at first free position */ |
| 3546 | for (j = 0; j < QDF_MAX_CONCURRENCY_PERSONA; j++) { |
| 3547 | if (qdf_is_macaddr_zero(&hdd_ctx-> |
| 3548 | dynamic_mac_list[j].dynamic_mac)) |
| 3549 | break; |
| 3550 | } |
| 3551 | if (j == QDF_MAX_CONCURRENCY_PERSONA) { |
| 3552 | hdd_err("Max interfaces are up"); |
| 3553 | return NULL; |
| 3554 | } |
| 3555 | |
| 3556 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[j].dynamic_mac.bytes, |
| 3557 | &hdd_ctx->provisioned_mac_addr[i].bytes, |
| 3558 | sizeof(struct qdf_mac_addr)); |
| 3559 | hdd_ctx->dynamic_mac_list[j].is_provisioned_mac = true; |
| 3560 | hdd_ctx->dynamic_mac_list[j].bit_position = i; |
| 3561 | return hdd_ctx->provisioned_mac_addr[i].bytes; |
| 3562 | } |
| 3563 | |
| 3564 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx, |
| 3565 | enum QDF_OPMODE interface_type) |
| 3566 | { |
| 3567 | uint8_t *mac_addr = NULL; |
| 3568 | |
| 3569 | if (qdf_atomic_test_bit(interface_type, |
| 3570 | (unsigned long *) |
| 3571 | (&hdd_ctx->config->provisioned_intf_pool))) |
| 3572 | mac_addr = wlan_hdd_get_provisioned_intf_addr(hdd_ctx); |
| 3573 | |
| 3574 | if ((!mac_addr) && |
| 3575 | (qdf_atomic_test_bit(interface_type, |
| 3576 | (unsigned long *) |
| 3577 | (&hdd_ctx->config->derived_intf_pool)))) |
| 3578 | mac_addr = wlan_hdd_get_derived_intf_addr(hdd_ctx); |
| 3579 | |
| 3580 | if (!mac_addr) |
| 3581 | hdd_err("MAC is not available in both the lists"); |
| 3582 | return mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3583 | } |
| 3584 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3585 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3586 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3587 | { |
| 3588 | int i; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3589 | int mac_pos_in_mask; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3590 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3591 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3592 | if (!memcmp(releaseAddr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3593 | hdd_ctx->dynamic_mac_list[i].dynamic_mac.bytes, |
| 3594 | QDF_MAC_ADDR_SIZE)) { |
| 3595 | mac_pos_in_mask = |
| 3596 | hdd_ctx->dynamic_mac_list[i].bit_position; |
| 3597 | if (hdd_ctx->dynamic_mac_list[i].is_provisioned_mac) { |
| 3598 | qdf_atomic_clear_bit( |
| 3599 | mac_pos_in_mask, |
| 3600 | &hdd_ctx-> |
| 3601 | provisioned_intf_addr_mask); |
| 3602 | hdd_info("Releasing MAC from provisioned list"); |
| 3603 | hdd_info( |
| 3604 | MAC_ADDRESS_STR, |
| 3605 | MAC_ADDR_ARRAY(releaseAddr)); |
| 3606 | } else { |
| 3607 | qdf_atomic_clear_bit( |
| 3608 | mac_pos_in_mask, &hdd_ctx-> |
| 3609 | derived_intf_addr_mask); |
| 3610 | hdd_info("Releasing MAC from derived list"); |
| 3611 | hdd_info(MAC_ADDRESS_STR, |
| 3612 | MAC_ADDR_ARRAY(releaseAddr)); |
| 3613 | } |
| 3614 | qdf_zero_macaddr(&hdd_ctx-> |
| 3615 | dynamic_mac_list[i].dynamic_mac); |
| 3616 | hdd_ctx->dynamic_mac_list[i].is_provisioned_mac = |
| 3617 | false; |
| 3618 | hdd_ctx->dynamic_mac_list[i].bit_position = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3619 | break; |
| 3620 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3621 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3622 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3623 | if (i == QDF_MAX_CONCURRENCY_PERSONA) |
| 3624 | hdd_err("Releasing non existing MAC" MAC_ADDRESS_STR, |
| 3625 | MAC_ADDR_ARRAY(releaseAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3626 | } |
| 3627 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3628 | /** |
| 3629 | * __hdd_set_multicast_list() - set the multicast address list |
| 3630 | * @dev: Pointer to the WLAN device. |
| 3631 | * @skb: Pointer to OS packet (sk_buff). |
| 3632 | * |
| 3633 | * This funciton sets the multicast address list. |
| 3634 | * |
| 3635 | * Return: None |
| 3636 | */ |
| 3637 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3638 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3639 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3640 | int i = 0, errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3641 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3642 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3643 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3644 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3645 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3646 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3647 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3648 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3649 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3650 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3651 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 3652 | if (errno) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3653 | goto out; |
| 3654 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3655 | errno = hdd_validate_adapter(adapter); |
| 3656 | if (errno) |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3657 | goto out; |
| 3658 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3659 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3660 | hdd_err("%s: Driver module is closed", __func__); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3661 | goto out; |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3662 | } |
| 3663 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3664 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 3665 | if (!mc_list_request) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3666 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3667 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3668 | /* Delete already configured multicast address list */ |
| 3669 | if (adapter->mc_addr_list.mc_cnt > 0) { |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3670 | hdd_debug("clear previously configured MC address list"); |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3671 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3672 | pmo_mc_list_change_notify); |
| 3673 | } |
| 3674 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3675 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3676 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3677 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3678 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3679 | } else { |
| 3680 | mc_count = netdev_mc_count(dev); |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 3681 | if (mc_count > ucfg_pmo_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3682 | 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] | 3683 | ucfg_pmo_max_mc_addr_supported(psoc)); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3684 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3685 | pmo_mc_list_change_notify); |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3686 | adapter->mc_addr_list.mc_cnt = 0; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3687 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3688 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3689 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3690 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3691 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3692 | if (i == mc_count) |
| 3693 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3694 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3695 | 0, ETH_ALEN); |
| 3696 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3697 | ha->addr, ETH_ALEN); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3698 | hdd_debug("mlist[%d] = %pM", i, |
| 3699 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3700 | i++; |
| 3701 | } |
| 3702 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3703 | |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3704 | adapter->mc_addr_list.mc_cnt = mc_count; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3705 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3706 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3707 | mc_list_request->count = mc_count; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3708 | |
| 3709 | errno = hdd_cache_mc_addr_list(mc_list_request); |
| 3710 | if (errno) { |
| 3711 | hdd_err("Failed to cache MC address list for vdev %u; errno:%d", |
| 3712 | adapter->session_id, errno); |
| 3713 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3714 | } |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3715 | |
| 3716 | hdd_enable_mc_addr_filtering(adapter, pmo_mc_list_change_notify); |
| 3717 | |
| 3718 | free_req: |
| 3719 | qdf_mem_free(mc_list_request); |
| 3720 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3721 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3722 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3723 | } |
| 3724 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3725 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3726 | /** |
| 3727 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3728 | * @dev: pointer to net_device |
| 3729 | * |
| 3730 | * Return: none |
| 3731 | */ |
| 3732 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3733 | { |
| 3734 | cds_ssr_protect(__func__); |
| 3735 | __hdd_set_multicast_list(dev); |
| 3736 | cds_ssr_unprotect(__func__); |
| 3737 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3738 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3739 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3740 | .ndo_open = hdd_open, |
| 3741 | .ndo_stop = hdd_stop, |
| 3742 | .ndo_uninit = hdd_uninit, |
| 3743 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3744 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3745 | .ndo_get_stats = hdd_get_stats, |
| 3746 | .ndo_do_ioctl = hdd_ioctl, |
| 3747 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3748 | .ndo_select_queue = hdd_select_queue, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3749 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3750 | }; |
| 3751 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3752 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3753 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3754 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3755 | .ndo_open = hdd_mon_open, |
| 3756 | .ndo_stop = hdd_stop, |
| 3757 | .ndo_get_stats = hdd_get_stats, |
| 3758 | }; |
| 3759 | |
| 3760 | /** |
| 3761 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3762 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3763 | * Return: None |
| 3764 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3765 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3766 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3767 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3768 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3769 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3770 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3771 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3772 | #else |
| 3773 | void hdd_set_station_ops(struct net_device *dev) |
| 3774 | { |
| 3775 | dev->netdev_ops = &wlan_drv_ops; |
| 3776 | } |
| 3777 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3778 | |
| 3779 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3780 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3781 | * @hdd_ctx: global hdd context |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3782 | * @mac_addr: mac address to assign to the interface |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3783 | * @name: User-visible name of the interface |
| 3784 | * |
| 3785 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3786 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3787 | * |
| 3788 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3789 | */ |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3790 | static struct hdd_adapter * |
| 3791 | hdd_alloc_station_adapter(struct hdd_context *hdd_ctx, tSirMacAddr mac_addr, |
| 3792 | unsigned char name_assign_type, const char *name) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3793 | { |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3794 | struct net_device *dev; |
| 3795 | struct hdd_adapter *adapter; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3796 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3797 | QDF_STATUS qdf_status; |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 3798 | void *soc; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3799 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 3800 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3801 | /* cfg80211 initialization and registration */ |
| 3802 | dev = alloc_netdev_mq(sizeof(*adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3803 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3804 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3805 | #endif |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3806 | (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE ? |
| 3807 | hdd_mon_mode_ether_setup : ether_setup), |
| 3808 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3809 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3810 | if (!dev) { |
| 3811 | hdd_err("Failed to allocate new net_device '%s'", name); |
| 3812 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3813 | } |
| 3814 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3815 | adapter = netdev_priv(dev); |
| 3816 | |
| 3817 | qdf_mem_zero(adapter, sizeof(*adapter)); |
| 3818 | sta_ctx = &adapter->session.station; |
| 3819 | qdf_mem_set(sta_ctx->conn_info.staId, sizeof(sta_ctx->conn_info.staId), |
| 3820 | HDD_WLAN_INVALID_STA_ID); |
| 3821 | adapter->dev = dev; |
| 3822 | adapter->hdd_ctx = hdd_ctx; |
| 3823 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
| 3824 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3825 | |
| 3826 | qdf_status = qdf_event_create(&adapter->qdf_session_open_event); |
| 3827 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3828 | goto free_net_dev; |
| 3829 | |
| 3830 | qdf_status = qdf_event_create(&adapter->qdf_session_close_event); |
| 3831 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3832 | goto free_net_dev; |
| 3833 | |
| 3834 | adapter->offloads_configured = false; |
| 3835 | adapter->is_link_up_service_needed = false; |
| 3836 | adapter->disconnection_in_progress = false; |
| 3837 | adapter->send_mode_change = true; |
| 3838 | |
| 3839 | /* Init the net_device structure */ |
| 3840 | strlcpy(dev->name, name, IFNAMSIZ); |
| 3841 | |
| 3842 | qdf_mem_copy(dev->dev_addr, mac_addr, sizeof(tSirMacAddr)); |
| 3843 | qdf_mem_copy(adapter->mac_addr.bytes, mac_addr, sizeof(tSirMacAddr)); |
| 3844 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 3845 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 3846 | if (cdp_cfg_get(soc, |
| 3847 | cfg_dp_enable_ip_tcp_udp_checksum_offload)) |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3848 | dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 3849 | dev->features |= NETIF_F_RXCSUM; |
| 3850 | |
| 3851 | hdd_set_tso_flags(hdd_ctx, dev); |
| 3852 | hdd_set_station_ops(adapter->dev); |
| 3853 | |
| 3854 | hdd_dev_setup_destructor(dev); |
| 3855 | dev->ieee80211_ptr = &adapter->wdev; |
| 3856 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
| 3857 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 3858 | adapter->wdev.netdev = dev; |
| 3859 | |
| 3860 | /* set dev's parent to underlying device */ |
| 3861 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
| 3862 | hdd_wmm_init(adapter); |
| 3863 | spin_lock_init(&adapter->pause_map_lock); |
| 3864 | adapter->start_time = qdf_system_ticks(); |
| 3865 | adapter->last_time = adapter->start_time; |
| 3866 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3867 | return adapter; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3868 | |
| 3869 | free_net_dev: |
| 3870 | free_netdev(adapter->dev); |
| 3871 | |
| 3872 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3873 | } |
| 3874 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3875 | 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] | 3876 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3877 | struct net_device *dev = adapter->dev; |
| 3878 | int ret; |
| 3879 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3880 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3881 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3882 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3883 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3884 | |
| 3885 | ret = dev_alloc_name(dev, dev->name); |
| 3886 | if (ret < 0) { |
| 3887 | hdd_err( |
| 3888 | "unable to get dev name: %s, err = 0x%x", |
| 3889 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3890 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3891 | } |
| 3892 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3893 | |
| 3894 | ret = register_netdevice(dev); |
| 3895 | if (ret) { |
| 3896 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3897 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3898 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3899 | } |
| 3900 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3901 | ret = register_netdev(dev); |
| 3902 | if (ret) { |
| 3903 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3904 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3905 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3906 | } |
| 3907 | } |
| 3908 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3909 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3910 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3911 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3912 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3913 | } |
| 3914 | |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3915 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id, |
| 3916 | QDF_STATUS qdf_status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3917 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3918 | struct hdd_adapter *adapter; |
| 3919 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3920 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3921 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3922 | if (!hdd_ctx) { |
| 3923 | hdd_err("Invalid HDD_CTX"); |
| 3924 | return QDF_STATUS_E_FAILURE; |
| 3925 | } |
| 3926 | |
| 3927 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3928 | if (NULL == adapter) { |
Naveen Rawat | 23a3b91 | 2018-05-30 17:45:52 -0700 | [diff] [blame] | 3929 | hdd_err("NULL adapter for %d", session_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3930 | return QDF_STATUS_E_INVAL; |
| 3931 | } |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3932 | |
| 3933 | if (qdf_status == QDF_STATUS_SUCCESS) |
| 3934 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3935 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3936 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3937 | hdd_debug("session %d opened", adapter->session_id); |
| 3938 | |
| 3939 | return QDF_STATUS_SUCCESS; |
| 3940 | } |
| 3941 | |
| 3942 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3943 | { |
| 3944 | struct hdd_adapter *adapter; |
| 3945 | struct hdd_context *hdd_ctx; |
| 3946 | |
| 3947 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3948 | if (!hdd_ctx) { |
| 3949 | hdd_err("Invalid HDD_CTX"); |
| 3950 | return QDF_STATUS_E_FAILURE; |
| 3951 | } |
| 3952 | |
| 3953 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3954 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3955 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3956 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3957 | } |
| 3958 | |
| 3959 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3960 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3961 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3962 | } |
| 3963 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3964 | /* |
| 3965 | * For NAN Data interface, the close session results in the final |
| 3966 | * indication to the userspace |
| 3967 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3968 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3969 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3970 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3971 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3972 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3973 | /* |
| 3974 | * We can be blocked while waiting for scheduled work to be |
| 3975 | * flushed, and the adapter structure can potentially be freed, in |
| 3976 | * which case the magic will have been reset. So make sure the |
| 3977 | * magic is still good, and hence the adapter structure is still |
| 3978 | * valid, before signaling completion |
| 3979 | */ |
| 3980 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3981 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3982 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3983 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3984 | } |
| 3985 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3986 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3987 | { |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3988 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3989 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3990 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3991 | vdev = hdd_objmgr_get_vdev(adapter); |
| 3992 | if (!vdev) |
| 3993 | return -EINVAL; |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3994 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3995 | status = pmo_vdev_ready(vdev); |
| 3996 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3997 | hdd_objmgr_put_vdev(adapter); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3998 | return qdf_status_to_os_return(status); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3999 | } |
| 4000 | |
| 4001 | status = ucfg_reg_11d_vdev_created_update(vdev); |
| 4002 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4003 | hdd_objmgr_put_vdev(adapter); |
| 4004 | return qdf_status_to_os_return(status); |
| 4005 | } |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4006 | |
| 4007 | if (wma_capability_enhanced_mcast_filter()) |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4008 | status = ucfg_pmo_enhanced_mc_filter_enable(vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4009 | else |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4010 | status = ucfg_pmo_enhanced_mc_filter_disable(vdev); |
| 4011 | |
| 4012 | hdd_objmgr_put_vdev(adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4013 | |
| 4014 | return qdf_status_to_os_return(status); |
| 4015 | } |
| 4016 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4017 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4018 | { |
| 4019 | QDF_STATUS status; |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4020 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4021 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4022 | uint8_t vdev_id; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4023 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4024 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4025 | vdev_id = adapter->session_id; |
| 4026 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4027 | |
| 4028 | /* vdev created sanity check */ |
| 4029 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4030 | hdd_err("vdev %u does not exist", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4031 | return -EINVAL; |
| 4032 | } |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4033 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4034 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4035 | if (!vdev) |
| 4036 | return -EINVAL; |
Ashish Kumar Dhanotiya | 68ee2e4 | 2018-11-19 21:15:14 +0530 | [diff] [blame] | 4037 | |
| 4038 | ucfg_pmo_del_wow_pattern(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4039 | status = ucfg_reg_11d_vdev_delete_update(vdev); |
Abhishek Singh | 935e477 | 2018-11-21 14:14:10 +0530 | [diff] [blame] | 4040 | ucfg_scan_vdev_set_disable(vdev, REASON_VDEV_DOWN); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4041 | hdd_objmgr_put_vdev(adapter); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4042 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4043 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4044 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4045 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4046 | status = sme_close_session(hdd_ctx->mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4047 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4048 | hdd_err("failed to close sme session; status:%d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4049 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4050 | } |
| 4051 | |
| 4052 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4053 | status = qdf_wait_for_event_completion( |
| 4054 | &adapter->qdf_session_close_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4055 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4056 | |
| 4057 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4058 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4059 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4060 | if (adapter->device_mode == QDF_NDI_MODE) |
| 4061 | hdd_ndp_session_end_handler(adapter); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4062 | |
| 4063 | if (status == QDF_STATUS_E_TIMEOUT) |
| 4064 | hdd_err("timed out waiting for sme close session"); |
| 4065 | else if (adapter->qdf_session_close_event.force_set) |
| 4066 | hdd_info("SSR occurred during sme close session"); |
| 4067 | else |
| 4068 | hdd_err("failed to wait for sme close session; status:%u", |
| 4069 | status); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4070 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4071 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4072 | release_vdev: |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4073 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4074 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4075 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4076 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4077 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4078 | return errno; |
| 4079 | } |
| 4080 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4081 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4082 | |
| 4083 | return 0; |
| 4084 | } |
| 4085 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4086 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 4087 | struct sme_session_params *session_param, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4088 | csr_roam_complete_cb callback, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4089 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4090 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4091 | uint32_t type; |
| 4092 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4093 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4094 | |
| 4095 | /* determine vdev (sub)type */ |
| 4096 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4097 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4098 | hdd_err("failed to get vdev type: %d", status); |
| 4099 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4100 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4101 | session_param->sme_session_id = adapter->session_id; |
| 4102 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 4103 | session_param->type_of_persona = type; |
| 4104 | session_param->subtype_of_persona = sub_type; |
| 4105 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 4106 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 4107 | session_param->callback = callback; |
| 4108 | session_param->callback_ctx = callback_ctx; |
| 4109 | |
| 4110 | return 0; |
| 4111 | } |
| 4112 | |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4113 | static void |
| 4114 | hdd_store_nss_chains_cfg_in_vdev(struct hdd_adapter *adapter) |
| 4115 | { |
| 4116 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 4117 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4118 | |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4119 | /* Populate the nss chain params from ini for this vdev type */ |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4120 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 4121 | adapter->device_mode, |
| 4122 | hdd_ctx->num_rf_chains); |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4123 | |
| 4124 | /* Store the nss chain config into the vdev */ |
| 4125 | sme_store_nss_chains_cfg_in_vdev(adapter->vdev, &vdev_ini_cfg); |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4126 | } |
gaurank kathpalia | 6982d47 | 2018-10-31 21:54:15 +0530 | [diff] [blame] | 4127 | |
| 4128 | bool hdd_is_vdev_in_conn_state(struct hdd_adapter *adapter) |
| 4129 | { |
| 4130 | switch (adapter->device_mode) { |
| 4131 | case QDF_STA_MODE: |
| 4132 | case QDF_P2P_CLIENT_MODE: |
| 4133 | case QDF_P2P_DEVICE_MODE: |
| 4134 | return hdd_conn_is_connected( |
| 4135 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)); |
| 4136 | case QDF_SAP_MODE: |
| 4137 | case QDF_P2P_GO_MODE: |
| 4138 | return (test_bit(SOFTAP_BSS_STARTED, |
| 4139 | &adapter->event_flags)); |
| 4140 | default: |
| 4141 | hdd_err("Device mode %d invalid", adapter->device_mode); |
| 4142 | return 0; |
| 4143 | } |
| 4144 | |
| 4145 | return 0; |
| 4146 | } |
| 4147 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4148 | int hdd_vdev_create(struct hdd_adapter *adapter, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4149 | csr_roam_complete_cb callback, void *ctx) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4150 | { |
| 4151 | QDF_STATUS status; |
| 4152 | int errno; |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4153 | bool bval; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4154 | struct hdd_context *hdd_ctx; |
| 4155 | struct sme_session_params sme_session_params = {0}; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4156 | struct wlan_objmgr_vdev *vdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4157 | |
| 4158 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4159 | |
| 4160 | /* do vdev create via objmgr */ |
| 4161 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 4162 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4163 | if (errno) { |
| 4164 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 4165 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4166 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4167 | |
| 4168 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4169 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 4170 | if (QDF_STATUS_SUCCESS != status) { |
| 4171 | hdd_err("failed to reinit session open event"); |
| 4172 | return -EINVAL; |
| 4173 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4174 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 4175 | callback, ctx); |
| 4176 | if (errno) { |
| 4177 | hdd_err("failed to populating SME params"); |
| 4178 | goto objmgr_vdev_destroy_procedure; |
| 4179 | } |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4180 | status = sme_open_session(hdd_ctx->mac_handle, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4181 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4182 | hdd_err("failed to open sme session: %d", status); |
| 4183 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4184 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4185 | } |
| 4186 | |
| 4187 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4188 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4189 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4190 | if (QDF_STATUS_SUCCESS != status) { |
| 4191 | if (adapter->qdf_session_open_event.force_set) { |
| 4192 | /* |
| 4193 | * SSR/PDR has caused shutdown, which has forcefully |
| 4194 | * set the event. Return without the closing session. |
| 4195 | */ |
| 4196 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 4197 | hdd_err("Session open event forcefully set"); |
| 4198 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4199 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 4200 | |
| 4201 | if (QDF_STATUS_E_TIMEOUT == status) |
| 4202 | hdd_err("Session failed to open within timeout period"); |
| 4203 | else |
| 4204 | hdd_err("Failed to wait for session open event(status-%d)", |
| 4205 | status); |
| 4206 | errno = -ETIMEDOUT; |
| 4207 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4208 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4209 | } |
| 4210 | |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 4211 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 4212 | hdd_err("Session failed to open due to vdev create failure"); |
| 4213 | errno = -EINVAL; |
| 4214 | goto objmgr_vdev_destroy_procedure; |
| 4215 | } |
| 4216 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4217 | /* firmware ready for component communication, raise vdev_ready event */ |
| 4218 | errno = hdd_vdev_ready(adapter); |
| 4219 | if (errno) { |
| 4220 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4221 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4222 | } |
| 4223 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4224 | if (adapter->device_mode == QDF_STA_MODE) { |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4225 | bval = false; |
| 4226 | status = ucfg_mlme_get_rtt_mac_randomization(hdd_ctx->psoc, |
| 4227 | &bval); |
| 4228 | if (QDF_IS_STATUS_ERROR(status)) |
| 4229 | hdd_err("unable to get RTT MAC randomization value"); |
| 4230 | |
| 4231 | hdd_debug("setting RTT mac randomization param: %d", bval); |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4232 | errno = sme_cli_set_command(adapter->session_id, |
| 4233 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4234 | bval, |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4235 | VDEV_CMD); |
| 4236 | if (0 != errno) |
| 4237 | hdd_err("RTT mac randomization param set failed %d", |
| 4238 | errno); |
| 4239 | } |
| 4240 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4241 | if (adapter->device_mode == QDF_STA_MODE || |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4242 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
| 4243 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4244 | if (!vdev) |
| 4245 | goto hdd_vdev_destroy_procedure; |
| 4246 | wlan_vdev_set_max_peer_count(vdev, HDD_MAX_VDEV_PEER_COUNT); |
| 4247 | hdd_objmgr_put_vdev(adapter); |
| 4248 | } |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4249 | |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4250 | hdd_store_nss_chains_cfg_in_vdev(adapter); |
| 4251 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4252 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4253 | |
| 4254 | return 0; |
| 4255 | |
| 4256 | /* |
| 4257 | * Due to legacy constraints, we need to destroy in the same order as |
| 4258 | * create. So, split error handling into 2 cases to accommodate. |
| 4259 | */ |
| 4260 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4261 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4262 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4263 | |
| 4264 | return errno; |
| 4265 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4266 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4267 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 4268 | |
| 4269 | return errno; |
| 4270 | } |
| 4271 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4272 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4273 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4274 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4275 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4276 | QDF_STATUS status; |
| 4277 | int ret_val; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4278 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4279 | bool bval = false; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4280 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4281 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4282 | mac_handle = hdd_ctx->mac_handle; |
| 4283 | sme_set_curr_device_mode(mac_handle, adapter->device_mode); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4284 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4285 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4286 | hdd_err("unable to get vht_enable2x2"); |
| 4287 | sme_set_pdev_ht_vht_ies(mac_handle, bval); |
| 4288 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4289 | sme_set_vdev_ies_per_band(mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4290 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 4291 | hdd_roam_profile_init(adapter); |
| 4292 | hdd_register_wext(adapter->dev); |
| 4293 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4294 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4295 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4296 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 4297 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4298 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4299 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4300 | status = sme_config_fast_roaming(mac_handle, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4301 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4302 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4303 | sta_ctx->conn_info.operationChannel = |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 4304 | hdd_ctx->config->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4305 | |
| 4306 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4307 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4308 | |
| 4309 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4310 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4311 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4312 | status, status); |
| 4313 | goto error_init_txrx; |
| 4314 | } |
| 4315 | |
| 4316 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4317 | |
| 4318 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4319 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4320 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4321 | status, status); |
| 4322 | goto error_wmm_init; |
| 4323 | } |
| 4324 | |
| 4325 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4326 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4327 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4328 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4329 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4330 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4331 | if (ret_val) |
| 4332 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4333 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4334 | /* |
| 4335 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4336 | * during that time, then as part of SSR init, do not enable |
| 4337 | * the LRO again. Keep the LRO state same as before SSR. |
| 4338 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 4339 | if (cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 4340 | cfg_dp_lro_enable) && |
| 4341 | !(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4342 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4343 | |
| 4344 | /* rcpi info initialization */ |
| 4345 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4346 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4347 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4348 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4349 | error_wmm_init: |
| 4350 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4351 | hdd_deinit_tx_rx(adapter); |
| 4352 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4353 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4354 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4355 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4356 | return status; |
| 4357 | } |
| 4358 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4359 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4360 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4361 | * @hdd_ctx: global hdd context |
| 4362 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4363 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4364 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4365 | * |
| 4366 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4367 | * |
| 4368 | * Return: None. |
| 4369 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4370 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4371 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4372 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4373 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4374 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4375 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4376 | if (adapter->dev) { |
| 4377 | if (rtnl_held) |
| 4378 | adapter->dev->wireless_handlers = NULL; |
| 4379 | else { |
| 4380 | rtnl_lock(); |
| 4381 | adapter->dev->wireless_handlers = NULL; |
| 4382 | rtnl_unlock(); |
| 4383 | } |
| 4384 | } |
| 4385 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4386 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4387 | hdd_deinit_tx_rx(adapter); |
| 4388 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4389 | } |
| 4390 | |
| 4391 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4392 | hdd_wmm_adapter_close(adapter); |
| 4393 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4394 | } |
| 4395 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4396 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4397 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4398 | } |
| 4399 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4400 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4401 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4402 | bool rtnl_held) |
| 4403 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4404 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4405 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4406 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4407 | case QDF_STA_MODE: |
| 4408 | case QDF_P2P_CLIENT_MODE: |
| 4409 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4410 | case QDF_IBSS_MODE: |
| 4411 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4412 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4413 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4414 | break; |
| 4415 | } |
| 4416 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4417 | case QDF_SAP_MODE: |
| 4418 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4419 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4420 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4421 | break; |
| 4422 | } |
| 4423 | |
| 4424 | default: |
| 4425 | break; |
| 4426 | } |
| 4427 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4428 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4429 | } |
| 4430 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4431 | static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx, |
| 4432 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4433 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4434 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4435 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4436 | |
| 4437 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4438 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4439 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4440 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4441 | return; |
| 4442 | } |
| 4443 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4444 | hdd_nud_deinit_tracking(adapter); |
| 4445 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4446 | hdd_apf_context_destroy(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4447 | qdf_spinlock_destroy(&adapter->vdev_lock); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4448 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4449 | wlan_hdd_debugfs_csr_deinit(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 4450 | if (adapter->device_mode == QDF_STA_MODE) |
| 4451 | hdd_sysfs_destroy_adapter_root_obj(adapter); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4452 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4453 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4454 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4455 | /* |
| 4456 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4457 | * the driver is almost closed and cannot handle either control |
| 4458 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4459 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4460 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4461 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4462 | * the interface is closed and restricts any operations on that |
| 4463 | */ |
| 4464 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4465 | |
| 4466 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4467 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4468 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4469 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4470 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4471 | /* |
| 4472 | * Note that the adapter is no longer valid at this point |
| 4473 | * since the memory has been reclaimed |
| 4474 | */ |
| 4475 | } |
| 4476 | } |
| 4477 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4478 | static QDF_STATUS hdd_check_for_existing_macaddr(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4479 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4480 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4481 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4482 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4483 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4484 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4485 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4486 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4487 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4488 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4489 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4490 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4491 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4492 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4493 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4494 | /** |
| 4495 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4496 | * @hdd_ctx: HDD Context |
| 4497 | * @adapter: HDD Adapter |
| 4498 | * |
| 4499 | * This function set the FW Debug log level based on the INI. |
| 4500 | * |
| 4501 | * Return: None |
| 4502 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4503 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4504 | struct hdd_adapter *adapter) |
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 | QDF_STATUS status; |
| 4507 | uint16_t enable_fw_log_level, enable_fw_log_type; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4508 | int ret; |
| 4509 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4510 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4511 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4512 | 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] | 4513 | return; |
| 4514 | } |
| 4515 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4516 | /* Enable FW logs based on INI configuration */ |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4517 | status = ucfg_fwol_get_enable_fw_log_type(hdd_ctx->psoc, |
| 4518 | &enable_fw_log_type); |
| 4519 | if (QDF_IS_STATUS_ERROR(status)) |
| 4520 | return; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4521 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4522 | WMI_DBGLOG_TYPE, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4523 | enable_fw_log_type, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4524 | DBG_CMD); |
| 4525 | if (ret != 0) |
| 4526 | hdd_err("Failed to enable FW log type ret %d", |
| 4527 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4528 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4529 | status = ucfg_fwol_get_enable_fw_log_level(hdd_ctx->psoc, |
| 4530 | &enable_fw_log_level); |
| 4531 | if (QDF_IS_STATUS_ERROR(status)) |
| 4532 | return; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4533 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4534 | WMI_DBGLOG_LOG_LEVEL, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4535 | enable_fw_log_level, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4536 | DBG_CMD); |
| 4537 | if (ret != 0) |
| 4538 | hdd_err("Failed to enable FW log level ret %d", |
| 4539 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4540 | |
lifeng | faa83cb | 2018-11-24 01:53:56 +0800 | [diff] [blame] | 4541 | sme_enable_fw_module_log_level(hdd_ctx->mac_handle, |
| 4542 | adapter->session_id); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4543 | } |
| 4544 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4545 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4546 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4547 | { |
| 4548 | } |
| 4549 | |
| 4550 | #endif |
| 4551 | |
| 4552 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4553 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4554 | * @adapter: HDD adapter |
| 4555 | * |
| 4556 | * Return: 0 on success or errno on failure |
| 4557 | */ |
| 4558 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4559 | { |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4560 | QDF_STATUS status; |
| 4561 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4562 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4563 | bool enable2x2 = false, enable_bt_chain_sep = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4564 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
| 4565 | |
| 4566 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 4567 | &dual_mac_feature); |
| 4568 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4569 | hdd_err("unable to get dual mac feature"); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4570 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4571 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &enable2x2); |
| 4572 | if (QDF_IS_STATUS_ERROR(status)) |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4573 | hdd_err("unable to get vht_enable2x2"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4574 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4575 | status = ucfg_mlme_get_bt_chain_separation_flag(hdd_ctx->psoc, |
| 4576 | &enable_bt_chain_sep); |
| 4577 | if (QDF_IS_STATUS_ERROR(status)) |
| 4578 | hdd_debug("unable to get BT chain separation. using default"); |
| 4579 | |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4580 | hdd_debug("enable2x2: %d, lte_coex: %d, disable_DBS: %d", |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4581 | enable2x2, hdd_ctx->lte_coex_ant_share, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4582 | dual_mac_feature); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4583 | hdd_debug("enable_bt_chain_separation %d", enable_bt_chain_sep); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4584 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4585 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4586 | HW_MODE_DBS_NONE, |
| 4587 | CDS_BAND_ALL); |
| 4588 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4589 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4590 | return qdf_status_to_os_return(status); |
| 4591 | } |
| 4592 | |
| 4593 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4594 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4595 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4596 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4597 | hdd_debug("firmware not capable. skip chain mask programming"); |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4598 | return 0; |
| 4599 | } |
| 4600 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4601 | if (enable2x2 && !enable_bt_chain_sep) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4602 | hdd_debug("2x2 enabled. skip chain mask programming"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4603 | return 0; |
| 4604 | } |
| 4605 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4606 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4607 | hdd_debug("DBS enabled(%d). skip chain mask programming", |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4608 | dual_mac_feature); |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4609 | return 0; |
| 4610 | } |
| 4611 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4612 | if (hdd_ctx->lte_coex_ant_share) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4613 | hdd_debug("lte ant sharing enabled. skip chainmask programming"); |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4614 | return 0; |
| 4615 | } |
| 4616 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4617 | status = ucfg_mlme_configure_chain_mask(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4618 | adapter->session_id); |
| 4619 | if (status != QDF_STATUS_SUCCESS) |
| 4620 | goto error; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4621 | |
| 4622 | return 0; |
| 4623 | |
| 4624 | error: |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4625 | hdd_err("WMI PDEV set param failed"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4626 | return -EINVAL; |
| 4627 | } |
| 4628 | |
| 4629 | /** |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4630 | * hdd_send_coex_config_params() - Send coex config params to FW |
| 4631 | * @hdd_ctx: HDD context |
| 4632 | * @adapter: Primary adapter context |
| 4633 | * |
| 4634 | * This function is used to send all coex config related params to FW |
| 4635 | * |
| 4636 | * Return: 0 on success and -EINVAL on failure |
| 4637 | */ |
| 4638 | static int hdd_send_coex_config_params(struct hdd_context *hdd_ctx, |
| 4639 | struct hdd_adapter *adapter) |
| 4640 | { |
| 4641 | struct coex_config_params coex_cfg_params = {0}; |
| 4642 | struct wlan_fwol_coex_config config = {0}; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 4643 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4644 | QDF_STATUS status; |
| 4645 | |
| 4646 | if (!hdd_ctx) { |
| 4647 | hdd_err("hdd_ctx is invalid"); |
| 4648 | goto err; |
| 4649 | } |
| 4650 | |
| 4651 | if (!adapter) { |
| 4652 | hdd_err("adapter is invalid"); |
| 4653 | goto err; |
| 4654 | } |
| 4655 | |
| 4656 | if (!psoc) { |
| 4657 | hdd_err("HDD psoc is invalid"); |
| 4658 | goto err; |
| 4659 | } |
| 4660 | |
| 4661 | status = ucfg_fwol_get_coex_config_params(psoc, &config); |
| 4662 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4663 | hdd_err("Unable to get coex config params"); |
| 4664 | goto err; |
| 4665 | } |
| 4666 | |
| 4667 | coex_cfg_params.vdev_id = adapter->session_id; |
| 4668 | coex_cfg_params.config_type = WMI_COEX_CONFIG_TX_POWER; |
| 4669 | coex_cfg_params.config_arg1 = config.max_tx_power_for_btc; |
| 4670 | |
| 4671 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4672 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4673 | hdd_err("Failed to send coex Tx power"); |
| 4674 | goto err; |
| 4675 | } |
| 4676 | |
| 4677 | coex_cfg_params.config_type = WMI_COEX_CONFIG_HANDOVER_RSSI; |
| 4678 | coex_cfg_params.config_arg1 = config.wlan_low_rssi_threshold; |
| 4679 | |
| 4680 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4681 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4682 | hdd_err("Failed to send coex handover RSSI"); |
| 4683 | goto err; |
| 4684 | } |
| 4685 | |
| 4686 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BTC_MODE; |
| 4687 | coex_cfg_params.config_arg1 = config.btc_mode; |
| 4688 | |
| 4689 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4690 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4691 | hdd_err("Failed to send coex BTC mode"); |
| 4692 | goto err; |
| 4693 | } |
| 4694 | |
| 4695 | coex_cfg_params.config_type = WMI_COEX_CONFIG_ANTENNA_ISOLATION; |
| 4696 | coex_cfg_params.config_arg1 = config.antenna_isolation; |
| 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 antenna isolation"); |
| 4701 | goto err; |
| 4702 | } |
| 4703 | |
| 4704 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_LOW_RSSI_THRESHOLD; |
| 4705 | coex_cfg_params.config_arg1 = config.bt_low_rssi_threshold; |
| 4706 | |
| 4707 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4708 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4709 | hdd_err("Failed to send coex BT low RSSI threshold"); |
| 4710 | goto err; |
| 4711 | } |
| 4712 | |
| 4713 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_INTERFERENCE_LEVEL; |
| 4714 | coex_cfg_params.config_arg1 = config.bt_interference_low_ll; |
| 4715 | coex_cfg_params.config_arg2 = config.bt_interference_low_ul; |
| 4716 | coex_cfg_params.config_arg3 = config.bt_interference_medium_ll; |
| 4717 | coex_cfg_params.config_arg4 = config.bt_interference_medium_ul; |
| 4718 | coex_cfg_params.config_arg5 = config.bt_interference_high_ll; |
| 4719 | coex_cfg_params.config_arg6 = config.bt_interference_high_ul; |
| 4720 | |
| 4721 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4722 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4723 | hdd_err("Failed to send coex BT interference level"); |
| 4724 | goto err; |
| 4725 | } |
| 4726 | return 0; |
| 4727 | err: |
| 4728 | return -EINVAL; |
| 4729 | } |
| 4730 | |
| 4731 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4732 | * hdd_set_fw_params() - Set parameters to firmware |
| 4733 | * @adapter: HDD adapter |
| 4734 | * |
| 4735 | * This function Sets various parameters to fw once the |
| 4736 | * adapter is started. |
| 4737 | * |
| 4738 | * Return: 0 on success or errno on failure |
| 4739 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4740 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4741 | { |
| 4742 | int ret; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4743 | uint16_t upper_brssi_thresh, lower_brssi_thresh, rts_profile; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4744 | bool enable_dtim_1chrx; |
| 4745 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4746 | struct hdd_context *hdd_ctx; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4747 | bool bval = false; |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4748 | uint8_t max_amsdu_len, enable_tx_sch_delay; |
| 4749 | uint32_t dtim_sel_diversity, enable_secondary_rate; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4750 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4751 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4752 | |
| 4753 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4754 | if (!hdd_ctx) |
| 4755 | return -EINVAL; |
| 4756 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4757 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4758 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4759 | return 0; |
| 4760 | } |
| 4761 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4762 | ret = -1; |
| 4763 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_lprx_enable(hdd_ctx->psoc, |
| 4764 | &bval))) { |
| 4765 | ret = sme_cli_set_command(adapter->session_id, |
| 4766 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4767 | bval, PDEV_CMD); |
| 4768 | } |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4769 | if (ret) { |
| 4770 | hdd_err("Failed to set LPRx"); |
| 4771 | goto error; |
| 4772 | } |
| 4773 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 4774 | ucfg_mlme_get_dtim_selection_diversity(hdd_ctx->psoc, |
| 4775 | &dtim_sel_diversity); |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4776 | |
| 4777 | ret = sme_cli_set_command( |
| 4778 | adapter->session_id, |
| 4779 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 4780 | dtim_sel_diversity, PDEV_CMD); |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4781 | if (ret) { |
| 4782 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4783 | goto error; |
| 4784 | } |
| 4785 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4786 | ret = -1; |
| 4787 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_enable_tx_sch_delay( |
| 4788 | hdd_ctx->psoc, &enable_tx_sch_delay))) { |
| 4789 | ret = sme_cli_set_command(adapter->session_id, |
| 4790 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4791 | enable_tx_sch_delay, PDEV_CMD); |
| 4792 | } |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4793 | if (ret) { |
| 4794 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4795 | goto error; |
| 4796 | } |
| 4797 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4798 | ret = -1; |
| 4799 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_enable_secondary_rate( |
| 4800 | hdd_ctx->psoc, &enable_secondary_rate))) { |
| 4801 | ret = sme_cli_set_command(adapter->session_id, |
| 4802 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4803 | enable_secondary_rate, PDEV_CMD); |
| 4804 | } |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4805 | if (ret) { |
| 4806 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4807 | goto error; |
| 4808 | } |
| 4809 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4810 | if (adapter->device_mode == QDF_STA_MODE) { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4811 | status = ucfg_get_upper_brssi_thresh(hdd_ctx->psoc, |
| 4812 | &upper_brssi_thresh); |
| 4813 | if (QDF_IS_STATUS_ERROR(status)) |
| 4814 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4815 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4816 | sme_set_smps_cfg(adapter->session_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4817 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4818 | upper_brssi_thresh); |
| 4819 | |
| 4820 | status = ucfg_get_lower_brssi_thresh(hdd_ctx->psoc, |
| 4821 | &lower_brssi_thresh); |
| 4822 | if (QDF_IS_STATUS_ERROR(status)) |
| 4823 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4824 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4825 | sme_set_smps_cfg(adapter->session_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4826 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4827 | lower_brssi_thresh); |
| 4828 | |
| 4829 | status = ucfg_get_enable_dtim_1chrx(hdd_ctx->psoc, |
| 4830 | &enable_dtim_1chrx); |
| 4831 | if (QDF_IS_STATUS_ERROR(status)) |
| 4832 | return -EINVAL; |
| 4833 | |
| 4834 | sme_set_smps_cfg(adapter->session_id, |
| 4835 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4836 | enable_dtim_1chrx); |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4837 | } |
| 4838 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4839 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4840 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4841 | hdd_err("unable to get vht_enable2x2"); |
| 4842 | |
| 4843 | if (bval) { |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4844 | hdd_debug("configuring 2x2 mode fw params"); |
| 4845 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4846 | ret = sme_set_cck_tx_fir_override(hdd_ctx->mac_handle, |
| 4847 | adapter->session_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4848 | if (ret) { |
| 4849 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4850 | ret); |
| 4851 | goto error; |
| 4852 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4853 | |
| 4854 | if (hdd_configure_chain_mask(adapter)) |
| 4855 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4856 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4857 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4858 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4859 | hdd_debug("configuring 1x1 mode fw params"); |
| 4860 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4861 | /* |
| 4862 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4863 | * we are passing two value |
| 4864 | * as param_id << 29 | param_value. |
| 4865 | * Below param_value = 0(disable) |
| 4866 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4867 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4868 | WMI_STA_SMPS_PARAM_CMDID, |
| 4869 | HDD_DTIM_1CHAIN_RX_ID << |
| 4870 | HDD_SMPS_PARAM_VALUE_S, |
| 4871 | VDEV_CMD); |
| 4872 | if (ret) { |
| 4873 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4874 | goto error; |
| 4875 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4876 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4877 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4878 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4879 | |
| 4880 | if (hdd_configure_chain_mask(adapter)) |
| 4881 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4882 | } |
| 4883 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4884 | ret = sme_set_enable_mem_deep_sleep(hdd_ctx->mac_handle, |
| 4885 | adapter->session_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4886 | if (ret) { |
| 4887 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4888 | goto error; |
| 4889 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4890 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4891 | status = ucfg_fwol_get_rts_profile(hdd_ctx->psoc, &rts_profile); |
| 4892 | if (QDF_IS_STATUS_ERROR(status)) |
| 4893 | return -EINVAL; |
| 4894 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4895 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4896 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4897 | rts_profile, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4898 | VDEV_CMD); |
| 4899 | if (ret) { |
| 4900 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4901 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4902 | } |
| 4903 | |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4904 | status = ucfg_mlme_get_max_amsdu_num(hdd_ctx->psoc, &max_amsdu_len); |
| 4905 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4906 | hdd_err("Failed to get Max AMSDU Num"); |
| 4907 | goto error; |
| 4908 | } |
| 4909 | |
| 4910 | hdd_debug("SET AMSDU num %d", max_amsdu_len); |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4911 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4912 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4913 | GEN_VDEV_PARAM_AMSDU, |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4914 | max_amsdu_len, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4915 | GEN_CMD); |
| 4916 | if (ret != 0) { |
| 4917 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4918 | goto error; |
| 4919 | } |
| 4920 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4921 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4922 | |
| 4923 | ret = hdd_send_coex_config_params(hdd_ctx, adapter); |
| 4924 | if (ret) { |
| 4925 | hdd_warn("Error initializing coex config params"); |
| 4926 | goto error; |
| 4927 | } |
| 4928 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4929 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4930 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4931 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4932 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4933 | error: |
| 4934 | return -EINVAL; |
| 4935 | } |
| 4936 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4937 | /** |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4938 | * hdd_init_completion() - Initialize Completion Variables |
| 4939 | * @adapter: HDD adapter |
| 4940 | * |
| 4941 | * This function Initialize the completion variables for |
| 4942 | * a particular adapter |
| 4943 | * |
| 4944 | * Return: None |
| 4945 | */ |
| 4946 | static void hdd_init_completion(struct hdd_adapter *adapter) |
| 4947 | { |
| 4948 | init_completion(&adapter->disconnect_comp_var); |
| 4949 | init_completion(&adapter->roaming_comp_var); |
| 4950 | init_completion(&adapter->linkup_event_var); |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4951 | init_completion(&adapter->sta_authorized_event); |
| 4952 | init_completion(&adapter->offchannel_tx_event); |
| 4953 | init_completion(&adapter->tx_action_cnf_event); |
| 4954 | init_completion(&adapter->ibss_peer_info_comp); |
| 4955 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
| 4956 | } |
| 4957 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 4958 | static void hdd_reset_locally_admin_bit(struct hdd_context *hdd_ctx, |
| 4959 | tSirMacAddr macAddr) |
| 4960 | { |
| 4961 | int i; |
| 4962 | /* |
| 4963 | * Reset locally administered bit for dynamic_mac_list |
| 4964 | * also as while releasing the MAC address for any |
| 4965 | * interface mac will be compared with dynamic mac list |
| 4966 | */ |
| 4967 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
| 4968 | if (!qdf_mem_cmp( |
| 4969 | macAddr, |
| 4970 | &hdd_ctx-> |
| 4971 | dynamic_mac_list[i].dynamic_mac.bytes[0], |
| 4972 | sizeof(struct qdf_mac_addr))) { |
| 4973 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT( |
| 4974 | hdd_ctx-> |
| 4975 | dynamic_mac_list[i].dynamic_mac.bytes); |
| 4976 | break; |
| 4977 | } |
| 4978 | } |
| 4979 | /* |
| 4980 | * Reset locally administered bit if the device mode is |
| 4981 | * STA |
| 4982 | */ |
| 4983 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
| 4984 | hdd_debug("locally administered bit reset in sta mode: " |
| 4985 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
| 4986 | } |
| 4987 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4988 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4989 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4990 | * @hdd_ctx: global hdd context |
| 4991 | * @session_type: type of the interface to be created |
| 4992 | * @iface_name: User-visible name of the interface |
| 4993 | * @macAddr: MAC address to assign to the interface |
| 4994 | * @name_assign_type: the name of assign type of the netdev |
| 4995 | * @rtnl_held: the rtnl lock hold flag |
| 4996 | * |
| 4997 | * This function open and setup the hdd adpater according to the device |
| 4998 | * type request, assign the name, the mac address assigned, and then prepared |
| 4999 | * the hdd related parameters, queue, lock and ready to start. |
| 5000 | * |
| 5001 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 5002 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5003 | struct hdd_adapter *hdd_open_adapter(struct hdd_context *hdd_ctx, uint8_t session_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5004 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5005 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5006 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5007 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5008 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5009 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5010 | |
| 5011 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 5012 | /* |
| 5013 | * Max limit reached on the number of vdevs configured by the |
| 5014 | * host. Return error |
| 5015 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5016 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 5017 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5018 | return NULL; |
| 5019 | } |
| 5020 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5021 | status = wlan_hdd_validate_mac_address((struct qdf_mac_addr *)macAddr); |
| 5022 | if (QDF_IS_STATUS_ERROR(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5023 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5024 | 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] | 5025 | return NULL; |
| 5026 | } |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5027 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5028 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5029 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5030 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 5031 | " already exists", |
| 5032 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5033 | return NULL; |
| 5034 | } |
| 5035 | |
| 5036 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5037 | case QDF_STA_MODE: |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5038 | if (!hdd_ctx->config->mac_provision) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5039 | hdd_reset_locally_admin_bit(hdd_ctx, macAddr); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5040 | /* |
| 5041 | * After resetting locally administered bit |
| 5042 | * again check if the new mac address is already |
| 5043 | * exists. |
| 5044 | */ |
| 5045 | status = hdd_check_for_existing_macaddr(hdd_ctx, |
| 5046 | macAddr); |
| 5047 | if (QDF_STATUS_E_FAILURE == status) { |
| 5048 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 5049 | " already exists", |
| 5050 | MAC_ADDR_ARRAY(macAddr)); |
| 5051 | return NULL; |
| 5052 | } |
| 5053 | } |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 5054 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5055 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5056 | case QDF_P2P_CLIENT_MODE: |
| 5057 | case QDF_P2P_DEVICE_MODE: |
| 5058 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 5059 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5060 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5061 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 5062 | name_assign_type, |
| 5063 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5064 | |
| 5065 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5066 | hdd_err("failed to allocate adapter for session %d", |
| 5067 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5068 | return NULL; |
| 5069 | } |
| 5070 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5071 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5072 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5073 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5074 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5075 | else if (QDF_MONITOR_MODE == session_type) |
| 5076 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5077 | else |
| 5078 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5079 | |
| 5080 | adapter->device_mode = session_type; |
| 5081 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5082 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5083 | /* |
| 5084 | * Workqueue which gets scheduled in IPv4 notification |
| 5085 | * callback |
| 5086 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5087 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5088 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5089 | |
| 5090 | #ifdef WLAN_NS_OFFLOAD |
| 5091 | /* |
| 5092 | * Workqueue which gets scheduled in IPv6 |
| 5093 | * notification callback. |
| 5094 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5095 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5096 | hdd_ipv6_notifier_work_queue); |
| 5097 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5098 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5099 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5100 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5101 | |
| 5102 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5103 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5104 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5105 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5106 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5107 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5108 | hdd_nud_init_tracking(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 5109 | if (adapter->device_mode == QDF_STA_MODE || |
| 5110 | adapter->device_mode == QDF_P2P_DEVICE_MODE) |
| 5111 | hdd_sysfs_create_adapter_root_obj(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5112 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 5113 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 5114 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5115 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5116 | case QDF_P2P_GO_MODE: |
| 5117 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5118 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 5119 | name_assign_type, |
| 5120 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5121 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5122 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5123 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5124 | return NULL; |
| 5125 | } |
| 5126 | |
| 5127 | adapter->wdev.iftype = |
| 5128 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5129 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5130 | NL80211_IFTYPE_P2P_GO; |
| 5131 | adapter->device_mode = session_type; |
| 5132 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 5133 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5134 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5135 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5136 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5137 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5138 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5139 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5140 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5141 | |
| 5142 | /* |
| 5143 | * Workqueue which gets scheduled in IPv4 notification |
| 5144 | * callback |
| 5145 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5146 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5147 | hdd_ipv4_notifier_work_queue); |
| 5148 | |
| 5149 | #ifdef WLAN_NS_OFFLOAD |
| 5150 | /* |
| 5151 | * Workqueue which gets scheduled in IPv6 |
| 5152 | * notification callback. |
| 5153 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5154 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5155 | hdd_ipv6_notifier_work_queue); |
| 5156 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5157 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5158 | case QDF_FTM_MODE: |
| 5159 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 5160 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 5161 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5162 | if (NULL == adapter) { |
| 5163 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 5164 | return NULL; |
| 5165 | } |
| 5166 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5167 | adapter->device_mode = session_type; |
| 5168 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5169 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5170 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5171 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5172 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5173 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5174 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5175 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5176 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5177 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5178 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5179 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5180 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5181 | return NULL; |
| 5182 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5183 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5184 | qdf_spinlock_create(&adapter->vdev_lock); |
| 5185 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5186 | hdd_init_completion(adapter); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5187 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 5188 | qdf_list_create(&adapter->blocked_scan_request_q, WLAN_MAX_SCAN_COUNT); |
| 5189 | qdf_mutex_create(&adapter->blocked_scan_request_q_lock); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5190 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5191 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5192 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5193 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5194 | } |
| 5195 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5196 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5197 | if (NULL != adapter) { |
| 5198 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5199 | adapter = NULL; |
| 5200 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5201 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5202 | return NULL; |
| 5203 | } |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 5204 | hdd_apf_context_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5205 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5206 | if (QDF_STATUS_SUCCESS == status) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5207 | policy_mgr_set_concurrency_mode(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5208 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5209 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5210 | /* Adapter successfully added. Increment the vdev count */ |
| 5211 | hdd_ctx->current_intf_count++; |
| 5212 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5213 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5214 | hdd_ctx->current_intf_count); |
| 5215 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 5216 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5217 | } |
| 5218 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 5219 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 5220 | hdd_err("Interface %s wow debug_fs init failed", |
| 5221 | netdev_name(adapter->dev)); |
| 5222 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 5223 | hdd_register_hl_netdev_fc_timer(adapter, |
| 5224 | hdd_tx_resume_timer_expired_handler); |
| 5225 | |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 5226 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 5227 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5228 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 5229 | if (adapter->device_mode == QDF_STA_MODE) |
| 5230 | wlan_hdd_debugfs_csr_init(adapter); |
| 5231 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5232 | return adapter; |
| 5233 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5234 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5235 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 5236 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5237 | |
| 5238 | return NULL; |
| 5239 | } |
| 5240 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5241 | static void __hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5242 | struct hdd_adapter *adapter, |
| 5243 | bool rtnl_held) |
| 5244 | { |
| 5245 | qdf_list_destroy(&adapter->blocked_scan_request_q); |
| 5246 | qdf_mutex_destroy(&adapter->blocked_scan_request_q_lock); |
| 5247 | policy_mgr_clear_concurrency_mode(hdd_ctx->psoc, adapter->device_mode); |
| 5248 | |
| 5249 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5250 | |
| 5251 | if (hdd_ctx->current_intf_count != 0) |
| 5252 | hdd_ctx->current_intf_count--; |
| 5253 | } |
| 5254 | |
| 5255 | void hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5256 | struct hdd_adapter *adapter, |
| 5257 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5258 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5259 | /* |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5260 | * Stop the global bus bandwidth timer while touching the adapter list |
| 5261 | * to avoid bad memory access by the timer handler. |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5262 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5263 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5264 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5265 | hdd_remove_adapter(hdd_ctx, adapter); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5266 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5267 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5268 | /* conditionally restart the bw timer */ |
| 5269 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5270 | } |
| 5271 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5272 | 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] | 5273 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5274 | struct hdd_adapter *adapter; |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5275 | struct hdd_vdev_sync *vdev_sync; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5276 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5277 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5278 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5279 | while (QDF_IS_STATUS_SUCCESS(hdd_remove_front_adapter(hdd_ctx, |
| 5280 | &adapter))) { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5281 | vdev_sync = hdd_vdev_sync_unregister(adapter->dev); |
| 5282 | if (vdev_sync) |
| 5283 | hdd_vdev_sync_wait_for_ops(vdev_sync); |
| 5284 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5285 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
| 5286 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5287 | |
| 5288 | if (vdev_sync) |
| 5289 | hdd_vdev_sync_destroy(vdev_sync); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5290 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5291 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5292 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5293 | } |
| 5294 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5295 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5296 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5297 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5298 | tSirUpdateIE updateIE; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5299 | mac_handle_t mac_handle; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5300 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5301 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5302 | case QDF_STA_MODE: |
| 5303 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5304 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5305 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5306 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5307 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5308 | break; |
| 5309 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5310 | case QDF_SAP_MODE: |
| 5311 | case QDF_P2P_GO_MODE: |
| 5312 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5313 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5314 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5315 | break; |
| 5316 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5317 | case QDF_FTM_MODE: |
| 5318 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5319 | default: |
| 5320 | /* |
| 5321 | * wlan_hdd_reset_prob_rspies should not have been called |
| 5322 | * for these kind of devices |
| 5323 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5324 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5325 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5326 | return; |
| 5327 | } |
| 5328 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5329 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5330 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5331 | updateIE.ieBufferlength = 0; |
| 5332 | updateIE.pAdditionIEBuffer = NULL; |
| 5333 | updateIE.append = true; |
| 5334 | updateIE.notify = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5335 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 5336 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5337 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5338 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5339 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5340 | } |
| 5341 | } |
| 5342 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5343 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 5344 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5345 | { |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5346 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 5347 | struct hdd_station_ctx *sta_ctx; |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5348 | struct sap_context *sap_ctx; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5349 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5350 | union iwreq_data wrqu; |
| 5351 | tSirUpdateIE updateIE; |
| 5352 | unsigned long rc; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 5353 | tsap_config_t *sap_config; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5354 | mac_handle_t mac_handle; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5355 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5356 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5357 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5358 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 5359 | if (adapter->session_id != HDD_SESSION_ID_INVALID) |
| 5360 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5361 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5362 | hdd_nud_ignore_tracking(adapter, true); |
| 5363 | hdd_nud_reset_tracking(adapter); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5364 | hdd_nud_flush_work(adapter); |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5365 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5366 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5367 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5368 | wlan_hdd_netif_queue_control(adapter, |
| 5369 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5370 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 5371 | /* |
| 5372 | * if this is the last active connection check & stop the |
| 5373 | * opportunistic timer first |
| 5374 | */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5375 | if ((policy_mgr_get_connection_count(hdd_ctx->psoc) == 1 && |
| 5376 | policy_mgr_mode_specific_connection_count(hdd_ctx->psoc, |
| 5377 | policy_mgr_convert_device_mode_to_qdf_type( |
| 5378 | adapter->device_mode), NULL) == 1) || |
| 5379 | !policy_mgr_get_connection_count(hdd_ctx->psoc)) |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 5380 | policy_mgr_check_and_stop_opportunistic_timer( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5381 | hdd_ctx->psoc, adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5382 | |
| 5383 | mac_handle = hdd_ctx->mac_handle; |
| 5384 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5385 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5386 | case QDF_STA_MODE: |
| 5387 | case QDF_P2P_CLIENT_MODE: |
| 5388 | case QDF_IBSS_MODE: |
| 5389 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5390 | case QDF_NDI_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5391 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5392 | |
| 5393 | if (adapter->device_mode == QDF_NDI_MODE || |
| 5394 | hdd_conn_is_connected(sta_ctx) || |
| 5395 | hdd_is_connecting(sta_ctx)) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5396 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5397 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5398 | roam_profile = hdd_roam_profile(adapter); |
| 5399 | /* For NDI do not use roam_profile */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5400 | if (adapter->device_mode == QDF_NDI_MODE) |
| 5401 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5402 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5403 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5404 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5405 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5406 | eCSR_BSS_TYPE_START_IBSS) |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5407 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5408 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5409 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5410 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Abhinav Kumar | 19a7a40 | 2018-07-12 17:36:57 +0530 | [diff] [blame] | 5411 | else if (adapter->device_mode == QDF_STA_MODE) |
| 5412 | wlan_hdd_disconnect(adapter, |
| 5413 | eCSR_DISCONNECT_REASON_DEAUTH); |
| 5414 | else |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5415 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5416 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5417 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5418 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5419 | /* success implies disconnect is queued */ |
| 5420 | if (QDF_IS_STATUS_SUCCESS(status) && |
| 5421 | adapter->device_mode != QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5422 | rc = wait_for_completion_timeout( |
| 5423 | &adapter->disconnect_comp_var, |
| 5424 | msecs_to_jiffies |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 5425 | (SME_DISCONNECT_TIMEOUT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5426 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5427 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5428 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5429 | if (QDF_IS_STATUS_ERROR(status)) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5430 | hdd_warn("failed to post disconnect"); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5431 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5432 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5433 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5434 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5435 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5436 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5437 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5438 | |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5439 | wlan_hdd_scan_abort(adapter); |
Wu Gao | 4a1ec8c | 2018-07-23 19:18:40 +0800 | [diff] [blame] | 5440 | wlan_hdd_cleanup_actionframe(adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5441 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5442 | hdd_clear_fils_connection_info(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5443 | hdd_deregister_tx_flow_control(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5444 | |
| 5445 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5446 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5447 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5448 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5449 | #endif |
| 5450 | #endif |
| 5451 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5452 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5453 | struct wlan_objmgr_vdev *vdev; |
| 5454 | |
| 5455 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5456 | if (vdev) { |
| 5457 | wlan_cfg80211_sched_scan_stop(vdev); |
| 5458 | hdd_objmgr_put_vdev(adapter); |
| 5459 | } |
| 5460 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5461 | |
Pragaspathi Thilagaraj | e6f37e0 | 2019-01-04 12:24:33 +0530 | [diff] [blame] | 5462 | /* |
| 5463 | * During vdev destroy, if any STA is in connecting state the |
| 5464 | * roam command will be in active queue and thus vdev destroy is |
| 5465 | * queued in pending queue. In case STA tries to connect to |
| 5466 | * multiple BSSID and fails to connect, due to auth/assoc |
| 5467 | * timeouts it may take more than vdev destroy time to get |
| 5468 | * completed. On vdev destroy timeout vdev is moved to logically |
| 5469 | * deleted state. Once connection is completed, vdev destroy is |
| 5470 | * activated and to release the self-peer ref count it try to |
| 5471 | * get the ref of the vdev, which fails as vdev is logically |
| 5472 | * deleted and this leads to peer ref leak. So before vdev |
| 5473 | * destroy is queued abort any STA ongoing connection to avoid |
| 5474 | * vdev destroy timeout. |
| 5475 | */ |
| 5476 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5477 | hdd_abort_ongoing_sta_connection(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5478 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5479 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5480 | break; |
| 5481 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5482 | case QDF_MONITOR_MODE: |
| 5483 | wlan_hdd_scan_abort(adapter); |
| 5484 | hdd_deregister_tx_flow_control(adapter); |
| 5485 | hdd_vdev_destroy(adapter); |
| 5486 | break; |
| 5487 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5488 | case QDF_SAP_MODE: |
Will Huang | 7049bae | 2018-08-13 17:25:02 +0800 | [diff] [blame] | 5489 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5490 | cds_flush_delayed_work(&adapter->acs_pending_work); |
| 5491 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5492 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5493 | |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5494 | wlan_hdd_scan_abort(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5495 | |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5496 | sap_config = &adapter->session.ap.sap_config; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5497 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 5498 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 5499 | ucfg_ipa_flush(hdd_ctx->pdev); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5500 | |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5501 | /* don't flush pre-cac destroy if we are destroying pre-cac */ |
| 5502 | sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(adapter); |
| 5503 | if (!wlan_sap_is_pre_cac_context(sap_ctx)) |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5504 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5505 | |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5506 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5507 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5508 | case QDF_P2P_GO_MODE: |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5509 | cds_flush_work(&adapter->sap_stop_bss_work); |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5510 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5511 | wlan_hdd_undo_acs(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5512 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5513 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5514 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5515 | |
| 5516 | hdd_deregister_tx_flow_control(adapter); |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5517 | hdd_destroy_acs_timer(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5518 | |
Pragaspathi Thilagaraj | e6f37e0 | 2019-01-04 12:24:33 +0530 | [diff] [blame] | 5519 | /** |
| 5520 | * During vdev destroy, If any STA is in connecting state the |
| 5521 | * roam command will be in active queue and thus vdev destroy is |
| 5522 | * queued in pending queue. In case STA is tries to connected to |
| 5523 | * multiple BSSID and fails to connect, due to auth/assoc |
| 5524 | * timeouts it may take more than vdev destroy time to get |
| 5525 | * completes. If vdev destroy timeout vdev is moved to logically |
| 5526 | * deleted state. Once connection is completed, vdev destroy is |
| 5527 | * activated and to release the self-peer ref count it try to |
| 5528 | * get the ref of the vdev, which fails as vdev is logically |
| 5529 | * deleted and this leads to peer ref leak. So before vdev |
| 5530 | * destroy is queued abort any STA ongoing connection to avoid |
| 5531 | * vdev destroy timeout. |
| 5532 | */ |
| 5533 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5534 | hdd_abort_ongoing_sta_connection(hdd_ctx); |
| 5535 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5536 | mutex_lock(&hdd_ctx->sap_lock); |
| 5537 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5538 | status = wlansap_stop_bss( |
| 5539 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5540 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5541 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5542 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5543 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5544 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5545 | qdf_stop_bss_event); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5546 | status = qdf_wait_for_event_completion( |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5547 | &hostapd_state->qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 5548 | SME_CMD_STOP_BSS_TIMEOUT); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5549 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5550 | hdd_err("failure waiting for wlansap_stop_bss %d", |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5551 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5552 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5553 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5554 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5555 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5556 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5557 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5558 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5559 | adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5560 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5561 | adapter->device_mode, |
| 5562 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5563 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5564 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5565 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5566 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5567 | updateIE.ieBufferlength = 0; |
| 5568 | updateIE.pAdditionIEBuffer = NULL; |
| 5569 | updateIE.append = false; |
| 5570 | updateIE.notify = false; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5571 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5572 | /* Probe bcn reset */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5573 | status = sme_update_add_ie(mac_handle, &updateIE, |
| 5574 | eUPDATE_IE_PROBE_BCN); |
| 5575 | if (status == QDF_STATUS_E_FAILURE) |
| 5576 | hdd_err("Could not pass PROBE_RSP_BCN to PE"); |
| 5577 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5578 | /* Assoc resp reset */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5579 | status = sme_update_add_ie(mac_handle, &updateIE, |
| 5580 | eUPDATE_IE_ASSOC_RESP); |
| 5581 | if (status == QDF_STATUS_E_FAILURE) |
| 5582 | hdd_err("Could not pass ASSOC_RSP to PE"); |
| 5583 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5584 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5585 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5586 | } |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5587 | clear_bit(SOFTAP_INIT_DONE, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5588 | qdf_mem_free(adapter->session.ap.beacon); |
| 5589 | adapter->session.ap.beacon = NULL; |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5590 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5591 | /* |
| 5592 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5593 | */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5594 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5595 | if (vdev) { |
| 5596 | if (policy_mgr_is_dnsc_set(vdev)) |
| 5597 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5598 | hdd_objmgr_put_vdev(adapter); |
| 5599 | } |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5600 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5601 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5602 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5603 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5604 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5605 | #endif |
| 5606 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5607 | |
| 5608 | hdd_vdev_destroy(adapter); |
| 5609 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5610 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5611 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5612 | case QDF_OCB_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5613 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5614 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5615 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 5616 | sta_ctx->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5617 | hdd_deregister_tx_flow_control(adapter); |
| 5618 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5619 | break; |
| 5620 | default: |
| 5621 | break; |
| 5622 | } |
| 5623 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 5624 | hdd_deregister_hl_netdev_fc_timer(adapter); |
| 5625 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5626 | if (adapter->scan_info.default_scan_ies) { |
| 5627 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5628 | adapter->scan_info.default_scan_ies = NULL; |
| 5629 | } |
| 5630 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5631 | hdd_exit(); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5632 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5633 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5634 | } |
| 5635 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5636 | /** |
| 5637 | * hdd_deinit_all_adapters - deinit all adapters |
| 5638 | * @hdd_ctx: HDD context |
| 5639 | * @rtnl_held: True if RTNL lock held |
| 5640 | * |
| 5641 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5642 | 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] | 5643 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5644 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5645 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5646 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5647 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5648 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5649 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5650 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5651 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5652 | } |
| 5653 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5654 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5655 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5656 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5657 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5658 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5659 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5660 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5661 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5662 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5663 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5664 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5665 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5666 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5667 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5668 | } |
| 5669 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5670 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5671 | struct hdd_adapter *adapter) |
| 5672 | { |
| 5673 | switch (adapter->device_mode) { |
| 5674 | case QDF_STA_MODE: |
| 5675 | case QDF_P2P_CLIENT_MODE: |
| 5676 | case QDF_IBSS_MODE: |
| 5677 | case QDF_P2P_DEVICE_MODE: |
| 5678 | case QDF_NDI_MODE: |
| 5679 | wlan_hdd_scan_abort(adapter); |
| 5680 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5681 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5682 | struct wlan_objmgr_vdev *vdev; |
| 5683 | |
| 5684 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5685 | if (vdev) { |
| 5686 | wlan_cfg80211_sched_scan_stop(vdev); |
| 5687 | hdd_objmgr_put_vdev(adapter); |
| 5688 | } |
| 5689 | } |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5690 | break; |
| 5691 | case QDF_P2P_GO_MODE: |
| 5692 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5693 | break; |
| 5694 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5695 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5696 | wlan_hdd_undo_acs(adapter); |
| 5697 | break; |
| 5698 | default: |
| 5699 | break; |
| 5700 | } |
| 5701 | } |
| 5702 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5703 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5704 | /** |
| 5705 | * hdd_adapter_abort_tx_flow() - Abort the tx flow control |
| 5706 | * @pAdapter: pointer to hdd_adapter_t |
| 5707 | * |
| 5708 | * Resume tx and stop the tx flow control timer if the tx is paused |
| 5709 | * and the flow control timer is running. This function is called by |
| 5710 | * SSR to avoid the inconsistency of tx status before and after SSR. |
| 5711 | * |
| 5712 | * Return: void |
| 5713 | */ |
| 5714 | static void hdd_adapter_abort_tx_flow(struct hdd_adapter *adapter) |
| 5715 | { |
| 5716 | if (adapter->hdd_stats.tx_rx_stats.is_txflow_paused && |
| 5717 | QDF_TIMER_STATE_RUNNING == |
| 5718 | qdf_mc_timer_get_current_state( |
| 5719 | &adapter->tx_flow_control_timer)) { |
| 5720 | hdd_tx_resume_timer_expired_handler(adapter); |
| 5721 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 5722 | } |
| 5723 | } |
| 5724 | #endif |
| 5725 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5726 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5727 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5728 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5729 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5730 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5731 | int sta_id; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5732 | bool value; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5733 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5734 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5735 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5736 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5737 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5738 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5739 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5740 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5741 | qdf_opmode_str(adapter->device_mode), |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5742 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5743 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5744 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5745 | hdd_adapter_abort_tx_flow(adapter); |
| 5746 | #endif |
| 5747 | |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5748 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5749 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5750 | /* Stop tdls timers */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5751 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5752 | if (vdev) { |
| 5753 | hdd_notify_tdls_reset_adapter(vdev); |
| 5754 | hdd_objmgr_put_vdev(adapter); |
| 5755 | } |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5756 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5757 | } |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 5758 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5759 | if (value && |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5760 | adapter->device_mode == QDF_SAP_MODE) { |
| 5761 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5762 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5763 | WLAN_CONTROL_PATH); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5764 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5765 | cds_flush_delayed_work( |
| 5766 | &adapter->acs_pending_work); |
| 5767 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5768 | } |
| 5769 | |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5770 | if (test_bit(SOFTAP_BSS_STARTED, |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5771 | &adapter->event_flags)) { |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5772 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5773 | clear_bit(SOFTAP_BSS_STARTED, |
| 5774 | &adapter->event_flags); |
| 5775 | } |
| 5776 | |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5777 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5778 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5779 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5780 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5781 | } |
Nijun Gong | 104ccc7 | 2018-08-07 10:43:56 +0800 | [diff] [blame] | 5782 | /* |
| 5783 | * Clear fc flag if it was set before SSR to avoid TX queues |
| 5784 | * permanently stopped after SSR. |
| 5785 | * Here WLAN_START_ALL_NETIF_QUEUE will actually not start any |
| 5786 | * queue since it's blocked by reason WLAN_CONTROL_PATH. |
| 5787 | */ |
| 5788 | if (adapter->pause_map & (1 << WLAN_DATA_FLOW_CONTROL)) |
| 5789 | wlan_hdd_netif_queue_control(adapter, |
| 5790 | WLAN_START_ALL_NETIF_QUEUE, |
| 5791 | WLAN_DATA_FLOW_CONTROL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5792 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5793 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5794 | |
| 5795 | hdd_deinit_tx_rx(adapter); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5796 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5797 | adapter->device_mode, adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5798 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5799 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5800 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5801 | hdd_wmm_adapter_close(adapter); |
| 5802 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5803 | } |
| 5804 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5805 | if (adapter->device_mode == QDF_STA_MODE) |
| 5806 | hdd_clear_fils_connection_info(adapter); |
| 5807 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5808 | if (adapter->device_mode == QDF_SAP_MODE) { |
Jingxiang Ge | ec11359 | 2018-08-09 15:40:39 +0800 | [diff] [blame] | 5809 | wlansap_cleanup_cac_timer( |
| 5810 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5811 | /* |
| 5812 | * If adapter is SAP, set session ID to invalid |
| 5813 | * since SAP session will be cleanup during SSR. |
| 5814 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5815 | wlansap_set_invalid_session( |
| 5816 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5817 | } |
| 5818 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5819 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5820 | if (adapter->device_mode == QDF_STA_MODE || |
| 5821 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5822 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5823 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5824 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5825 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5826 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
Wu Gao | 6b81fc5 | 2018-05-24 19:27:27 +0800 | [diff] [blame] | 5827 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5828 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5829 | if (adapter->sta_info[sta_id].in_use) { |
| 5830 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5831 | sta_id); |
| 5832 | hdd_softap_deregister_sta(adapter, |
| 5833 | sta_id); |
| 5834 | adapter->sta_info[sta_id].in_use = 0; |
| 5835 | } |
| 5836 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5837 | } |
| 5838 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5839 | hdd_nud_ignore_tracking(adapter, true); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5840 | hdd_nud_reset_tracking(adapter); |
| 5841 | hdd_nud_flush_work(adapter); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5842 | |
| 5843 | if (adapter->device_mode != QDF_SAP_MODE && |
| 5844 | adapter->device_mode != QDF_P2P_GO_MODE && |
| 5845 | adapter->device_mode != QDF_FTM_MODE) |
| 5846 | hdd_set_disconnect_status(adapter, false); |
| 5847 | |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5848 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5849 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5850 | hdd_softap_deinit_tx_rx(adapter); |
Tiger Yu | 8c38770 | 2018-07-06 16:56:42 +0800 | [diff] [blame] | 5851 | hdd_deregister_tx_flow_control(adapter); |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5852 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5853 | /* Destroy vdev which will be recreated during reinit. */ |
| 5854 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5855 | } |
| 5856 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5857 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5858 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5859 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5860 | } |
| 5861 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5862 | bool hdd_is_any_interface_open(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5863 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5864 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5865 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5866 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5867 | hdd_info("FTM mode, don't close the module"); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5868 | return true; |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5869 | } |
| 5870 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5871 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5872 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5873 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5874 | return true; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5875 | } |
| 5876 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5877 | return false; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5878 | } |
| 5879 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5880 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5881 | { |
| 5882 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5883 | return true; |
| 5884 | else |
| 5885 | return false; |
| 5886 | } |
| 5887 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5888 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5889 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5890 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5891 | struct ieee80211_channel *channel, |
| 5892 | const u8 *bssid, const u8 *ssid, |
| 5893 | size_t ssid_len) |
| 5894 | { |
| 5895 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5896 | ssid, ssid_len, |
| 5897 | WLAN_CAPABILITY_ESS, |
| 5898 | WLAN_CAPABILITY_ESS); |
| 5899 | } |
| 5900 | #else |
| 5901 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5902 | struct ieee80211_channel *channel, |
| 5903 | const u8 *bssid, const u8 *ssid, |
| 5904 | size_t ssid_len) |
| 5905 | { |
| 5906 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5907 | ssid, ssid_len, |
| 5908 | IEEE80211_BSS_TYPE_ESS, |
| 5909 | IEEE80211_PRIVACY_ANY); |
| 5910 | } |
| 5911 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5912 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5913 | #if defined CFG80211_CONNECT_BSS || \ |
| 5914 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5915 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5916 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5917 | /** |
| 5918 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5919 | * @timeout_reason: reason for connect timeout |
| 5920 | * |
| 5921 | * This function is used to convert host timeout |
| 5922 | * reason enum to kernel specific enum. |
| 5923 | * |
| 5924 | * Return: nl timeout enum |
| 5925 | */ |
| 5926 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5927 | tSirResultCodes timeout_reason) |
| 5928 | { |
| 5929 | switch (timeout_reason) { |
| 5930 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5931 | return NL80211_TIMEOUT_SCAN; |
| 5932 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5933 | return NL80211_TIMEOUT_AUTH; |
| 5934 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5935 | return NL80211_TIMEOUT_ASSOC; |
| 5936 | default: |
| 5937 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5938 | } |
| 5939 | } |
| 5940 | |
| 5941 | /** |
| 5942 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5943 | * @dev: network device |
| 5944 | * @bssid: bssid to which we want to associate |
| 5945 | * @timeout_reason: reason for connect timeout |
| 5946 | * |
| 5947 | * This API is used to send connection timeout reason to supplicant |
| 5948 | * |
| 5949 | * Return: void |
| 5950 | */ |
| 5951 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5952 | const u8 *bssid, |
| 5953 | tSirResultCodes timeout_reason) |
| 5954 | { |
| 5955 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5956 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5957 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5958 | |
| 5959 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5960 | nl_timeout_reason); |
| 5961 | } |
| 5962 | |
| 5963 | /** |
| 5964 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5965 | * @dev: network device |
| 5966 | * @bssid: bssid to which we want to associate |
| 5967 | * @req_ie: Request Information Element |
| 5968 | * @req_ie_len: len of the req IE |
| 5969 | * @resp_ie: Response IE |
| 5970 | * @resp_ie_len: len of ht response IE |
| 5971 | * @status: status |
| 5972 | * @gfp: Kernel Flag |
| 5973 | * @timeout_reason: reason for connect timeout |
| 5974 | * |
| 5975 | * Return: void |
| 5976 | */ |
| 5977 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5978 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5979 | size_t req_ie_len, const u8 *resp_ie, |
| 5980 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5981 | tSirResultCodes timeout_reason) |
| 5982 | { |
| 5983 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5984 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5985 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5986 | |
| 5987 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5988 | resp_ie, resp_ie_len, status, gfp, |
| 5989 | nl_timeout_reason); |
| 5990 | } |
| 5991 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5992 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5993 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5994 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5995 | const u8 *bssid, |
| 5996 | tSirResultCodes timeout_reason) |
| 5997 | { |
| 5998 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5999 | } |
| 6000 | #endif |
| 6001 | |
| 6002 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6003 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6004 | size_t req_ie_len, const u8 *resp_ie, |
| 6005 | size_t resp_ie_len, int status, gfp_t gfp, |
| 6006 | tSirResultCodes timeout_reason) |
| 6007 | { |
| 6008 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 6009 | resp_ie, resp_ie_len, status, gfp); |
| 6010 | } |
| 6011 | #endif |
| 6012 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6013 | /** |
| 6014 | * hdd_connect_bss() - API to send connection status to supplicant |
| 6015 | * @dev: network device |
| 6016 | * @bssid: bssid to which we want to associate |
| 6017 | * @req_ie: Request Information Element |
| 6018 | * @req_ie_len: len of the req IE |
| 6019 | * @resp_ie: Response IE |
| 6020 | * @resp_ie_len: len of ht response IE |
| 6021 | * @status: status |
| 6022 | * @gfp: Kernel Flag |
| 6023 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6024 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6025 | * |
| 6026 | * The API is a wrapper to send connection status to supplicant |
| 6027 | * |
| 6028 | * Return: Void |
| 6029 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6030 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 6031 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6032 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6033 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6034 | size_t req_ie_len, const u8 *resp_ie, |
| 6035 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6036 | bool connect_timeout, |
| 6037 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6038 | { |
| 6039 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6040 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6041 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6042 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6043 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6044 | } |
| 6045 | #else |
| 6046 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6047 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6048 | size_t req_ie_len, const u8 *resp_ie, |
| 6049 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6050 | bool connect_timeout, |
| 6051 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6052 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6053 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6054 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6055 | } |
| 6056 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6057 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6058 | #if defined(WLAN_FEATURE_FILS_SK) |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6059 | #if (defined(CFG80211_CONNECT_DONE) || \ |
| 6060 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) && \ |
| 6061 | (LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0)) |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6062 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 6063 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6064 | /** |
| 6065 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 6066 | * @fils_params: connect response to supplicant |
| 6067 | * @fils_kek: FILS kek |
| 6068 | * @fils_kek_len: FILS kek length |
| 6069 | * @pmk: FILS PMK |
| 6070 | * @pmk_len: FILS PMK length |
| 6071 | * @pmkid: PMKID |
| 6072 | * @fils_seq_num: FILS Seq number |
| 6073 | * |
| 6074 | * Return: None |
| 6075 | */ |
| 6076 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6077 | *fils_params, const uint8_t *fils_kek, |
| 6078 | size_t fils_kek_len, const uint8_t *pmk, |
| 6079 | size_t pmk_len, const uint8_t *pmkid, |
| 6080 | uint16_t fils_seq_num) |
| 6081 | { |
| 6082 | /* Increament seq number to be used for next FILS */ |
| 6083 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 6084 | fils_params->update_erp_next_seq_num = true; |
| 6085 | fils_params->fils_kek = fils_kek; |
| 6086 | fils_params->fils_kek_len = fils_kek_len; |
| 6087 | fils_params->pmk = pmk; |
| 6088 | fils_params->pmk_len = pmk_len; |
| 6089 | fils_params->pmkid = pmkid; |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6090 | hdd_debug("FILS erp_next_seq_num:%d", |
| 6091 | fils_params->fils_erp_next_seq_num); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6092 | } |
| 6093 | #else |
| 6094 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6095 | *fils_params, const uint8_t |
| 6096 | *fils_kek, size_t fils_kek_len, |
| 6097 | const uint8_t *pmk, size_t pmk_len, |
| 6098 | const uint8_t *pmkid, |
| 6099 | uint16_t fils_seq_num) |
| 6100 | { } |
| 6101 | #endif |
| 6102 | |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6103 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) |
| 6104 | /** |
| 6105 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 6106 | * @fils_params: connect response to supplicant |
| 6107 | * @fils_kek: FILS kek |
| 6108 | * @fils_kek_len: FILS kek length |
| 6109 | * @pmk: FILS PMK |
| 6110 | * @pmk_len: FILS PMK length |
| 6111 | * @pmkid: PMKID |
| 6112 | * @fils_seq_num: FILS Seq number |
| 6113 | * |
| 6114 | * Return: None |
| 6115 | */ |
| 6116 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6117 | *fils_params, const uint8_t *fils_kek, |
| 6118 | size_t fils_kek_len, const uint8_t *pmk, |
| 6119 | size_t pmk_len, const uint8_t *pmkid, |
| 6120 | uint16_t fils_seq_num) |
| 6121 | { |
| 6122 | /* Increament seq number to be used for next FILS */ |
| 6123 | fils_params->fils.erp_next_seq_num = fils_seq_num + 1; |
| 6124 | fils_params->fils.update_erp_next_seq_num = true; |
| 6125 | fils_params->fils.kek = fils_kek; |
| 6126 | fils_params->fils.kek_len = fils_kek_len; |
| 6127 | fils_params->fils.pmk = pmk; |
| 6128 | fils_params->fils.pmk_len = pmk_len; |
| 6129 | fils_params->fils.pmkid = pmkid; |
| 6130 | hdd_debug("FILS erp_next_seq_num:%d", |
| 6131 | fils_params->fils.erp_next_seq_num); |
| 6132 | } |
| 6133 | #endif /* CFG80211_CONNECT_DONE */ |
| 6134 | |
| 6135 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 6136 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 6137 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6138 | void hdd_update_hlp_info(struct net_device *dev, |
| 6139 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6140 | { |
| 6141 | struct sk_buff *skb; |
| 6142 | uint16_t skb_len; |
| 6143 | struct llc_snap_hdr_t *llc_hdr; |
| 6144 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6145 | uint8_t *hlp_data; |
| 6146 | uint16_t hlp_data_len; |
| 6147 | struct fils_join_rsp_params *roam_fils_params |
| 6148 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6149 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6150 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6151 | if (!roam_fils_params) { |
| 6152 | hdd_err("FILS Roam Param NULL"); |
| 6153 | return; |
| 6154 | } |
| 6155 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 6156 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6157 | hdd_err("FILS HLP Data NULL, len %d", |
| 6158 | roam_fils_params->hlp_data_len); |
| 6159 | return; |
| 6160 | } |
| 6161 | |
| 6162 | hlp_data = roam_fils_params->hlp_data; |
| 6163 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 6164 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6165 | /* Calculate skb length */ |
| 6166 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 6167 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 6168 | if (skb == NULL) { |
| 6169 | hdd_err("HLP packet nbuf alloc fails"); |
| 6170 | return; |
| 6171 | } |
| 6172 | |
| 6173 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 6174 | QDF_MAC_ADDR_SIZE); |
| 6175 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 6176 | QDF_MAC_ADDR_SIZE); |
| 6177 | |
| 6178 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 6179 | if (IS_SNAP(llc_hdr)) { |
| 6180 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6181 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6182 | } |
| 6183 | |
| 6184 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 6185 | |
| 6186 | /* |
| 6187 | * This HLP packet is formed from HLP info encapsulated |
| 6188 | * in assoc response frame which is AEAD encrypted. |
| 6189 | * Hence, this checksum validation can be set unnecessary. |
| 6190 | * i.e. network layer need not worry about checksum. |
| 6191 | */ |
| 6192 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 6193 | |
| 6194 | status = hdd_rx_packet_cbk(padapter, skb); |
| 6195 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6196 | hdd_err("Sending HLP packet fails"); |
| 6197 | return; |
| 6198 | } |
| 6199 | hdd_debug("send HLP packet to netif successfully"); |
| 6200 | } |
| 6201 | |
| 6202 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6203 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 6204 | * @dev: network device |
| 6205 | * @bssid: bssid to which we want to associate |
| 6206 | * @bss: cfg80211 bss info |
| 6207 | * @roam_info: information about connected bss |
| 6208 | * @req_ie: Request Information Element |
| 6209 | * @req_ie_len: len of the req IE |
| 6210 | * @resp_ie: Response IE |
| 6211 | * @resp_ie_len: len of ht response IE |
| 6212 | * @status: status |
| 6213 | * @gfp: allocation flags |
| 6214 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6215 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6216 | * |
| 6217 | * This API is used as wrapper to send FILS key/sequence number |
| 6218 | * params etc. to supplicant in case of FILS connection |
| 6219 | * |
| 6220 | * Return: None |
| 6221 | */ |
| 6222 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6223 | struct cfg80211_bss *bss, |
| 6224 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6225 | const u8 *req_ie, size_t req_ie_len, |
| 6226 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6227 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6228 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6229 | { |
| 6230 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6231 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6232 | struct fils_join_rsp_params *roam_fils_params = |
| 6233 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6234 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6235 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 6236 | |
| 6237 | if (!roam_fils_params) { |
| 6238 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 6239 | } else { |
| 6240 | fils_params.status = status; |
| 6241 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 6242 | fils_params.timeout_reason = |
| 6243 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6244 | fils_params.req_ie = req_ie; |
| 6245 | fils_params.req_ie_len = req_ie_len; |
| 6246 | fils_params.resp_ie = resp_ie; |
| 6247 | fils_params.resp_ie_len = resp_ie_len; |
| 6248 | fils_params.bss = bss; |
| 6249 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 6250 | roam_fils_params->kek_len, |
| 6251 | roam_fils_params->fils_pmk, |
| 6252 | roam_fils_params->fils_pmk_len, |
| 6253 | roam_fils_params->fils_pmkid, |
| 6254 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 6255 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6256 | } |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6257 | hdd_debug("FILS indicate connect status %d", fils_params.status); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6258 | |
| 6259 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 6260 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6261 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6262 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6263 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6264 | /* Clear all the FILS key info */ |
| 6265 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 6266 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 6267 | if (roam_fils_params) |
| 6268 | qdf_mem_free(roam_fils_params); |
| 6269 | roam_info->fils_join_rsp = NULL; |
| 6270 | } |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6271 | #else /* CFG80211_CONNECT_DONE */ |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6272 | static inline void |
| 6273 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6274 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6275 | const u8 *req_ie, size_t req_ie_len, |
| 6276 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 6277 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6278 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6279 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6280 | #endif |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6281 | #endif /* WLAN_FEATURE_FILS_SK */ |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6282 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6283 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 6284 | (defined(CFG80211_CONNECT_DONE) || \ |
| 6285 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6286 | /** |
| 6287 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 6288 | * supplicant. |
| 6289 | * @dev: network device |
| 6290 | * @bssid: bssid to which we want to associate |
| 6291 | * @bss: cfg80211 bss info |
| 6292 | * @roam_info: information about connected bss |
| 6293 | * @req_ie: Request Information Element |
| 6294 | * @req_ie_len: len of the req IE |
| 6295 | * @resp_ie: Response IE |
| 6296 | * @resp_ie_len: len of ht response IE |
| 6297 | * @status: status |
| 6298 | * @gfp: allocation flags |
| 6299 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6300 | * @timeout_reason: reason for connect timeout |
| 6301 | * |
| 6302 | * The API is a wrapper to send connection status to supplicant |
| 6303 | * |
| 6304 | * Return: 0 if success else failure |
| 6305 | */ |
| 6306 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 6307 | const u8 *bssid, |
| 6308 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6309 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6310 | size_t req_ie_len, const u8 *resp_ie, |
| 6311 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6312 | bool connect_timeout, |
| 6313 | tSirResultCodes timeout_reason) |
| 6314 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6315 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6316 | if (!roam_info || !roam_info->is_fils_connection) |
| 6317 | return -EINVAL; |
| 6318 | |
| 6319 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 6320 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6321 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6322 | return 0; |
| 6323 | } |
| 6324 | #else |
| 6325 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 6326 | const u8 *bssid, |
| 6327 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6328 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6329 | size_t req_ie_len, const u8 *resp_ie, |
| 6330 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6331 | bool connect_timeout, |
| 6332 | tSirResultCodes timeout_reason) |
| 6333 | { |
| 6334 | return -EINVAL; |
| 6335 | } |
| 6336 | #endif |
| 6337 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6338 | /** |
| 6339 | * hdd_connect_result() - API to send connection status to supplicant |
| 6340 | * @dev: network device |
| 6341 | * @bssid: bssid to which we want to associate |
| 6342 | * @roam_info: information about connected bss |
| 6343 | * @req_ie: Request Information Element |
| 6344 | * @req_ie_len: len of the req IE |
| 6345 | * @resp_ie: Response IE |
| 6346 | * @resp_ie_len: len of ht response IE |
| 6347 | * @status: status |
| 6348 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6349 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6350 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6351 | * |
| 6352 | * The API is a wrapper to send connection status to supplicant |
| 6353 | * and allow runtime suspend |
| 6354 | * |
| 6355 | * Return: Void |
| 6356 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6357 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6358 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6359 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6360 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6361 | bool connect_timeout, |
| 6362 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6363 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6364 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6365 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 6366 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6367 | |
| 6368 | if (WLAN_STATUS_SUCCESS == status) { |
| 6369 | struct ieee80211_channel *chan; |
| 6370 | int freq; |
| 6371 | int chan_no = roam_info->pBssDesc->channelId; |
| 6372 | |
| 6373 | if (chan_no <= 14) |
| 6374 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6375 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6376 | else |
| 6377 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6378 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6379 | |
| 6380 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 6381 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 6382 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 6383 | roam_info->u.pConnectedProfile->SSID.length); |
| 6384 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6385 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6386 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 6387 | roam_info, req_ie, req_ie_len, resp_ie, |
| 6388 | resp_ie_len, status, gfp, connect_timeout, |
| 6389 | timeout_reason) != 0) { |
| 6390 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 6391 | req_ie_len, resp_ie, resp_ie_len, |
| 6392 | status, gfp, connect_timeout, timeout_reason); |
| 6393 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6394 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6395 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6396 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6397 | } |
| 6398 | #else |
| 6399 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6400 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6401 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6402 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6403 | bool connect_timeout, |
| 6404 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6405 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6406 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 6407 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6408 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6409 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 6410 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 6411 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6412 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6413 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6414 | } |
| 6415 | #endif |
| 6416 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6417 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6418 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 6419 | uint32_t bandwidth) |
| 6420 | { |
| 6421 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6422 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 6423 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 6424 | QDF_STATUS status; |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6425 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6426 | struct qdf_mac_addr bssid; |
| 6427 | struct csr_roam_profile roam_profile; |
| 6428 | struct ch_params ch_params; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6429 | eConnectionState connstate; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6430 | |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6431 | if (hdd_get_conparam() != QDF_GLOBAL_MONITOR_MODE && |
| 6432 | adapter->device_mode != QDF_STA_MODE) { |
| 6433 | 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] | 6434 | return -EINVAL; |
| 6435 | } |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6436 | if (adapter->device_mode == QDF_STA_MODE && |
| 6437 | hdd_ctx->config->enable_change_channel_bandwidth) { |
| 6438 | connstate = sta_ctx->conn_info.connState; |
| 6439 | if (eConnectionState_Associated == connstate || |
| 6440 | eConnectionState_Connecting == connstate) { |
| 6441 | return -EINVAL; |
| 6442 | } |
| 6443 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6444 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 6445 | /* Validate Channel */ |
| 6446 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6447 | hdd_err("Channel %d Not supported", chan); |
| 6448 | return -EINVAL; |
| 6449 | } |
| 6450 | |
| 6451 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 6452 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 6453 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 6454 | return -EINVAL; |
| 6455 | } |
| 6456 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 6457 | (bandwidth != CH_WIDTH_MAX)) { |
| 6458 | hdd_err("Only BW20 possible on channel 14"); |
| 6459 | return -EINVAL; |
| 6460 | } |
| 6461 | } |
| 6462 | |
| 6463 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6464 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 6465 | (bandwidth != CH_WIDTH_MAX)) { |
| 6466 | hdd_err("Only BW20 possible on channel 165"); |
| 6467 | return -EINVAL; |
| 6468 | } |
| 6469 | } |
| 6470 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6471 | hdd_debug("Set monitor mode Channel %d", chan); |
| 6472 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 6473 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 6474 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 6475 | roam_profile.phyMode = ch_info->phy_mode; |
| 6476 | roam_profile.ch_params.ch_width = bandwidth; |
| 6477 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6478 | if (hdd_ctx->config->enable_change_channel_bandwidth && |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6479 | (!sme_find_session_by_bssid(mac_handle, adapter->mac_addr.bytes))) { |
| 6480 | status = sme_create_mon_session(mac_handle, |
Rajeev Kumar Sirasanagandla | e3b5991 | 2018-08-24 15:53:31 +0530 | [diff] [blame] | 6481 | adapter->mac_addr.bytes, |
| 6482 | adapter->session_id); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6483 | if (status != QDF_STATUS_SUCCESS) { |
| 6484 | hdd_err("Status: %d Failed to create session.", |
| 6485 | status); |
| 6486 | return qdf_status_to_os_return(status); |
| 6487 | } |
| 6488 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6489 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 6490 | QDF_MAC_ADDR_SIZE); |
| 6491 | |
| 6492 | ch_params.ch_width = bandwidth; |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6493 | wlan_reg_set_channel_params(hdd_ctx->pdev, chan, 0, &ch_params); |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6494 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 6495 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 6496 | return -EINVAL; |
| 6497 | } |
| 6498 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 6499 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 6500 | hdd_err("Failed to change hw mode"); |
| 6501 | return -EINVAL; |
| 6502 | } |
| 6503 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 6504 | status = sme_roam_channel_change_req(hdd_ctx->mac_handle, |
| 6505 | bssid, &ch_params, |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6506 | &roam_profile); |
| 6507 | if (status) { |
| 6508 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 6509 | status); |
| 6510 | } |
| 6511 | |
| 6512 | adapter->mon_chan = chan; |
| 6513 | adapter->mon_bandwidth = bandwidth; |
| 6514 | return qdf_status_to_os_return(status); |
| 6515 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6516 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6517 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6518 | #ifdef MSM_PLATFORM |
| 6519 | /** |
| 6520 | * hdd_stop_p2p_go() - call cfg80211 API to stop P2P GO |
| 6521 | * @adapter: pointer to adapter |
| 6522 | * |
| 6523 | * This function calls cfg80211 API to stop P2P GO |
| 6524 | * |
| 6525 | * Return: None |
| 6526 | */ |
| 6527 | static void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6528 | { |
| 6529 | hdd_debug("[SSR] send stop ap to supplicant"); |
| 6530 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 6531 | } |
| 6532 | |
| 6533 | static inline void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6534 | { |
| 6535 | } |
| 6536 | #else |
| 6537 | static inline void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6538 | { |
| 6539 | } |
| 6540 | |
| 6541 | /** |
| 6542 | * hdd_delete_sta() - call cfg80211 API to delete STA |
| 6543 | * @adapter: pointer to adapter |
| 6544 | * |
| 6545 | * This function calls cfg80211 API to delete STA |
| 6546 | * |
| 6547 | * Return: None |
| 6548 | */ |
| 6549 | static void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6550 | { |
| 6551 | struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT; |
| 6552 | |
| 6553 | hdd_debug("[SSR] send restart supplicant"); |
| 6554 | /* event supplicant to restart */ |
| 6555 | cfg80211_del_sta(adapter->dev, |
| 6556 | (const u8 *)&bcast_mac.bytes[0], |
| 6557 | GFP_KERNEL); |
| 6558 | } |
| 6559 | #endif |
| 6560 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6561 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6562 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6563 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6564 | eConnectionState connState; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6565 | bool value; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6566 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6567 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6568 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6569 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6570 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6571 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6572 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6573 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 6574 | qdf_opmode_str(adapter->device_mode), |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6575 | adapter->device_mode); |
| 6576 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6577 | hdd_wmm_init(adapter); |
| 6578 | |
| 6579 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6580 | case QDF_STA_MODE: |
| 6581 | case QDF_P2P_CLIENT_MODE: |
| 6582 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6583 | |
| 6584 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 6585 | ->conn_info.connState; |
| 6586 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6587 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6588 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 6589 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6590 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6591 | /* Indicate disconnect event to supplicant |
| 6592 | * if associated previously |
| 6593 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6594 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 6595 | eConnectionState_IbssConnected == connState || |
| 6596 | eConnectionState_NotConnected == connState || |
| 6597 | eConnectionState_IbssDisconnected == connState || |
| 6598 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6599 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6600 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6601 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6602 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6603 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 6604 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 6605 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 6606 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 6607 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6608 | |
| 6609 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 6610 | wlan_hdd_cfg80211_indicate_disconnect( |
| 6611 | adapter->dev, false, |
| 6612 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6613 | } else if (eConnectionState_Connecting == connState) { |
| 6614 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6615 | * Indicate connect failure to supplicant if we |
| 6616 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6617 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6618 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6619 | NULL, 0, NULL, 0, |
| 6620 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6621 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6622 | } |
| 6623 | |
| 6624 | hdd_register_tx_flow_control(adapter, |
| 6625 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6626 | hdd_tx_resume_cb, |
| 6627 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6628 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 6629 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6630 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6631 | break; |
| 6632 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6633 | case QDF_SAP_MODE: |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 6634 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6635 | &value); |
| 6636 | if (value) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6637 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6638 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6639 | break; |
| 6640 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6641 | case QDF_P2P_GO_MODE: |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6642 | hdd_delete_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6643 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6644 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6645 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6646 | hdd_set_mon_rx_cb(adapter->dev); |
| 6647 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6648 | adapter->mon_bandwidth); |
| 6649 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6650 | default: |
| 6651 | break; |
| 6652 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6653 | /* |
| 6654 | * Action frame registered in one adapter which will |
| 6655 | * applicable to all interfaces |
| 6656 | */ |
| 6657 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6658 | } |
| 6659 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6660 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6661 | if (!hdd_is_interface_up(adapter)) |
| 6662 | continue; |
| 6663 | |
| 6664 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 6665 | hdd_stop_p2p_go(adapter); |
| 6666 | } |
| 6667 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6668 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6669 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6670 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6671 | } |
| 6672 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6673 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6674 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6675 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6676 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6677 | qdf_list_node_t *node; |
| 6678 | |
| 6679 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6680 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6681 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6682 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6683 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6684 | |
| 6685 | if (QDF_IS_STATUS_ERROR(status)) |
| 6686 | return status; |
| 6687 | |
| 6688 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6689 | |
| 6690 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6691 | } |
| 6692 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6693 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6694 | struct hdd_adapter *current_adapter, |
| 6695 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6696 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6697 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6698 | qdf_list_node_t *node; |
| 6699 | |
| 6700 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6701 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6702 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6703 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6704 | ¤t_adapter->node, |
| 6705 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6706 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6707 | |
| 6708 | if (QDF_IS_STATUS_ERROR(status)) |
| 6709 | return status; |
| 6710 | |
| 6711 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6712 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6713 | return status; |
| 6714 | } |
| 6715 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6716 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6717 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6718 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6719 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6720 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6721 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6722 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6723 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6724 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6725 | return status; |
| 6726 | } |
| 6727 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6728 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6729 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6730 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6731 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6732 | qdf_list_node_t *node; |
| 6733 | |
| 6734 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6735 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6736 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6737 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6738 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6739 | |
| 6740 | if (QDF_IS_STATUS_ERROR(status)) |
| 6741 | return status; |
| 6742 | |
| 6743 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6744 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6745 | return status; |
| 6746 | } |
| 6747 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6748 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6749 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6750 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6751 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6752 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6753 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6754 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6755 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6756 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6757 | return status; |
| 6758 | } |
| 6759 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6760 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6761 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6762 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6763 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6764 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6765 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6766 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6767 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6768 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6769 | return status; |
| 6770 | } |
| 6771 | |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 6772 | struct hdd_adapter *hdd_get_adapter_by_rand_macaddr( |
| 6773 | struct hdd_context *hdd_ctx, tSirMacAddr mac_addr) |
| 6774 | { |
| 6775 | struct hdd_adapter *adapter; |
| 6776 | |
| 6777 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6778 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6779 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6780 | adapter->device_mode == QDF_P2P_DEVICE_MODE) && |
| 6781 | ucfg_p2p_check_random_mac(hdd_ctx->psoc, |
| 6782 | adapter->session_id, mac_addr)) |
| 6783 | return adapter; |
| 6784 | } |
| 6785 | |
| 6786 | return NULL; |
| 6787 | } |
| 6788 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6789 | struct hdd_adapter *hdd_get_adapter_by_macaddr(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6790 | tSirMacAddr macAddr) |
| 6791 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6792 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6793 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6794 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6795 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 6796 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6797 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6798 | } |
| 6799 | |
| 6800 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6801 | } |
| 6802 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6803 | struct hdd_adapter *hdd_get_adapter_by_vdev(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6804 | uint32_t vdev_id) |
| 6805 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6806 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6807 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6808 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6809 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6810 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6811 | } |
| 6812 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6813 | return NULL; |
| 6814 | } |
| 6815 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6816 | /** |
| 6817 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 6818 | * the sessionid |
| 6819 | * @hdd_ctx: hdd context. |
| 6820 | * @sme_session_id: sme session is for the adapter to get. |
| 6821 | * |
| 6822 | * This function is used to get the adapter with provided session id |
| 6823 | * |
| 6824 | * Return: adapter pointer if found |
| 6825 | * |
| 6826 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6827 | struct hdd_adapter * |
| 6828 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6829 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6830 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6831 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6832 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6833 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6834 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6835 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6836 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6837 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6838 | return NULL; |
| 6839 | } |
| 6840 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6841 | 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] | 6842 | const char *iface_name) |
| 6843 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6844 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6845 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6846 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6847 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6848 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6849 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6850 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6851 | return NULL; |
| 6852 | } |
| 6853 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6854 | /** |
| 6855 | * hdd_get_adapter() - to get adapter matching the mode |
| 6856 | * @hdd_ctx: hdd context |
| 6857 | * @mode: adapter mode |
| 6858 | * |
| 6859 | * This routine will return the pointer to adapter matching |
| 6860 | * with the passed mode. |
| 6861 | * |
| 6862 | * Return: pointer to adapter or null |
| 6863 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6864 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6865 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6866 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6867 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6868 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6869 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6870 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6871 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6872 | } |
| 6873 | |
| 6874 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6875 | } |
| 6876 | |
Jeff Johnson | 36a0abf | 2018-05-20 11:24:25 -0700 | [diff] [blame] | 6877 | enum QDF_OPMODE hdd_get_device_mode(uint32_t session_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6878 | { |
| 6879 | struct hdd_context *hdd_ctx; |
| 6880 | struct hdd_adapter *adapter; |
| 6881 | |
| 6882 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6883 | if (!hdd_ctx) { |
| 6884 | hdd_err("Invalid HDD context"); |
| 6885 | return QDF_MAX_NO_OF_MODE; |
| 6886 | } |
| 6887 | |
| 6888 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6889 | if (!adapter) { |
| 6890 | hdd_err("Invalid HDD adapter"); |
| 6891 | return QDF_MAX_NO_OF_MODE; |
| 6892 | } |
| 6893 | |
| 6894 | return adapter->device_mode; |
| 6895 | } |
| 6896 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6897 | /** |
| 6898 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6899 | * @hdd_ctx: Pointer to the HDD context. |
| 6900 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6901 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6902 | * QDF_STA_MODE, |
| 6903 | * QDF_P2P_CLIENT_MODE, |
| 6904 | * QDF_SAP_MODE, |
| 6905 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6906 | * |
| 6907 | * This API returns the operating channel of the requested device mode |
| 6908 | * |
| 6909 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6910 | * not connected. |
| 6911 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6912 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6913 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6914 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6915 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6916 | uint8_t operatingChannel = 0; |
| 6917 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6918 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6919 | if (mode == adapter->device_mode) { |
| 6920 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6921 | case QDF_STA_MODE: |
| 6922 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6923 | if (hdd_conn_is_connected |
| 6924 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6925 | (adapter))) { |
| 6926 | operatingChannel = |
| 6927 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6928 | (adapter))->conn_info. |
| 6929 | operationChannel; |
| 6930 | } |
| 6931 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6932 | case QDF_SAP_MODE: |
| 6933 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6934 | /* softap connection info */ |
| 6935 | if (test_bit |
| 6936 | (SOFTAP_BSS_STARTED, |
| 6937 | &adapter->event_flags)) |
| 6938 | operatingChannel = |
| 6939 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6940 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6941 | break; |
| 6942 | default: |
| 6943 | break; |
| 6944 | } |
| 6945 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6946 | /* Found the device of interest. break the loop */ |
| 6947 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6948 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6949 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6950 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6951 | return operatingChannel; |
| 6952 | } |
| 6953 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6954 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6955 | hdd_ctx) |
| 6956 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6957 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6958 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6959 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6960 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6961 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6962 | if (adapter->device_mode == QDF_STA_MODE || |
| 6963 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6964 | adapter->device_mode == QDF_IBSS_MODE || |
| 6965 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6966 | adapter->device_mode == QDF_SAP_MODE || |
| 6967 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6968 | hdd_unregister_wext(adapter->dev); |
| 6969 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6970 | } |
| 6971 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6972 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6973 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6974 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6975 | } |
| 6976 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6977 | 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] | 6978 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6979 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6980 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6981 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6982 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6983 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6984 | if (adapter->device_mode == QDF_STA_MODE || |
| 6985 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6986 | adapter->device_mode == QDF_IBSS_MODE || |
| 6987 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6988 | adapter->device_mode == QDF_SAP_MODE || |
| 6989 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6990 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6991 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6992 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6993 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6994 | } |
| 6995 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6996 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6997 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6998 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6999 | } |
| 7000 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7001 | /** |
| 7002 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 7003 | * adapters |
| 7004 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 7005 | * |
| 7006 | * return: QDF_STATUS_SUCCESS |
| 7007 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7008 | 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] | 7009 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7010 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7011 | int err; |
| 7012 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7013 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7014 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7015 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7016 | if (adapter->device_mode == QDF_STA_MODE || |
| 7017 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 7018 | adapter->device_mode == QDF_IBSS_MODE || |
| 7019 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 7020 | adapter->device_mode == QDF_SAP_MODE || |
| 7021 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7022 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 7023 | if (err) |
| 7024 | hdd_err("Unable to stop scheduled scan"); |
| 7025 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7026 | } |
| 7027 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7028 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7029 | |
| 7030 | return QDF_STATUS_SUCCESS; |
| 7031 | } |
| 7032 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7033 | #ifdef WLAN_NS_OFFLOAD |
| 7034 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7035 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7036 | * @hdd_ctx: Pointer to hdd context |
| 7037 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7038 | * Unregister for IPv6 address change notifications. |
| 7039 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7040 | * Return: None |
| 7041 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7042 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7043 | { |
| 7044 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7045 | } |
| 7046 | |
| 7047 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7048 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7049 | * @hdd_ctx: Pointer to hdd context |
| 7050 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7051 | * Register for IPv6 address change notifications. |
| 7052 | * |
| 7053 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7054 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7055 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7056 | { |
| 7057 | int ret; |
| 7058 | |
| 7059 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 7060 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7061 | if (ret) { |
| 7062 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 7063 | goto out; |
| 7064 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7065 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7066 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7067 | out: |
| 7068 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7069 | } |
| 7070 | #else |
| 7071 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7072 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7073 | * @hdd_ctx: Pointer to hdd context |
| 7074 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7075 | * Unregister for IPv6 address change notifications. |
| 7076 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7077 | * Return: None |
| 7078 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7079 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7080 | { |
| 7081 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7082 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7083 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7084 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7085 | * @hdd_ctx: Pointer to hdd context |
| 7086 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7087 | * Register for IPv6 address change notifications. |
| 7088 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7089 | * Return: None |
| 7090 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7091 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7092 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7093 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7094 | } |
| 7095 | #endif |
| 7096 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7097 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 7098 | { |
| 7099 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 7100 | adapter->disconnection_in_progress = status; |
| 7101 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 7102 | hdd_debug("setting disconnection status: %d", status); |
| 7103 | } |
| 7104 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7105 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7106 | * hdd_register_notifiers - Register netdev notifiers. |
| 7107 | * @hdd_ctx: HDD context |
| 7108 | * |
| 7109 | * Register netdev notifiers like IPv4 and IPv6. |
| 7110 | * |
| 7111 | * Return: 0 on success and errno on failure |
| 7112 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7113 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7114 | { |
| 7115 | int ret; |
| 7116 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7117 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 7118 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7119 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7120 | |
| 7121 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 7122 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 7123 | if (ret) { |
| 7124 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 7125 | goto unregister_ip6_notifier; |
| 7126 | } |
| 7127 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7128 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 7129 | if (ret) { |
| 7130 | hdd_err("Failed to register netevent notifier: %d", |
| 7131 | ret); |
| 7132 | goto unregister_inetaddr_notifier; |
| 7133 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7134 | return 0; |
| 7135 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7136 | unregister_inetaddr_notifier: |
| 7137 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7138 | unregister_ip6_notifier: |
| 7139 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7140 | out: |
| 7141 | return ret; |
| 7142 | |
| 7143 | } |
| 7144 | |
| 7145 | /** |
| 7146 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 7147 | * @hdd_ctx: HDD context |
| 7148 | * |
| 7149 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 7150 | * |
| 7151 | * Return: None. |
| 7152 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7153 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7154 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7155 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7156 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 7157 | |
| 7158 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7159 | } |
| 7160 | |
| 7161 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7162 | * hdd_exit_netlink_services - Exit netlink services |
| 7163 | * @hdd_ctx: HDD context |
| 7164 | * |
| 7165 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7166 | * nl service. |
| 7167 | * |
| 7168 | * Return: None. |
| 7169 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7170 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7171 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7172 | spectral_scan_deactivate_service(); |
| 7173 | cnss_diag_deactivate_service(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7174 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7175 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7176 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7177 | |
| 7178 | nl_srv_exit(); |
| 7179 | } |
| 7180 | |
| 7181 | /** |
| 7182 | * hdd_init_netlink_services- Init netlink services |
| 7183 | * @hdd_ctx: HDD context |
| 7184 | * |
| 7185 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7186 | * nl service. |
| 7187 | * |
| 7188 | * Return: 0 on success and errno on failure. |
| 7189 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7190 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7191 | { |
| 7192 | int ret; |
| 7193 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7194 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7195 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7196 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7197 | goto out; |
| 7198 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7199 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7200 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 7201 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7202 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7203 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7204 | goto err_nl_srv; |
| 7205 | } |
| 7206 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7207 | ptt_sock_activate_svc(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7208 | |
| 7209 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 7210 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7211 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7212 | |
| 7213 | ret = cnss_diag_activate_service(); |
| 7214 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7215 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7216 | goto err_close_cesium; |
| 7217 | } |
| 7218 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7219 | spectral_scan_activate_service(); |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 7220 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7221 | return 0; |
| 7222 | |
| 7223 | err_close_cesium: |
| 7224 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7225 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7226 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7227 | err_nl_srv: |
| 7228 | nl_srv_exit(); |
| 7229 | out: |
| 7230 | return ret; |
| 7231 | } |
| 7232 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7233 | /** |
| 7234 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 7235 | * @hdd_ctx: HDD context. |
| 7236 | * |
| 7237 | * Destroy RX wakelock. |
| 7238 | * |
| 7239 | * Return: None. |
| 7240 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7241 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7242 | { |
| 7243 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 7244 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7245 | |
| 7246 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7247 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 7248 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7249 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7250 | * Create RX wakelock. |
| 7251 | * |
| 7252 | * Return: None. |
| 7253 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7254 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7255 | { |
| 7256 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 7257 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7258 | |
| 7259 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7260 | * hdd_context_deinit() - Deinitialize HDD context |
| 7261 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7262 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7263 | * Deinitialize HDD context along with all the feature specific contexts but |
| 7264 | * do not free hdd context itself. Caller of this API is supposed to free |
| 7265 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7266 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7267 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7268 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7269 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7270 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7271 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 7272 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7273 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7274 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7275 | hdd_sap_context_destroy(hdd_ctx); |
| 7276 | |
| 7277 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 7278 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7279 | hdd_scan_context_destroy(hdd_ctx); |
| 7280 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 7281 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7282 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7283 | return 0; |
| 7284 | } |
| 7285 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7286 | void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7287 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 7288 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 7289 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7290 | hdd_exit_netlink_services(hdd_ctx); |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 7291 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 7292 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7293 | hdd_context_deinit(hdd_ctx); |
| 7294 | |
Dustin Brown | db2df2e | 2018-10-31 15:29:24 -0700 | [diff] [blame] | 7295 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 7296 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7297 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7298 | hdd_ctx->config = NULL; |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 7299 | cfg_release(); |
| 7300 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7301 | wiphy_free(hdd_ctx->wiphy); |
| 7302 | } |
| 7303 | |
| 7304 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7305 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 7306 | * |
| 7307 | * This function is used to destroy bug report lock |
| 7308 | * |
| 7309 | * Return: None |
| 7310 | */ |
| 7311 | static void wlan_destroy_bug_report_lock(void) |
| 7312 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 7313 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7314 | |
| 7315 | p_cds_context = cds_get_global_context(); |
| 7316 | if (!p_cds_context) { |
| 7317 | hdd_err("cds context is NULL"); |
| 7318 | return; |
| 7319 | } |
| 7320 | |
| 7321 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 7322 | } |
| 7323 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7324 | #ifdef DISABLE_CHANNEL_LIST |
| 7325 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7326 | { |
| 7327 | qdf_mutex_destroy(&hdd_ctx->cache_channel_lock); |
| 7328 | } |
| 7329 | #else |
| 7330 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7331 | { |
| 7332 | } |
| 7333 | #endif |
| 7334 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 7335 | void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7336 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7337 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7338 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7339 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7340 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7341 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 7342 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Dustin Brown | 6470aba | 2018-09-05 09:49:58 -0700 | [diff] [blame] | 7343 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7344 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7345 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7346 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7347 | if (QDF_TIMER_STATE_RUNNING == |
| 7348 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 7349 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7350 | } |
| 7351 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7352 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7353 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 7354 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7355 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7356 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7357 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7358 | hdd_ctx->last_acs_channel_list = NULL; |
| 7359 | hdd_ctx->num_of_channels = 0; |
| 7360 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7361 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7362 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7363 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 7364 | driver_status = hdd_ctx->driver_status; |
| 7365 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 7366 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7367 | /* |
| 7368 | * Powersave Offload Case |
| 7369 | * Disable Idle Power Save Mode |
| 7370 | */ |
| 7371 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 7372 | /* clear the scan queue in all the scenarios */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7373 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7374 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7375 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 7376 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 7377 | /* |
| 7378 | * Cancel any outstanding scan requests. We are about to close |
| 7379 | * all of our adapters, but an adapter structure is what SME |
| 7380 | * passes back to our callback function. Hence if there |
| 7381 | * are any outstanding scan requests then there is a |
| 7382 | * race condition between when the adapter is closed and |
| 7383 | * when the callback is invoked. We try to resolve that |
| 7384 | * race condition here by canceling any outstanding scans |
| 7385 | * before we close the adapters. |
| 7386 | * Note that the scans may be cancelled in an asynchronous |
| 7387 | * manner, so ideally there needs to be some kind of |
| 7388 | * synchronization. Rather than introduce a new |
| 7389 | * synchronization here, we will utilize the fact that we are |
| 7390 | * about to Request Full Power, and since that is synchronized, |
| 7391 | * the expectation is that by the time Request Full Power has |
| 7392 | * completed, all scans will be cancelled |
| 7393 | */ |
| 7394 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7395 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 7396 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 7397 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7398 | } |
| 7399 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 7400 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7401 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 7402 | |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 7403 | qdf_dp_trace_deinit(); |
| 7404 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 7405 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 7406 | |
Visweswara Tanuku | c029a20 | 2018-11-27 10:42:10 +0530 | [diff] [blame] | 7407 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 7408 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 7409 | hdd_driver_memdump_deinit(); |
| 7410 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 7411 | qdf_nbuf_deinit_replenish_timer(); |
| 7412 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7413 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 7414 | hdd_info("Release wakelock for monitor mode!"); |
| 7415 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 7416 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 7417 | } |
| 7418 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7419 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7420 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7421 | wlan_hdd_cache_chann_mutex_destroy(hdd_ctx); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7422 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 7423 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7424 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 7425 | hdd_close_all_adapters(hdd_ctx, false); |
| 7426 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 7427 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7428 | /* |
| 7429 | * If there is re_init failure wiphy would have already de-registered |
| 7430 | * check the wiphy status before un-registering again |
| 7431 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 7432 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7433 | wiphy_unregister(wiphy); |
| 7434 | wlan_hdd_cfg80211_deinit(wiphy); |
| 7435 | hdd_lpass_notify_stop(hdd_ctx); |
| 7436 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 7437 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7438 | hdd_exit_netlink_services(hdd_ctx); |
| 7439 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7440 | #ifdef FEATURE_WLAN_CH_AVOID |
| 7441 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 7442 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7443 | } |
| 7444 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7445 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7446 | /** |
| 7447 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7448 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7449 | * |
| 7450 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 7451 | * Then new ACS request will do a fresh scan without reusing the cached |
| 7452 | * scan information. |
| 7453 | * |
| 7454 | * Return: void |
| 7455 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 7456 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7457 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7458 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7459 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7460 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7461 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7462 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7463 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7464 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7465 | hdd_ctx->last_acs_channel_list = NULL; |
| 7466 | hdd_ctx->num_of_channels = 0; |
| 7467 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7468 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7469 | mac_handle = hdd_ctx->mac_handle; |
| 7470 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7471 | return; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7472 | sme_scan_flush_result(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7473 | } |
| 7474 | #endif |
| 7475 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7476 | /** |
| 7477 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 7478 | * @state: state |
| 7479 | * |
| 7480 | * This function notifies FW with modem power status |
| 7481 | * |
| 7482 | * Return: 0 if successful, error number otherwise |
| 7483 | */ |
| 7484 | int hdd_wlan_notify_modem_power_state(int state) |
| 7485 | { |
| 7486 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7487 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7488 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7489 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7490 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7491 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7492 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7493 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7494 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7495 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7496 | mac_handle = hdd_ctx->mac_handle; |
| 7497 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7498 | return -EINVAL; |
| 7499 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7500 | qdf_status = sme_notify_modem_power_state(mac_handle, state); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7501 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7502 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7503 | state); |
| 7504 | return -EINVAL; |
| 7505 | } |
| 7506 | return 0; |
| 7507 | } |
| 7508 | |
| 7509 | /** |
| 7510 | * |
| 7511 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 7512 | * @adapter - Pointer to the HDD |
| 7513 | * |
| 7514 | * Return: None |
| 7515 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7516 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7517 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7518 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7519 | |
| 7520 | /* |
| 7521 | * Send ready indication to the HDD. This will kick off the MAC |
| 7522 | * into a 'running' state and should kick off an initial scan. |
| 7523 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7524 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->mac_handle); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7525 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7526 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 7527 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7528 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7529 | } |
| 7530 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7531 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7532 | } |
| 7533 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 7534 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 7535 | { |
| 7536 | struct hdd_adapter *adapter; |
| 7537 | |
| 7538 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7539 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 7540 | return adapter; |
| 7541 | } |
| 7542 | |
| 7543 | return NULL; |
| 7544 | } |
| 7545 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7546 | /* wake lock APIs for HDD */ |
| 7547 | void hdd_prevent_suspend(uint32_t reason) |
| 7548 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7549 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7550 | } |
| 7551 | |
| 7552 | void hdd_allow_suspend(uint32_t reason) |
| 7553 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7554 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7555 | } |
| 7556 | |
| 7557 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 7558 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 7559 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 7560 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7561 | } |
| 7562 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7563 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7564 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7565 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7566 | return sme_init_chan_list(hdd_ctx->mac_handle, |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 7567 | hdd_ctx->reg.alpha2, |
| 7568 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7569 | } |
| 7570 | |
| 7571 | /** |
| 7572 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 7573 | * @hdd_ctx: Pointer to the hdd context |
| 7574 | * |
| 7575 | * HDD function to know if hardware supports 5GHz |
| 7576 | * |
| 7577 | * Return: true if hardware supports 5GHz |
| 7578 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7579 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7580 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7581 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7582 | return true; |
| 7583 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7584 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7585 | return true; |
| 7586 | else |
| 7587 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7588 | } |
| 7589 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7590 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7591 | { |
| 7592 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7593 | int ret_val; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7594 | uint32_t channel_bonding_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7595 | |
| 7596 | wiphy = hdd_ctx->wiphy; |
| 7597 | |
| 7598 | /* |
| 7599 | * The channel information in |
| 7600 | * wiphy needs to be initialized before wiphy registration |
| 7601 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7602 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7603 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7604 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7605 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7606 | } |
| 7607 | |
| 7608 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7609 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7610 | #else |
| 7611 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7612 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7613 | WIPHY_WOWLAN_DISCONNECT | |
| 7614 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7615 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7616 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7617 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7618 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7619 | |
| 7620 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7621 | WOW_MAX_FILTERS_PER_LIST); |
| 7622 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7623 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7624 | #endif |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7625 | ucfg_mlme_get_channel_bonding_24ghz(hdd_ctx->psoc, |
| 7626 | &channel_bonding_mode); |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7627 | if (hdd_ctx->obss_scan_offload) { |
| 7628 | hdd_debug("wmi_service_obss_scan supported"); |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7629 | } else if (channel_bonding_mode) { |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7630 | hdd_debug("enable wpa_supp obss_scan"); |
| 7631 | wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; |
| 7632 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7633 | |
| 7634 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7635 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7636 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7637 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7638 | return ret_val; |
| 7639 | } |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7640 | |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7641 | /* Check the kernel version for upstream commit aced43ce780dc5 that |
| 7642 | * has support for processing user cell_base hints when wiphy is |
| 7643 | * self managed or check the backport flag for the same. |
| 7644 | */ |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7645 | #if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \ |
| 7646 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7647 | hdd_send_wiphy_regd_sync_event(hdd_ctx); |
| 7648 | #endif |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7649 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7650 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7651 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7652 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7653 | } |
| 7654 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7655 | #ifdef MSM_PLATFORM |
| 7656 | /** |
| 7657 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7658 | * @hdd_ctx - handle to hdd context |
| 7659 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7660 | * |
| 7661 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7662 | * Stats show up in wlan driver logs. |
| 7663 | * |
| 7664 | * Returns: None |
| 7665 | */ |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7666 | static void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7667 | bool data_in_interval) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7668 | { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7669 | static uint32_t counter; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7670 | static bool data_in_time_period; |
| 7671 | ol_txrx_pdev_handle pdev; |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7672 | ol_txrx_soc_handle soc; |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7673 | uint32_t periodic_stats_disp_time = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7674 | |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7675 | ucfg_mlme_stats_get_periodic_display_time(hdd_ctx->psoc, |
| 7676 | &periodic_stats_disp_time); |
| 7677 | if (!periodic_stats_disp_time) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7678 | return; |
| 7679 | |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7680 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 7681 | if (!soc) { |
| 7682 | hdd_err("soc is NULL"); |
| 7683 | return; |
| 7684 | } |
| 7685 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7686 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7687 | if (!pdev) { |
| 7688 | hdd_err("pdev is NULL"); |
| 7689 | return; |
| 7690 | } |
| 7691 | |
| 7692 | counter++; |
| 7693 | if (data_in_interval) |
| 7694 | data_in_time_period = data_in_interval; |
| 7695 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7696 | if (counter * hdd_ctx->config->bus_bw_compute_interval >= |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7697 | periodic_stats_disp_time * 1000) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7698 | if (data_in_time_period) { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7699 | wlan_hdd_display_txrx_stats(hdd_ctx); |
Mohit Khanna | c964965 | 2018-11-28 18:10:28 -0800 | [diff] [blame] | 7700 | dp_txrx_ext_dump_stats(soc, CDP_DP_RX_THREAD_STATS); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7701 | cdp_display_stats(soc, |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7702 | CDP_RX_RING_STATS, |
| 7703 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7704 | cdp_display_stats(soc, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7705 | CDP_TXRX_PATH_STATS, |
| 7706 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7707 | wlan_hdd_display_netif_queue_history |
| 7708 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7709 | qdf_dp_trace_dump_stats(); |
| 7710 | } |
| 7711 | counter = 0; |
| 7712 | data_in_time_period = false; |
| 7713 | } |
| 7714 | } |
| 7715 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7716 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7717 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7718 | * @hdd_ctx: pointer to struct hdd_context |
| 7719 | * |
| 7720 | * Return: none |
| 7721 | */ |
| 7722 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7723 | { |
| 7724 | struct hdd_adapter *adapter; |
| 7725 | |
| 7726 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7727 | hdd_send_rps_disable_ind(adapter); |
| 7728 | } |
| 7729 | |
| 7730 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7731 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7732 | * @hdd_ctx - handle to hdd context |
| 7733 | * @tx_packets - transmit packet count |
| 7734 | * @rx_packets - receive packet count |
| 7735 | * |
| 7736 | * The function controls the bus bandwidth and dynamic control of |
| 7737 | * tcp delayed ack configuration |
| 7738 | * |
| 7739 | * Returns: None |
| 7740 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7741 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7742 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7743 | const uint64_t tx_packets, |
| 7744 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7745 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7746 | u64 total_pkts = tx_packets + rx_packets; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7747 | uint64_t temp_tx = 0, avg_rx = 0; |
| 7748 | uint64_t no_rx_offload_pkts = 0, avg_no_rx_offload_pkts = 0; |
| 7749 | uint64_t rx_offload_pkts = 0, avg_rx_offload_pkts = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7750 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7751 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7752 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7753 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7754 | uint16_t index = 0; |
| 7755 | bool vote_level_change = false; |
| 7756 | bool rx_level_change = false; |
| 7757 | bool tx_level_change = false; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7758 | bool rxthread_high_tput_req = false; |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7759 | bool dptrace_high_tput_req; |
Srinivas Girigowda | 5033534 | 2018-09-07 15:21:01 -0700 | [diff] [blame] | 7760 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7761 | if (total_pkts > hdd_ctx->config->bus_bw_high_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7762 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7763 | else if (total_pkts > hdd_ctx->config->bus_bw_medium_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7764 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7765 | else if (total_pkts > hdd_ctx->config->bus_bw_low_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7766 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7767 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7768 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7769 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7770 | dptrace_high_tput_req = |
| 7771 | next_vote_level > PLD_BUS_WIDTH_NONE ? true : false; |
| 7772 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7773 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7774 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7775 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7776 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7777 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7778 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7779 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7780 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7781 | if (hdd_ctx->hbw_requested) { |
| 7782 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7783 | hdd_ctx->hbw_requested = false; |
| 7784 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7785 | if (hdd_ctx->dynamic_rps) |
| 7786 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7787 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7788 | if (!hdd_ctx->hbw_requested) { |
| 7789 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7790 | hdd_ctx->hbw_requested = true; |
| 7791 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7792 | if (hdd_ctx->dynamic_rps) |
| 7793 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7794 | } |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7795 | |
Manjunathappa Prakash | cb6df76 | 2018-05-29 18:54:58 -0700 | [diff] [blame] | 7796 | if (hdd_ctx->config->napi_cpu_affinity_mask) |
| 7797 | hdd_napi_apply_throughput_policy(hdd_ctx, |
| 7798 | tx_packets, |
| 7799 | rx_packets); |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7800 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7801 | if (rx_packets < hdd_ctx->config->bus_bw_low_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7802 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
| 7803 | else |
| 7804 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7805 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7806 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7807 | qdf_dp_trace_apply_tput_policy(dptrace_high_tput_req); |
| 7808 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7809 | /* |
| 7810 | * Includes tcp+udp, if perf core is required for tcp, then |
| 7811 | * perf core is also required for udp. |
| 7812 | */ |
| 7813 | no_rx_offload_pkts = hdd_ctx->no_rx_offload_pkt_cnt; |
| 7814 | hdd_ctx->no_rx_offload_pkt_cnt = 0; |
| 7815 | rx_offload_pkts = rx_packets - no_rx_offload_pkts; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7816 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7817 | avg_no_rx_offload_pkts = (no_rx_offload_pkts + |
| 7818 | hdd_ctx->prev_no_rx_offload_pkts) / 2; |
| 7819 | hdd_ctx->prev_no_rx_offload_pkts = no_rx_offload_pkts; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7820 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7821 | avg_rx_offload_pkts = (rx_offload_pkts + |
| 7822 | hdd_ctx->prev_rx_offload_pkts) / 2; |
| 7823 | hdd_ctx->prev_rx_offload_pkts = rx_offload_pkts; |
| 7824 | |
| 7825 | avg_rx = avg_no_rx_offload_pkts + avg_rx_offload_pkts; |
| 7826 | /* |
| 7827 | * Takes care to set Rx_thread affinity for below case |
| 7828 | * 1)LRO/GRO not supported ROME case |
| 7829 | * 2)when rx_ol is disabled in cases like concurrency etc |
| 7830 | * 3)For UDP cases |
| 7831 | */ |
| 7832 | if (avg_no_rx_offload_pkts > |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7833 | hdd_ctx->config->bus_bw_high_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7834 | rxthread_high_tput_req = true; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7835 | else |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7836 | rxthread_high_tput_req = false; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7837 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7838 | if (cds_sched_handle_throughput_req(rxthread_high_tput_req)) |
| 7839 | hdd_warn("Rx thread high_tput(%d) affinity request failed", |
| 7840 | rxthread_high_tput_req); |
| 7841 | |
| 7842 | /* fine-tuning parameters for RX Flows */ |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7843 | if (avg_rx > hdd_ctx->config->tcp_delack_thres_high) { |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7844 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7845 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7846 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7847 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7848 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7849 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7850 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7851 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7852 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7853 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7854 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7855 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7856 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Jeff Johnson | b9feee4 | 2018-07-08 10:34:48 -0700 | [diff] [blame] | 7857 | next_rx_level, avg_rx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7858 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7859 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7860 | /* Send throughput indication only if it is enabled. |
| 7861 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7862 | * to default delayed ack. Note that this will disable the |
| 7863 | * dynamic delayed ack mechanism across the system |
| 7864 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7865 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7866 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7867 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7868 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7869 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7870 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7871 | rx_tp_data.level = next_rx_level; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7872 | wlan_hdd_update_tcp_rx_param(hdd_ctx, &rx_tp_data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7873 | } |
| 7874 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7875 | /* fine-tuning parameters for TX Flows */ |
| 7876 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7877 | hdd_ctx->prev_tx = tx_packets; |
| 7878 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7879 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7880 | else |
| 7881 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7882 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7883 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7884 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7885 | struct wlan_tx_tp_data tx_tp_data = {0}; |
| 7886 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7887 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7888 | next_tx_level, temp_tx); |
| 7889 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7890 | tx_level_change = true; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7891 | tx_tp_data.level = next_tx_level; |
| 7892 | tx_tp_data.tcp_limit_output = true; |
| 7893 | wlan_hdd_update_tcp_tx_param(hdd_ctx, &tx_tp_data); |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7894 | } |
| 7895 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7896 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7897 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7898 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7899 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7900 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7901 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7902 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7903 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7904 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7905 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7906 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7907 | |
| 7908 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7909 | } |
| 7910 | |
| 7911 | #define HDD_BW_GET_DIFF(_x, _y) (unsigned long)((ULONG_MAX - (_y)) + (_x) + 1) |
Rajeev Kumar | b2b5e69 | 2018-08-31 15:12:40 -0700 | [diff] [blame] | 7912 | static void __hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7913 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7914 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7915 | bus_bw_work); |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7916 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7917 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7918 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7919 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7920 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7921 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7922 | bool connected = false; |
| 7923 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7924 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7925 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7926 | return; |
| 7927 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7928 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7929 | goto restart_timer; |
| 7930 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7931 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7932 | /* |
| 7933 | * Validate magic so we don't end up accessing |
| 7934 | * an invalid adapter. |
| 7935 | */ |
| 7936 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7937 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7938 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7939 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7940 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7941 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7942 | != eConnectionState_Associated) { |
| 7943 | |
| 7944 | continue; |
| 7945 | } |
| 7946 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7947 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7948 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7949 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7950 | |
| 7951 | continue; |
| 7952 | } |
| 7953 | |
| 7954 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7955 | adapter->prev_tx_packets); |
| 7956 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7957 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7958 | |
| 7959 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7960 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7961 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7962 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7963 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7964 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7965 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7966 | &fwd_tx_packets, &fwd_rx_packets); |
| 7967 | if (ret == A_OK) { |
| 7968 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7969 | fwd_tx_packets, |
| 7970 | adapter->prev_fwd_tx_packets); |
| 7971 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7972 | fwd_tx_packets, |
| 7973 | adapter->prev_fwd_rx_packets); |
| 7974 | } |
| 7975 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7976 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7977 | if (adapter->device_mode == QDF_SAP_MODE) |
| 7978 | con_sap_adapter = adapter; |
| 7979 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7980 | total_rx += adapter->stats.rx_packets; |
| 7981 | total_tx += adapter->stats.tx_packets; |
| 7982 | |
| 7983 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7984 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7985 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7986 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7987 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7988 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7989 | connected = true; |
| 7990 | } |
| 7991 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7992 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7993 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7994 | return; |
| 7995 | } |
| 7996 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7997 | /* add intra bss forwarded tx and rx packets */ |
| 7998 | tx_packets += fwd_tx_packets_diff; |
| 7999 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8000 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8001 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->pdev)) { |
| 8002 | ucfg_ipa_uc_stat_query(hdd_ctx->pdev, &ipa_tx_packets, |
| 8003 | &ipa_rx_packets); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 8004 | tx_packets += (uint64_t)ipa_tx_packets; |
| 8005 | rx_packets += (uint64_t)ipa_rx_packets; |
| 8006 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 8007 | if (con_sap_adapter) { |
| 8008 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 8009 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 8010 | } |
| 8011 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8012 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, tx_packets, rx_packets); |
| 8013 | ucfg_ipa_uc_stat_request(hdd_ctx->pdev, 2); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 8014 | } |
| 8015 | |
| 8016 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8017 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 8018 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 8019 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 8020 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 8021 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 8022 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8023 | hdd_ctx->config->bus_bw_compute_interval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 8024 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8025 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8026 | |
Rajeev Kumar | b2b5e69 | 2018-08-31 15:12:40 -0700 | [diff] [blame] | 8027 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
| 8028 | { |
| 8029 | cds_ssr_protect(__func__); |
| 8030 | __hdd_bus_bw_work_handler(work); |
| 8031 | cds_ssr_unprotect(__func__); |
| 8032 | } |
| 8033 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 8034 | /** |
| 8035 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 8036 | * @arg: Argument of timer function |
| 8037 | * |
| 8038 | * Schedule a workqueue in this function where all the processing is done. |
| 8039 | * |
| 8040 | * Return: None. |
| 8041 | */ |
| 8042 | static void __hdd_bus_bw_cbk(void *arg) |
| 8043 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8044 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 8045 | |
| 8046 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8047 | return; |
| 8048 | |
| 8049 | schedule_work(&hdd_ctx->bus_bw_work); |
| 8050 | } |
| 8051 | |
| 8052 | /** |
| 8053 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 8054 | * @arg: Argument of timer function |
| 8055 | * |
| 8056 | * Return: None. |
| 8057 | */ |
| 8058 | static void hdd_bus_bw_cbk(void *arg) |
| 8059 | { |
| 8060 | cds_ssr_protect(__func__); |
| 8061 | __hdd_bus_bw_cbk(arg); |
| 8062 | cds_ssr_unprotect(__func__); |
| 8063 | } |
| 8064 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8065 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8066 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8067 | hdd_enter(); |
| 8068 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8069 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8070 | INIT_WORK(&hdd_ctx->bus_bw_work, hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 8071 | hdd_ctx->bus_bw_timer_running = false; |
| 8072 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8073 | qdf_timer_init(NULL, &hdd_ctx->bus_bw_timer, hdd_bus_bw_cbk, |
| 8074 | (void *)hdd_ctx, QDF_TIMER_TYPE_SW); |
| 8075 | |
| 8076 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8077 | |
| 8078 | return 0; |
| 8079 | } |
| 8080 | |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 8081 | void hdd_bus_bandwidth_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8082 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8083 | hdd_enter(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8084 | |
Rajeev Kumar | c27efb6 | 2018-08-31 14:21:22 -0700 | [diff] [blame] | 8085 | QDF_BUG(!hdd_ctx->bus_bw_timer_running); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8086 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 8087 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 8088 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8089 | |
| 8090 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8091 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 8092 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8093 | #endif /* MSM_PLATFORM */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8094 | |
| 8095 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8096 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 8097 | * @hdd_ctx: hdd context |
| 8098 | * |
| 8099 | * Return: 0 for success or error code |
| 8100 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8101 | 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] | 8102 | { |
| 8103 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 8104 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8105 | if (!hdd_ctx->hdd_txrx_hist) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8106 | return -ENOMEM; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8107 | return 0; |
| 8108 | } |
| 8109 | |
| 8110 | /** |
| 8111 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 8112 | * @hdd_ctx: hdd context |
| 8113 | * |
| 8114 | * Return: none |
| 8115 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8116 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8117 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 8118 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 8119 | return; |
| 8120 | |
| 8121 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 8122 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8123 | } |
| 8124 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8125 | static uint8_t *convert_level_to_string(uint32_t level) |
| 8126 | { |
| 8127 | switch (level) { |
| 8128 | /* initialize the wlan sub system */ |
| 8129 | case WLAN_SVC_TP_NONE: |
| 8130 | return "NONE"; |
| 8131 | case WLAN_SVC_TP_LOW: |
| 8132 | return "LOW"; |
| 8133 | case WLAN_SVC_TP_MEDIUM: |
| 8134 | return "MED"; |
| 8135 | case WLAN_SVC_TP_HIGH: |
| 8136 | return "HIGH"; |
| 8137 | default: |
| 8138 | return "INVAL"; |
| 8139 | } |
| 8140 | } |
| 8141 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8142 | |
| 8143 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8144 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 8145 | * @hdd_ctx: hdd context |
| 8146 | * |
| 8147 | * Return: none |
| 8148 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8149 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8150 | { |
| 8151 | int i; |
| 8152 | |
| 8153 | #ifdef MSM_PLATFORM |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8154 | hdd_nofl_info("BW compute Interval: %dms", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8155 | hdd_ctx->config->bus_bw_compute_interval); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8156 | 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] | 8157 | hdd_ctx->config->bus_bw_high_threshold, |
| 8158 | hdd_ctx->config->bus_bw_medium_threshold, |
| 8159 | hdd_ctx->config->bus_bw_low_threshold); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8160 | hdd_nofl_info("Enable TCP DEL ACK: %d", |
| 8161 | hdd_ctx->en_tcp_delack_no_lro); |
| 8162 | hdd_nofl_info("TCP DEL High TH: %d TCP DEL Low TH: %d", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8163 | hdd_ctx->config->tcp_delack_thres_high, |
| 8164 | hdd_ctx->config->tcp_delack_thres_low); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8165 | hdd_nofl_info("TCP TX HIGH TP TH: %d (Use to set tcp_output_bytes_limit)", |
| 8166 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8167 | #endif |
| 8168 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8169 | hdd_nofl_info("Total entries: %d Current index: %d", |
| 8170 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8171 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8172 | 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] | 8173 | |
| 8174 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8175 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 8176 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8177 | hdd_nofl_info("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 8178 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 8179 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 8180 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 8181 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8182 | hdd_ctx->hdd_txrx_hist[i]. |
| 8183 | next_vote_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8184 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8185 | hdd_ctx->hdd_txrx_hist[i]. |
| 8186 | next_rx_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8187 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8188 | hdd_ctx->hdd_txrx_hist[i]. |
| 8189 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8190 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8191 | } |
| 8192 | |
| 8193 | /** |
| 8194 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 8195 | * @hdd_ctx: hdd context |
| 8196 | * |
| 8197 | * Return: none |
| 8198 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8199 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8200 | { |
| 8201 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8202 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 8203 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8204 | } |
| 8205 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8206 | /* length of the netif queue log needed per adapter */ |
| 8207 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 8208 | |
| 8209 | /** |
| 8210 | * |
| 8211 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 8212 | * @hdd_ctx: hdd context |
| 8213 | * |
| 8214 | * Return: none |
| 8215 | */ |
| 8216 | static void |
| 8217 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 8218 | { |
| 8219 | int adapter_num = 0; |
| 8220 | int i; |
| 8221 | int bytes_written; |
| 8222 | u32 tbytes; |
| 8223 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8224 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8225 | char *comb_log_str; |
| 8226 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8227 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8228 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 8229 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * CSR_ROAM_SESSION_MAX) + 1; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8230 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8231 | if (!comb_log_str) |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8232 | return; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8233 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8234 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8235 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8236 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8237 | curr_time = qdf_system_ticks(); |
| 8238 | total = curr_time - adapter->start_time; |
| 8239 | delta = curr_time - adapter->last_time; |
| 8240 | |
| 8241 | if (adapter->pause_map) { |
| 8242 | pause = adapter->total_pause_time + delta; |
| 8243 | unpause = adapter->total_unpause_time; |
| 8244 | } else { |
| 8245 | unpause = adapter->total_unpause_time + delta; |
| 8246 | pause = adapter->total_pause_time; |
| 8247 | } |
| 8248 | |
| 8249 | tbytes = 0; |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 8250 | qdf_mem_zero(temp_str, sizeof(temp_str)); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8251 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8252 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 8253 | continue; |
| 8254 | tbytes += |
| 8255 | snprintf( |
| 8256 | &temp_str[tbytes], |
| 8257 | (tbytes >= sizeof(temp_str) ? |
| 8258 | 0 : sizeof(temp_str) - tbytes), |
| 8259 | "%d(%d,%d) ", |
| 8260 | i, |
| 8261 | adapter->queue_oper_stats[i]. |
| 8262 | pause_count, |
| 8263 | adapter->queue_oper_stats[i]. |
| 8264 | unpause_count); |
| 8265 | } |
| 8266 | if (tbytes >= sizeof(temp_str)) |
| 8267 | hdd_warn("log truncated"); |
| 8268 | |
| 8269 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8270 | bytes_written >= comb_log_str_size ? 0 : |
| 8271 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8272 | "[%d %d] (%d) %u/%ums %s|", |
| 8273 | adapter->session_id, adapter->device_mode, |
| 8274 | adapter->pause_map, |
| 8275 | qdf_system_ticks_to_msecs(pause), |
| 8276 | qdf_system_ticks_to_msecs(total), |
| 8277 | temp_str); |
| 8278 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8279 | adapter_num++; |
| 8280 | } |
| 8281 | |
| 8282 | /* using QDF_TRACE to avoid printing function name */ |
| 8283 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 8284 | "STATS |%s", comb_log_str); |
| 8285 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8286 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8287 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8288 | |
| 8289 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8290 | } |
| 8291 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8292 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 8293 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 8294 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8295 | * |
| 8296 | * Return: none |
| 8297 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8298 | void |
| 8299 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 8300 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8301 | { |
| 8302 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8303 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8304 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8305 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8306 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8307 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 8308 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 8309 | return; |
| 8310 | } |
| 8311 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8312 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8313 | hdd_nofl_info("Netif queue operation statistics:"); |
| 8314 | hdd_nofl_info("Session_id %d device mode %d", |
| 8315 | adapter->session_id, adapter->device_mode); |
| 8316 | hdd_nofl_info("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8317 | curr_time = qdf_system_ticks(); |
| 8318 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8319 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8320 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8321 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8322 | unpause = adapter->total_unpause_time; |
| 8323 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8324 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8325 | pause = adapter->total_pause_time; |
| 8326 | } |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8327 | hdd_nofl_info("Total: %ums Pause: %ums Unpause: %ums", |
| 8328 | qdf_system_ticks_to_msecs(total), |
| 8329 | qdf_system_ticks_to_msecs(pause), |
| 8330 | qdf_system_ticks_to_msecs(unpause)); |
| 8331 | hdd_nofl_info("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8332 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8333 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8334 | qdf_time_t pause_delta = 0; |
| 8335 | |
| 8336 | if (adapter->pause_map & (1 << i)) |
| 8337 | pause_delta = delta; |
| 8338 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8339 | /* using hdd_log to avoid printing function name */ |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8340 | hdd_nofl_info("%s: %d: %d: %ums", |
| 8341 | hdd_reason_type_to_string(i), |
| 8342 | adapter->queue_oper_stats[i].pause_count, |
| 8343 | adapter->queue_oper_stats[i]. |
| 8344 | unpause_count, |
| 8345 | qdf_system_ticks_to_msecs( |
| 8346 | adapter->queue_oper_stats[i]. |
| 8347 | total_pause_time + pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8348 | } |
| 8349 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8350 | hdd_nofl_info("Netif queue operation history:"); |
| 8351 | hdd_nofl_info("Total entries: %d current index %d", |
| 8352 | WLAN_HDD_MAX_HISTORY_ENTRY, |
| 8353 | adapter->history_index); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8354 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8355 | hdd_nofl_info("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8356 | |
| 8357 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8358 | /* using hdd_log to avoid printing function name */ |
| 8359 | if (adapter->queue_oper_history[i].time == 0) |
| 8360 | continue; |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8361 | hdd_nofl_info("%d: %u: %s: %s: %x", |
| 8362 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8363 | adapter->queue_oper_history[i].time), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8364 | hdd_action_type_to_string( |
| 8365 | adapter->queue_oper_history[i]. |
| 8366 | netif_action), |
| 8367 | hdd_reason_type_to_string( |
| 8368 | adapter->queue_oper_history[i]. |
| 8369 | netif_reason), |
| 8370 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8371 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8372 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8373 | } |
| 8374 | |
| 8375 | /** |
| 8376 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 8377 | * @hdd_ctx: hdd context |
| 8378 | * |
| 8379 | * Return: none |
| 8380 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8381 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8382 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8383 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8384 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8385 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8386 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8387 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8388 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8389 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8390 | adapter->history_index = 0; |
| 8391 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 8392 | adapter->total_pause_time = 0; |
| 8393 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8394 | } |
| 8395 | } |
| 8396 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8397 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 8398 | /** |
| 8399 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 8400 | * @hdd_ctx: hdd global context |
| 8401 | * |
| 8402 | * Return: none |
| 8403 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8404 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8405 | { |
| 8406 | uint8_t i; |
| 8407 | |
| 8408 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 8409 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 8410 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 8411 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 8412 | } |
| 8413 | } |
| 8414 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8415 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8416 | { |
| 8417 | } |
| 8418 | #endif |
| 8419 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8420 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 8421 | /** |
| 8422 | * 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] | 8423 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8424 | * @enable: enable or disable this behaviour |
| 8425 | * |
| 8426 | * Return: int |
| 8427 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8428 | 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] | 8429 | { |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8430 | struct wow_pulse_mode wow_pulse_set_info; |
| 8431 | QDF_STATUS status; |
| 8432 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8433 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8434 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8435 | if (!ucfg_pmo_is_wow_pulse_enabled(phddctx->psoc)) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8436 | return 0; |
| 8437 | |
| 8438 | /* prepare the request to send to SME */ |
| 8439 | if (enable == true) { |
| 8440 | wow_pulse_set_info.wow_pulse_enable = true; |
| 8441 | wow_pulse_set_info.wow_pulse_pin = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8442 | ucfg_pmo_get_wow_pulse_pin(phddctx->psoc); |
| 8443 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8444 | wow_pulse_set_info.wow_pulse_interval_high = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8445 | ucfg_pmo_get_wow_pulse_interval_high(phddctx->psoc); |
| 8446 | |
| 8447 | wow_pulse_set_info.wow_pulse_interval_low = |
| 8448 | ucfg_pmo_get_wow_pulse_interval_low(phddctx->psoc); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8449 | } else { |
| 8450 | wow_pulse_set_info.wow_pulse_enable = false; |
| 8451 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 8452 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 8453 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 8454 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8455 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8456 | wow_pulse_set_info.wow_pulse_enable, |
| 8457 | wow_pulse_set_info.wow_pulse_pin, |
| 8458 | wow_pulse_set_info.wow_pulse_interval_low, |
| 8459 | wow_pulse_set_info.wow_pulse_interval_high); |
| 8460 | |
| 8461 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 8462 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8463 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8464 | return -EIO; |
| 8465 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8466 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8467 | return 0; |
| 8468 | } |
| 8469 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8470 | 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] | 8471 | { |
| 8472 | return 0; |
| 8473 | } |
| 8474 | #endif |
| 8475 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8476 | #ifdef WLAN_FEATURE_FASTPATH |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8477 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8478 | /** |
| 8479 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 8480 | * @hdd_cfg: hdd config |
| 8481 | * @context: lower layer context |
| 8482 | * |
| 8483 | * Return: none |
| 8484 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8485 | void hdd_enable_fastpath(struct hdd_context *hdd_ctx, |
| 8486 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8487 | { |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8488 | if (cfg_get(hdd_ctx->psoc, CFG_DP_ENABLE_FASTPATH)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8489 | hif_enable_fastpath(context); |
| 8490 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8491 | #endif |
| 8492 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8493 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8494 | /** |
| 8495 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8496 | * @hdd_handle: opaque handle for the hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8497 | * @level: thermal level |
| 8498 | * |
| 8499 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8500 | * than 0, and restore the original data path when throttle level is 0 |
| 8501 | * |
| 8502 | * Return: none |
| 8503 | */ |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8504 | 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] | 8505 | { |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8506 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8507 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8508 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 8509 | if (level > THROTTLE_LEVEL_0) |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8510 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8511 | else |
| 8512 | /* restore original concurrency mode */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8513 | 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] | 8514 | } |
| 8515 | |
| 8516 | /** |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8517 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8518 | * @hdd_ctx: pointer to hdd context |
| 8519 | * @adapter: pointer to softap adapter |
| 8520 | * |
| 8521 | * This function is used to get safe channel from current regulatory valid |
| 8522 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8523 | * |
| 8524 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8525 | * failure, the channel number returned is zero. |
| 8526 | */ |
| 8527 | static uint8_t |
| 8528 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8529 | struct hdd_adapter *adapter) |
| 8530 | { |
| 8531 | struct sir_pcl_list pcl = {0}; |
| 8532 | uint32_t i, j; |
| 8533 | bool found = false; |
| 8534 | int ret; |
| 8535 | |
| 8536 | /* Try for safe channel from all valid channel */ |
| 8537 | pcl.pcl_len = MAX_NUM_CHAN; |
| 8538 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 8539 | &pcl.pcl_len); |
| 8540 | if (ret) { |
| 8541 | hdd_err("error %d in getting valid channel list", ret); |
| 8542 | return INVALID_CHANNEL_ID; |
| 8543 | } |
| 8544 | |
| 8545 | for (i = 0; i < pcl.pcl_len; i++) { |
| 8546 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 8547 | found = false; |
| 8548 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
| 8549 | if (pcl.pcl_list[i] == |
| 8550 | hdd_ctx->unsafe_channel_list[j]) { |
| 8551 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
| 8552 | found = true; |
| 8553 | break; |
| 8554 | } |
| 8555 | } |
| 8556 | |
| 8557 | if (found) |
| 8558 | continue; |
| 8559 | |
| 8560 | if ((pcl.pcl_list[i] >= |
| 8561 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
| 8562 | (pcl.pcl_list[i] <= |
| 8563 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
| 8564 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
| 8565 | return pcl.pcl_list[i]; |
| 8566 | } |
| 8567 | } |
| 8568 | |
| 8569 | return INVALID_CHANNEL_ID; |
| 8570 | } |
| 8571 | |
| 8572 | #else |
| 8573 | /** |
| 8574 | * hdd_set_thermal_level_cb() - set thermal level callback function |
| 8575 | * @hdd_handle: opaque handle for the hdd context |
| 8576 | * @level: thermal level |
| 8577 | * |
| 8578 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8579 | * than 0, and restore the original data path when throttle level is 0 |
| 8580 | * |
| 8581 | * Return: none |
| 8582 | */ |
| 8583 | static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level) |
| 8584 | { |
| 8585 | } |
| 8586 | |
| 8587 | /** |
| 8588 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8589 | * @hdd_ctx: pointer to hdd context |
| 8590 | * @adapter: pointer to softap adapter |
| 8591 | * |
| 8592 | * This function is used to get safe channel from current regulatory valid |
| 8593 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8594 | * |
| 8595 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8596 | * failure, the channel number returned is zero. |
| 8597 | */ |
| 8598 | static uint8_t |
| 8599 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8600 | struct hdd_adapter *adapter) |
| 8601 | { |
| 8602 | return 0; |
| 8603 | } |
| 8604 | #endif |
| 8605 | |
| 8606 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8607 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 8608 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 8609 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8610 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8611 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 8612 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 8613 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8614 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8615 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8616 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8617 | */ |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8618 | static uint8_t |
| 8619 | 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] | 8620 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8621 | struct sir_pcl_list pcl; |
| 8622 | QDF_STATUS status; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8623 | uint32_t i; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8624 | mac_handle_t mac_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8625 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8626 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8627 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8628 | if (!hdd_ctx) { |
| 8629 | hdd_err("invalid HDD context"); |
| 8630 | return INVALID_CHANNEL_ID; |
| 8631 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8632 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8633 | mac_handle = hdd_ctx->mac_handle; |
| 8634 | if (!mac_handle) { |
| 8635 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 8636 | return INVALID_CHANNEL_ID; |
| 8637 | } |
| 8638 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8639 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8640 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 8641 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 8642 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8643 | if (QDF_IS_STATUS_ERROR(status)) { |
| 8644 | hdd_err("Get PCL failed"); |
| 8645 | return INVALID_CHANNEL_ID; |
| 8646 | } |
| 8647 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 8648 | /* |
| 8649 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 8650 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 8651 | * try to choose a safe channel from acs range. |
| 8652 | */ |
| 8653 | if (!pcl.pcl_len) |
| 8654 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8655 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8656 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8657 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 8658 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8659 | |
| 8660 | /* PCL already takes unsafe channel into account */ |
| 8661 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8662 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8663 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8664 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8665 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8666 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8667 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8668 | return pcl.pcl_list[i]; |
| 8669 | } |
| 8670 | } |
| 8671 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8672 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8673 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8674 | return hdd_get_safe_channel(hdd_ctx, adapter); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8675 | } |
| 8676 | |
| 8677 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8678 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8679 | * @adapter: AP adapter |
| 8680 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8681 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8682 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8683 | * Moves the SAP interface by invoking the function which |
| 8684 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8685 | * |
| 8686 | * Return: None |
| 8687 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8688 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8689 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8690 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8691 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8692 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8693 | mac_handle_t mac_handle; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8694 | |
| 8695 | if (!adapter) { |
| 8696 | hdd_err("invalid adapter"); |
| 8697 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8698 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8699 | |
| 8700 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8701 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8702 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 8703 | if (!mac_handle) { |
| 8704 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8705 | return; |
| 8706 | } |
| 8707 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8708 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8709 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8710 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8711 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8712 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8713 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8714 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8715 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8716 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8717 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8718 | 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] | 8719 | { |
| 8720 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8721 | int status; |
| 8722 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8723 | |
| 8724 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8725 | |
| 8726 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8727 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8728 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8729 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8730 | } |
| 8731 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8732 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8733 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8734 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8735 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8736 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8737 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8738 | hdd_err("failed to start external acs timer"); |
| 8739 | return -ENOSPC; |
| 8740 | } |
| 8741 | /* Update config to application */ |
| 8742 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8743 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8744 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8745 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8746 | } |
| 8747 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8748 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8749 | /** |
| 8750 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8751 | * @hdd_ctx: hdd context pointer |
| 8752 | * |
| 8753 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8754 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8755 | * sap. User space on LTE coex indication restart driver. |
| 8756 | * |
| 8757 | * Return - none |
| 8758 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8759 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8760 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8761 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8762 | uint32_t i; |
| 8763 | bool found = false; |
| 8764 | uint8_t restart_chan; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8765 | uint8_t scc_on_lte_coex = 0; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8766 | bool value; |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8767 | QDF_STATUS status; |
| 8768 | bool is_acs_support_for_dfs_ltecoex = cfg_default(CFG_USER_ACS_DFS_LTE); |
| 8769 | bool is_vendor_acs_support = |
| 8770 | cfg_default(CFG_USER_AUTO_CHANNEL_SELECTION); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8771 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8772 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8773 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8774 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8775 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8776 | adapter->device_mode, |
| 8777 | adapter->session.ap.sap_config. |
| 8778 | acs_cfg.acs_mode); |
| 8779 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8780 | } |
| 8781 | |
| 8782 | found = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8783 | status = |
| 8784 | ucfg_policy_mgr_get_sta_sap_scc_lte_coex_chnl(hdd_ctxt->psoc, |
| 8785 | &scc_on_lte_coex); |
| 8786 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8787 | hdd_err("can't get scc on lte coex chnl, use def"); |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8788 | /* |
| 8789 | * If STA+SAP is doing SCC & g_sta_sap_scc_on_lte_coex_chan |
| 8790 | * is set, no need to move SAP. |
| 8791 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8792 | if (policy_mgr_is_sta_sap_scc(hdd_ctxt->psoc, |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8793 | adapter->session.ap.operating_channel) && |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8794 | scc_on_lte_coex) |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8795 | hdd_debug("SAP is allowed on SCC channel, no need to move SAP"); |
| 8796 | else { |
| 8797 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
| 8798 | if (adapter->session.ap.operating_channel == |
| 8799 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8800 | found = true; |
| 8801 | hdd_debug("operating ch:%d is unsafe", |
| 8802 | adapter->session.ap.operating_channel); |
| 8803 | break; |
| 8804 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8805 | } |
| 8806 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8807 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8808 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8809 | adapter->session.ap.operating_channel); |
| 8810 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8811 | } |
| 8812 | |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8813 | status = ucfg_mlme_get_acs_support_for_dfs_ltecoex( |
| 8814 | hdd_ctxt->psoc, |
| 8815 | &is_acs_support_for_dfs_ltecoex); |
| 8816 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8817 | hdd_err("get_acs_support_for_dfs_ltecoex failed,set def"); |
| 8818 | |
| 8819 | status = ucfg_mlme_get_vendor_acs_support( |
| 8820 | hdd_ctxt->psoc, |
| 8821 | &is_vendor_acs_support); |
| 8822 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8823 | hdd_err("get_vendor_acs_support failed, set default"); |
| 8824 | |
| 8825 | if (is_vendor_acs_support && is_acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8826 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8827 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8828 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8829 | } else |
| 8830 | restart_chan = |
| 8831 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8832 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8833 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8834 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8835 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8836 | /* |
| 8837 | * SAP restart due to unsafe channel. While |
| 8838 | * restarting the SAP, make sure to clear |
| 8839 | * acs_channel, channel to reset to |
| 8840 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8841 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8842 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8843 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8844 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8845 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8846 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 8847 | ucfg_mlme_get_sap_internal_restart(hdd_ctxt->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8848 | &value); |
| 8849 | hdd_debug("driver to start sap: %d", value); |
| 8850 | if (value) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8851 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8852 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8853 | else |
| 8854 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8855 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8856 | } |
| 8857 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8858 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8859 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8860 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8861 | * @hdd_ctx: HDD global context |
| 8862 | * |
| 8863 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8864 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8865 | * down to the lower layers. Then subscribe to subsequent channel |
| 8866 | * avoidance events. |
| 8867 | * |
| 8868 | * Return: None |
| 8869 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8870 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8871 | { |
| 8872 | uint16_t unsafe_channel_count; |
| 8873 | int index; |
| 8874 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8875 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8876 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8877 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8878 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8879 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8880 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8881 | hdd_ctx->unsafe_channel_count); |
| 8882 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8883 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8884 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8885 | |
| 8886 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8887 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8888 | hdd_ctx->unsafe_channel_list[index]); |
| 8889 | |
| 8890 | } |
| 8891 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8892 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8893 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8894 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8895 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8896 | { |
| 8897 | uint8_t restart_chan; |
| 8898 | |
| 8899 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8900 | if (!restart_chan) { |
| 8901 | hdd_alert("fail to restart SAP"); |
| 8902 | return; |
| 8903 | } |
| 8904 | |
| 8905 | /* SAP restart due to unsafe channel. While restarting |
| 8906 | * the SAP, make sure to clear acs_channel, channel to |
| 8907 | * reset to 0. Otherwise these settings will override |
| 8908 | * the ACS while restart. |
| 8909 | */ |
| 8910 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8911 | |
| 8912 | hdd_debug("sending coex indication"); |
| 8913 | |
| 8914 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8915 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8916 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8917 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8918 | |
| 8919 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8920 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8921 | { |
| 8922 | uint32_t size; |
| 8923 | uint16_t *unsafe_list; |
| 8924 | uint16_t chan_count; |
| 8925 | |
| 8926 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8927 | return -EINVAL; |
| 8928 | |
| 8929 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8930 | NUM_CHANNELS); |
| 8931 | if (chan_count) { |
| 8932 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8933 | unsafe_list = qdf_mem_malloc(size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8934 | if (!unsafe_list) |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8935 | return -ENOMEM; |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8936 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8937 | } else { |
| 8938 | unsafe_list = NULL; |
| 8939 | } |
| 8940 | |
| 8941 | *local_unsafe_list = unsafe_list; |
| 8942 | *local_unsafe_list_count = chan_count; |
| 8943 | |
| 8944 | return 0; |
| 8945 | } |
| 8946 | |
| 8947 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8948 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8949 | { |
| 8950 | int i, j; |
| 8951 | |
| 8952 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8953 | return true; |
| 8954 | if (local_unsafe_list_count == 0) |
| 8955 | return false; |
| 8956 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8957 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8958 | if (local_unsafe_list[i] == |
| 8959 | hdd_ctx->unsafe_channel_list[j]) |
| 8960 | break; |
| 8961 | if (j >= local_unsafe_list_count) |
| 8962 | break; |
| 8963 | } |
| 8964 | if (i >= local_unsafe_list_count) { |
| 8965 | hdd_info("unsafe chan list same"); |
| 8966 | return false; |
| 8967 | } |
| 8968 | |
| 8969 | return true; |
| 8970 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8971 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8972 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8973 | { |
| 8974 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8975 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8976 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8977 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8978 | { |
| 8979 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8980 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8981 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8982 | |
| 8983 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8984 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8985 | * user space |
| 8986 | * @frame_ind: Management frame data to be informed. |
| 8987 | * |
| 8988 | * This function is used to indicate management frame to |
| 8989 | * user space |
| 8990 | * |
| 8991 | * Return: None |
| 8992 | * |
| 8993 | */ |
| 8994 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8995 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8996 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8997 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8998 | int i; |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8999 | struct ieee80211_mgmt *mgmt = |
| 9000 | (struct ieee80211_mgmt *)frame_ind->frameBuf; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9001 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 9002 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9003 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9004 | return; |
| 9005 | |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 9006 | if (frame_ind->frame_len < ieee80211_hdrlen(mgmt->frame_control)) { |
| 9007 | hdd_err(" Invalid frame length"); |
| 9008 | return; |
| 9009 | } |
| 9010 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9011 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 9012 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 9013 | adapter = |
| 9014 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 9015 | if (adapter) |
| 9016 | break; |
| 9017 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 9018 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 9019 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 9020 | if ((NULL != adapter) && |
| 9021 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 9022 | __hdd_indicate_mgmt_frame(adapter, |
| 9023 | frame_ind->frame_len, |
| 9024 | frame_ind->frameBuf, |
| 9025 | frame_ind->frameType, |
| 9026 | frame_ind->rxChan, |
| 9027 | frame_ind->rxRssi); |
| 9028 | } |
| 9029 | } |
| 9030 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9031 | } else { |
| 9032 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 9033 | frame_ind->sessionId); |
| 9034 | } |
| 9035 | |
| 9036 | if ((NULL != adapter) && |
| 9037 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 9038 | __hdd_indicate_mgmt_frame(adapter, |
| 9039 | frame_ind->frame_len, |
| 9040 | frame_ind->frameBuf, |
| 9041 | frame_ind->frameType, |
| 9042 | frame_ind->rxChan, |
| 9043 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9044 | } |
| 9045 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9046 | void hdd_acs_response_timeout_handler(void *context) |
| 9047 | { |
| 9048 | struct hdd_external_acs_timer_context *timer_context = |
| 9049 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9050 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9051 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9052 | uint8_t reason; |
| 9053 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9054 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9055 | if (!timer_context) { |
| 9056 | hdd_err("invlaid timer context"); |
| 9057 | return; |
| 9058 | } |
| 9059 | adapter = timer_context->adapter; |
| 9060 | reason = timer_context->reason; |
| 9061 | |
| 9062 | |
| 9063 | if ((!adapter) || |
| 9064 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 9065 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 9066 | return; |
| 9067 | } |
| 9068 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9069 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 9070 | return; |
| 9071 | |
| 9072 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 9073 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 9074 | else |
| 9075 | return; |
| 9076 | |
| 9077 | hdd_err("ACS timeout happened for %s reason %d", |
| 9078 | adapter->dev->name, reason); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9079 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9080 | switch (reason) { |
| 9081 | /* SAP init case */ |
| 9082 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 9083 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 9084 | false); |
| 9085 | wlan_hdd_cfg80211_start_acs(adapter); |
| 9086 | break; |
| 9087 | /* DFS detected on current channel */ |
| 9088 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 9089 | wlan_sap_update_next_channel( |
| 9090 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9091 | sme_update_new_channel_event(hdd_ctx->mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 9092 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9093 | break; |
| 9094 | /* LTE coex event on current channel */ |
| 9095 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 9096 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 9097 | break; |
| 9098 | default: |
| 9099 | hdd_info("invalid reason for timer invoke"); |
| 9100 | |
| 9101 | } |
| 9102 | } |
| 9103 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9104 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9105 | * hdd_override_ini_config - Override INI config |
| 9106 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9107 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9108 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9109 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9110 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9111 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9112 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9113 | { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9114 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9115 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9116 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 9117 | ucfg_scan_cfg_set_dfs_chan_scan_allowed(hdd_ctx->psoc, |
| 9118 | enable_dfs_chan_scan); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9119 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9120 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9121 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9122 | if (0 == enable_11d || 1 == enable_11d) { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9123 | status = ucfg_mlme_set_11d_enabled(hdd_ctx->psoc, enable_11d); |
| 9124 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9125 | hdd_err("Failed to set 11d_enable flag"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9126 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 9127 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9128 | if (hdd_ctx->config->action_oui_enable && !ucfg_action_oui_enabled()) { |
| 9129 | hdd_ctx->config->action_oui_enable = 0; |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9130 | hdd_err("Ignore action oui ini, since no action_oui component"); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9131 | } |
Will Huang | 14b120f | 2019-01-14 17:26:14 +0800 | [diff] [blame] | 9132 | |
| 9133 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
| 9134 | hdd_override_all_ps(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9135 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9136 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9137 | #ifdef ENABLE_MTRACE_LOG |
| 9138 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9139 | { |
| 9140 | uint8_t module_id = 0; |
| 9141 | int qdf_print_idx = -1; |
| 9142 | |
| 9143 | qdf_print_idx = qdf_get_pidx(); |
| 9144 | for (module_id = 0; module_id < QDF_MODULE_ID_MAX; module_id++) |
| 9145 | qdf_print_set_category_verbose( |
| 9146 | qdf_print_idx, |
| 9147 | module_id, QDF_TRACE_LEVEL_TRACE, |
| 9148 | hdd_ctx->config->enable_mtrace); |
| 9149 | } |
| 9150 | #else |
| 9151 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9152 | { |
| 9153 | } |
| 9154 | |
| 9155 | #endif |
| 9156 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9157 | /** |
| 9158 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 9159 | * @hdd_ctx - HDD context |
| 9160 | * |
| 9161 | * Set trace level for each module based on INI config. |
| 9162 | * |
| 9163 | * Return: None |
| 9164 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9165 | 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] | 9166 | { |
Wu Gao | bc6eaa1 | 2018-11-30 14:17:45 +0800 | [diff] [blame] | 9167 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, 0x7f); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 9168 | hdd_qdf_trace_enable(QDF_MODULE_ID_MLME, 0xffff); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 9169 | hdd_qdf_trace_enable(QDF_MODULE_ID_FWOL, 0xffff); |
Kiran Kumar Lokere | 4ce4048 | 2018-08-30 16:31:00 -0700 | [diff] [blame] | 9170 | hdd_qdf_trace_enable(QDF_MODULE_ID_CRYPTO, 0xffff); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 9171 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9172 | hdd_set_mtrace_for_each(hdd_ctx); |
| 9173 | |
Nirav Shah | 5c083da | 2018-08-03 13:46:02 +0530 | [diff] [blame] | 9174 | hdd_cfg_print_global_config(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9175 | } |
| 9176 | |
| 9177 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9178 | * hdd_context_init() - Initialize HDD context |
| 9179 | * @hdd_ctx: HDD context. |
| 9180 | * |
| 9181 | * Initialize HDD context along with all the feature specific contexts. |
| 9182 | * |
| 9183 | * return: 0 on success and errno on failure. |
| 9184 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9185 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9186 | { |
| 9187 | int ret; |
| 9188 | |
| 9189 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 9190 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 9191 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9192 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 9193 | init_completion(&hdd_ctx->ready_to_suspend); |
| 9194 | |
| 9195 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9196 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 9197 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 9198 | qdf_list_create(&hdd_ctx->hdd_adapters, 0); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9199 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9200 | ret = hdd_scan_context_init(hdd_ctx); |
| 9201 | if (ret) |
| 9202 | goto list_destroy; |
| 9203 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9204 | hdd_rx_wake_lock_create(hdd_ctx); |
| 9205 | |
| 9206 | ret = hdd_sap_context_init(hdd_ctx); |
| 9207 | if (ret) |
| 9208 | goto scan_destroy; |
| 9209 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9210 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 9211 | |
| 9212 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 9213 | |
| 9214 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 9215 | hdd_ctx->config); |
| 9216 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 9217 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9218 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 9219 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 9220 | "monitor_mode_wakelock"); |
| 9221 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9222 | return 0; |
| 9223 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9224 | sap_destroy: |
| 9225 | hdd_sap_context_destroy(hdd_ctx); |
| 9226 | |
| 9227 | scan_destroy: |
| 9228 | hdd_scan_context_destroy(hdd_ctx); |
| 9229 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9230 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 9231 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 9232 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9233 | return ret; |
| 9234 | } |
| 9235 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9236 | void hdd_psoc_idle_timer_start(struct hdd_context *hdd_ctx) |
| 9237 | { |
| 9238 | uint32_t timeout_ms = hdd_ctx->config->iface_change_wait_time; |
| 9239 | enum wake_lock_reason reason = |
| 9240 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER; |
| 9241 | |
Rajeev Kumar | 7b7bb3f | 2018-12-20 12:09:54 -0800 | [diff] [blame] | 9242 | if (!timeout_ms) { |
| 9243 | hdd_info("psoc idle timer is disabled"); |
| 9244 | return; |
| 9245 | } |
| 9246 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9247 | hdd_debug("Starting psoc idle timer"); |
| 9248 | qdf_sched_delayed_work(&hdd_ctx->psoc_idle_timeout_work, timeout_ms); |
| 9249 | hdd_prevent_suspend_timeout(timeout_ms, reason); |
| 9250 | } |
| 9251 | |
| 9252 | void hdd_psoc_idle_timer_stop(struct hdd_context *hdd_ctx) |
| 9253 | { |
| 9254 | qdf_cancel_delayed_work(&hdd_ctx->psoc_idle_timeout_work); |
| 9255 | hdd_debug("Stopped psoc idle timer"); |
| 9256 | } |
| 9257 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9258 | /** |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9259 | * hdd_psoc_idle_shutdown() - perform an idle shutdown on the given psoc |
| 9260 | * @hdd_ctx: the hdd context which should be shutdown |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9261 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9262 | * When no interfaces are "up" on a psoc, an idle shutdown timer is started. |
| 9263 | * If no interfaces are brought up before the timer expires, we do an |
| 9264 | * "idle shutdown," cutting power to the physical SoC to save power. This is |
| 9265 | * done completely transparently from the perspective of userspace. |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9266 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9267 | * Return: None |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9268 | */ |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9269 | static void hdd_psoc_idle_shutdown(struct hdd_context *hdd_ctx) |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9270 | { |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9271 | struct hdd_psoc_sync *psoc_sync; |
| 9272 | int errno; |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9273 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9274 | hdd_enter(); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9275 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9276 | errno = hdd_psoc_sync_trans_start(hdd_ctx->parent_dev, &psoc_sync); |
| 9277 | if (errno) { |
| 9278 | hdd_info("psoc busy, abort idle shutdown; errno:%d", errno); |
| 9279 | goto exit; |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9280 | } |
| 9281 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9282 | hdd_psoc_sync_wait_for_ops(psoc_sync); |
| 9283 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9284 | QDF_BUG(!hdd_wlan_stop_modules(hdd_ctx, false)); |
| 9285 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9286 | hdd_psoc_sync_trans_stop(psoc_sync); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9287 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9288 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9289 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9290 | } |
| 9291 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9292 | int hdd_psoc_idle_restart(struct hdd_context *hdd_ctx) |
| 9293 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 9294 | QDF_BUG(rtnl_is_locked()); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9295 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9296 | return hdd_wlan_start_modules(hdd_ctx, false); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9297 | } |
| 9298 | |
| 9299 | /** |
| 9300 | * hdd_psoc_idle_timeout_callback() - Handler for psoc idle timeout |
| 9301 | * @priv: pointer to hdd context |
| 9302 | * |
| 9303 | * Return: None |
| 9304 | */ |
| 9305 | static void hdd_psoc_idle_timeout_callback(void *priv) |
| 9306 | { |
| 9307 | struct hdd_context *hdd_ctx = priv; |
| 9308 | |
| 9309 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 9310 | return; |
| 9311 | |
| 9312 | hdd_debug("Psoc idle timeout elapsed; starting psoc shutdown"); |
| 9313 | hdd_psoc_idle_shutdown(hdd_ctx); |
| 9314 | } |
| 9315 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9316 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9317 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9318 | { |
| 9319 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 9320 | wlan_logging_to_console); |
| 9321 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 9322 | } |
| 9323 | #else |
| 9324 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9325 | { } |
| 9326 | #endif |
| 9327 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9328 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9329 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9330 | struct wlan_objmgr_psoc *psoc) |
| 9331 | { |
| 9332 | config->wlan_logging_enable = cfg_get(psoc, CFG_WLAN_LOGGING_SUPPORT); |
| 9333 | |
| 9334 | config->wlan_logging_to_console = |
| 9335 | cfg_get(psoc, CFG_WLAN_LOGGING_CONSOLE_SUPPORT); |
| 9336 | } |
| 9337 | #else |
| 9338 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9339 | struct wlan_objmgr_psoc *psoc) |
| 9340 | { |
| 9341 | } |
| 9342 | #endif |
| 9343 | |
| 9344 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9345 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9346 | struct wlan_objmgr_psoc *psoc) |
| 9347 | { |
| 9348 | config->wlan_auto_shutdown = cfg_get(psoc, CFG_WLAN_AUTO_SHUTDOWN); |
| 9349 | } |
| 9350 | #else |
| 9351 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9352 | struct wlan_objmgr_psoc *psoc) |
| 9353 | { |
| 9354 | } |
| 9355 | #endif |
| 9356 | |
| 9357 | #ifndef REMOVE_PKT_LOG |
| 9358 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9359 | struct wlan_objmgr_psoc *psoc) |
| 9360 | { |
| 9361 | config->enable_packet_log = cfg_get(psoc, CFG_ENABLE_PACKET_LOG); |
| 9362 | } |
| 9363 | #else |
| 9364 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9365 | struct wlan_objmgr_psoc *psoc) |
| 9366 | { |
| 9367 | } |
| 9368 | #endif |
| 9369 | |
Sandeep Puligilla | 43b6d1a | 2018-12-03 09:16:13 -0800 | [diff] [blame] | 9370 | #ifdef ENABLE_MTRACE_LOG |
| 9371 | static void hdd_init_mtrace_log(struct hdd_config *config, |
| 9372 | struct wlan_objmgr_psoc *psoc) |
| 9373 | { |
| 9374 | config->enable_mtrace = cfg_get(psoc, CFG_ENABLE_MTRACE); |
| 9375 | } |
| 9376 | #else |
| 9377 | static void hdd_init_mtrace_log(struct hdd_config *config, |
| 9378 | struct wlan_objmgr_psoc *psoc) |
| 9379 | { |
| 9380 | } |
| 9381 | #endif |
| 9382 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9383 | #ifdef FEATURE_RUNTIME_PM |
| 9384 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9385 | struct wlan_objmgr_psoc *psoc) |
| 9386 | { |
| 9387 | config->runtime_pm = cfg_get(psoc, CFG_ENABLE_RUNTIME_PM); |
| 9388 | } |
| 9389 | #else |
| 9390 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9391 | struct wlan_objmgr_psoc *psoc) |
| 9392 | |
| 9393 | { |
| 9394 | } |
| 9395 | #endif |
| 9396 | |
| 9397 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 9398 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9399 | struct wlan_objmgr_psoc *psoc) |
| 9400 | { |
| 9401 | config->vc_mode_cfg_bitmap = cfg_get(psoc, CFG_VC_MODE_BITMAP); |
| 9402 | } |
| 9403 | #else |
| 9404 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9405 | struct wlan_objmgr_psoc *psoc) |
| 9406 | { |
| 9407 | } |
| 9408 | #endif |
| 9409 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9410 | /** |
| 9411 | * hdd_cfg_params_init() - Initialize hdd params in hdd_config strucuture |
| 9412 | * @hdd_ctx - Pointer to HDD context |
| 9413 | * |
| 9414 | * Return: None |
| 9415 | */ |
| 9416 | static void hdd_cfg_params_init(struct hdd_context *hdd_ctx) |
| 9417 | { |
| 9418 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
| 9419 | struct hdd_config *config = hdd_ctx->config; |
| 9420 | |
| 9421 | if (!psoc) { |
| 9422 | hdd_err("Invalid psoc"); |
| 9423 | return; |
| 9424 | } |
| 9425 | |
| 9426 | if (!config) { |
| 9427 | hdd_err("Invalid hdd config"); |
| 9428 | return; |
| 9429 | } |
| 9430 | |
| 9431 | config->bug_on_reinit_failure = cfg_get(psoc, |
| 9432 | CFG_BUG_ON_REINIT_FAILURE); |
| 9433 | |
| 9434 | config->is_ramdump_enabled = cfg_get(psoc, |
| 9435 | CFG_ENABLE_RAMDUMP_COLLECTION); |
| 9436 | |
| 9437 | config->iface_change_wait_time = cfg_get(psoc, |
| 9438 | CFG_INTERFACE_CHANGE_WAIT); |
| 9439 | |
| 9440 | config->multicast_host_fw_msgs = cfg_get(psoc, |
| 9441 | CFG_MULTICAST_HOST_FW_MSGS); |
| 9442 | |
| 9443 | config->private_wext_control = cfg_get(psoc, CFG_PRIVATE_WEXT_CONTROL); |
| 9444 | config->timer_multiplier = cfg_get(psoc, CFG_TIMER_MULTIPLIER); |
| 9445 | config->enablefwprint = cfg_get(psoc, CFG_ENABLE_FW_UART_PRINT); |
| 9446 | config->enable_fw_log = cfg_get(psoc, CFG_ENABLE_FW_LOG); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9447 | config->operating_channel = cfg_get(psoc, CFG_OPERATING_CHANNEL); |
| 9448 | config->num_vdevs = cfg_get(psoc, CFG_NUM_VDEV_ENABLE); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9449 | qdf_str_lcopy(config->enable_concurrent_sta, |
| 9450 | cfg_get(psoc, CFG_ENABLE_CONCURRENT_STA), |
| 9451 | CFG_CONCURRENT_IFACE_MAX_LEN); |
| 9452 | qdf_str_lcopy(config->dbs_scan_selection, |
| 9453 | cfg_get(psoc, CFG_DBS_SCAN_SELECTION), |
| 9454 | CFG_DBS_SCAN_PARAM_LENGTH); |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9455 | 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] | 9456 | config->mac_provision = cfg_get(psoc, CFG_ENABLE_MAC_PROVISION); |
| 9457 | config->provisioned_intf_pool = |
| 9458 | cfg_get(psoc, CFG_PROVISION_INTERFACE_POOL); |
| 9459 | config->derived_intf_pool = cfg_get(psoc, CFG_DERIVED_INTERFACE_POOL); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9460 | config->action_oui_enable = cfg_get(psoc, CFG_ENABLE_ACTION_OUI); |
Sandeep Puligilla | dc6d68a | 2019-01-04 16:57:12 -0800 | [diff] [blame] | 9461 | config->advertiseConcurrentOperation = |
| 9462 | cfg_get(psoc, |
| 9463 | CFG_ADVERTISE_CONCURRENT_OPERATION); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9464 | qdf_str_lcopy(config->action_oui_str[0], |
| 9465 | cfg_get(psoc, CFG_ACTION_OUI_CONNECT_1X1), |
| 9466 | ACTION_OUI_MAX_STR_LEN); |
| 9467 | qdf_str_lcopy(config->action_oui_str[1], |
| 9468 | cfg_get(psoc, CFG_ACTION_OUI_ITO_EXTENSION), |
| 9469 | ACTION_OUI_MAX_STR_LEN); |
| 9470 | qdf_str_lcopy(config->action_oui_str[2], |
| 9471 | cfg_get(psoc, CFG_ACTION_OUI_CCKM_1X1), |
| 9472 | ACTION_OUI_MAX_STR_LEN); |
| 9473 | qdf_str_lcopy(config->action_oui_str[3], |
| 9474 | cfg_get(psoc, CFG_ACTION_OUI_ITO_ALTERNATE), |
| 9475 | ACTION_OUI_MAX_STR_LEN); |
| 9476 | qdf_str_lcopy(config->action_oui_str[4], |
| 9477 | cfg_get(psoc, CFG_ACTION_OUI_SWITCH_TO_11N_MODE), |
| 9478 | ACTION_OUI_MAX_STR_LEN); |
| 9479 | qdf_str_lcopy(config->action_oui_str[5], |
| 9480 | cfg_get(psoc, |
| 9481 | CFG_ACTION_OUI_CONNECT_1X1_WITH_1_CHAIN), |
| 9482 | ACTION_OUI_MAX_STR_LEN); |
Rajeev Kumar Sirasanagandla | d7987f1 | 2018-12-08 23:24:04 +0530 | [diff] [blame] | 9483 | qdf_str_lcopy(config->action_oui_str[6], |
| 9484 | cfg_get(psoc, |
| 9485 | CFG_ACTION_OUI_DISABLE_AGGRESSIVE_TX), |
| 9486 | ACTION_OUI_MAX_STR_LEN); |
Sourav Mohapatra | 9e014cf | 2018-12-11 09:39:33 +0530 | [diff] [blame] | 9487 | config->enable_rtt_support = cfg_get(psoc, CFG_ENABLE_RTT_SUPPORT); |
Sandeep Puligilla | efeb4a9 | 2019-01-08 00:06:51 -0800 | [diff] [blame] | 9488 | config->is_unit_test_framework_enabled = |
| 9489 | cfg_get(psoc, CFG_ENABLE_UNIT_TEST_FRAMEWORK); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9490 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9491 | hdd_init_vc_mode_cfg_bitmap(config, psoc); |
| 9492 | hdd_init_runtime_pm(config, psoc); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9493 | hdd_init_wlan_auto_shutdown(config, psoc); |
| 9494 | hdd_init_wlan_logging_params(config, psoc); |
| 9495 | hdd_init_packet_log(config, psoc); |
Sandeep Puligilla | 43b6d1a | 2018-12-03 09:16:13 -0800 | [diff] [blame] | 9496 | hdd_init_mtrace_log(config, psoc); |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 9497 | hdd_dp_cfg_update(psoc, hdd_ctx); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9498 | } |
| 9499 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 9500 | struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9501 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9502 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9503 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9504 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9505 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9506 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9507 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 9508 | hdd_ctx = hdd_cfg80211_wiphy_alloc(); |
| 9509 | if (!hdd_ctx) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9510 | ret = -ENOMEM; |
| 9511 | goto err_out; |
| 9512 | } |
| 9513 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9514 | qdf_create_delayed_work(&hdd_ctx->psoc_idle_timeout_work, |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9515 | hdd_psoc_idle_timeout_callback, |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9516 | hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9517 | |
| 9518 | mutex_init(&hdd_ctx->iface_change_lock); |
| 9519 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9520 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 9521 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9522 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9523 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9524 | if (!hdd_ctx->config) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9525 | ret = -ENOMEM; |
| 9526 | goto err_free_hdd_context; |
| 9527 | } |
| 9528 | |
| 9529 | /* Read and parse the qcom_cfg.ini file */ |
| 9530 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9531 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9532 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9533 | WLAN_INI_FILE); |
| 9534 | ret = -EINVAL; |
| 9535 | goto err_free_config; |
| 9536 | } |
| 9537 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 9538 | status = cfg_parse(WLAN_INI_FILE); |
| 9539 | if (QDF_IS_STATUS_ERROR(status)) |
| 9540 | hdd_err("Failed to parse cfg %s; status:%d\n", |
| 9541 | WLAN_INI_FILE, status); |
| 9542 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9543 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID); |
| 9544 | if (ret) { |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9545 | QDF_DEBUG_PANIC("Psoc creation fails!"); |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9546 | goto err_free_config; |
| 9547 | } |
| 9548 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9549 | hdd_cfg_params_init(hdd_ctx); |
| 9550 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 9551 | hdd_debug("setting timer multiplier: %u", |
| 9552 | hdd_ctx->config->timer_multiplier); |
| 9553 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 9554 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9555 | cds_set_fatal_event(cfg_get(hdd_ctx->psoc, |
| 9556 | CFG_ENABLE_FATAL_EVENT_TRIGGER)); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 9557 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9558 | hdd_override_ini_config(hdd_ctx); |
| 9559 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9560 | ret = hdd_context_init(hdd_ctx); |
| 9561 | |
| 9562 | if (ret) |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9563 | goto err_hdd_objmgr_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9564 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9565 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9566 | goto skip_multicast_logging; |
| 9567 | |
| 9568 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 9569 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9570 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 9571 | if (ret) |
| 9572 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9573 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9574 | ret = hdd_init_netlink_services(hdd_ctx); |
| 9575 | if (ret) |
| 9576 | goto err_deinit_txrx_histogram; |
| 9577 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9578 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9579 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9580 | skip_multicast_logging: |
| 9581 | hdd_set_trace_level_for_each(hdd_ctx); |
| 9582 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 9583 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 9584 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9585 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 9586 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9587 | return hdd_ctx; |
| 9588 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9589 | err_deinit_txrx_histogram: |
| 9590 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 9591 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9592 | err_deinit_hdd_context: |
| 9593 | hdd_context_deinit(hdd_ctx); |
| 9594 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9595 | err_hdd_objmgr_destroy: |
| 9596 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 9597 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9598 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9599 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9600 | |
| 9601 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9602 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 9603 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9604 | |
| 9605 | err_out: |
| 9606 | return ERR_PTR(ret); |
| 9607 | } |
| 9608 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9609 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9610 | * hdd_start_station_adapter()- Start the Station Adapter |
| 9611 | * @adapter: HDD adapter |
| 9612 | * |
| 9613 | * This function initializes the adapter for the station mode. |
| 9614 | * |
| 9615 | * Return: 0 on success or errno on failure. |
| 9616 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9617 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9618 | { |
| 9619 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9620 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9621 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9622 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9623 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9624 | hdd_err("session is already opened, %d", |
| 9625 | adapter->session_id); |
| 9626 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9627 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9628 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9629 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 9630 | if (ret) { |
| 9631 | hdd_err("failed to create vdev: %d", ret); |
| 9632 | return ret; |
| 9633 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9634 | status = hdd_init_station_mode(adapter); |
| 9635 | |
| 9636 | if (QDF_STATUS_SUCCESS != status) { |
| 9637 | hdd_err("Error Initializing station mode: %d", status); |
| 9638 | return qdf_status_to_os_return(status); |
| 9639 | } |
| 9640 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9641 | hdd_register_tx_flow_control(adapter, |
| 9642 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9643 | hdd_tx_resume_cb, |
| 9644 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9645 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9646 | hdd_exit(); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 9647 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9648 | return 0; |
| 9649 | } |
| 9650 | |
| 9651 | /** |
| 9652 | * hdd_start_ap_adapter()- Start AP Adapter |
| 9653 | * @adapter: HDD adapter |
| 9654 | * |
| 9655 | * This function initializes the adapter for the AP mode. |
| 9656 | * |
| 9657 | * Return: 0 on success errno on failure. |
| 9658 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9659 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9660 | { |
| 9661 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9662 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9663 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9664 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9665 | uint32_t fine_time_meas_cap = 0; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9666 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9667 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9668 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9669 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9670 | hdd_err("session is already opened, %d", |
| 9671 | adapter->session_id); |
| 9672 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9673 | } |
| 9674 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9675 | * In SSR case no need to create new sap context. |
| 9676 | * Otherwise create sap context first and then create |
| 9677 | * vdev as while creating the vdev, driver needs to |
| 9678 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9679 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9680 | if (adapter->session.ap.sap_context) { |
| 9681 | is_ssr = true; |
| 9682 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9683 | hdd_err("sap creation failed"); |
| 9684 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 9685 | } |
| 9686 | |
| 9687 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 9688 | adapter->session.ap.sap_context); |
| 9689 | if (ret) { |
| 9690 | hdd_err("failed to create vdev, status:%d", ret); |
| 9691 | hdd_sap_destroy_ctx(adapter); |
| 9692 | return ret; |
| 9693 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9694 | |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9695 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 9696 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 9697 | &fine_time_meas_cap); |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9698 | sme_cli_set_command(adapter->session_id, |
| 9699 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9700 | (bool)(fine_time_meas_cap & WMI_FW_AP_RTT_RESPR), |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9701 | VDEV_CMD); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9702 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9703 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9704 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9705 | |
| 9706 | if (QDF_STATUS_SUCCESS != status) { |
| 9707 | hdd_err("Error Initializing the AP mode: %d", status); |
| 9708 | return qdf_status_to_os_return(status); |
| 9709 | } |
| 9710 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9711 | hdd_register_tx_flow_control(adapter, |
| 9712 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9713 | hdd_softap_tx_resume_cb, |
| 9714 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9715 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9716 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9717 | return 0; |
| 9718 | } |
| 9719 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9720 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 9721 | /** |
| 9722 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9723 | * @cds_cfg: CDS Configuration |
| 9724 | * @hdd_ctx: Pointer to hdd context |
| 9725 | * |
| 9726 | * Return: none |
| 9727 | */ |
| 9728 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9729 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9730 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9731 | { |
| 9732 | cds_cfg->tx_flow_stop_queue_th = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9733 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9734 | cds_cfg->tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9735 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 9736 | /* configuration for DP RX Threads */ |
| 9737 | cds_cfg->enable_dp_rx_threads = hdd_ctx->enable_dp_rx_threads; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9738 | } |
| 9739 | #else |
| 9740 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9741 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9742 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9743 | { |
| 9744 | } |
| 9745 | #endif |
| 9746 | |
| 9747 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 9748 | /** |
| 9749 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 9750 | * @cds_cfg: CDS Configuration |
| 9751 | * @hdd_ctx: Pointer to hdd context |
| 9752 | * |
| 9753 | * Return: none |
| 9754 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9755 | static inline void hdd_ra_populate_cds_config(struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9756 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9757 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 9758 | bool is_rate_limit_enabled; |
| 9759 | QDF_STATUS status; |
| 9760 | |
| 9761 | status = ucfg_fwol_get_is_rate_limit_enabled(hdd_ctx->psoc, |
| 9762 | &is_rate_limit_enabled); |
| 9763 | if (QDF_IS_STATUS_ERROR(status)) |
| 9764 | return; |
| 9765 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 9766 | cds_cfg->is_ra_ratelimit_enabled = is_rate_limit_enabled; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9767 | } |
| 9768 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9769 | static inline void hdd_ra_populate_cds_config(struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9770 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9771 | { |
| 9772 | } |
| 9773 | #endif |
| 9774 | |
| 9775 | /** |
| 9776 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9777 | * @hdd_ctx: HDD Context |
| 9778 | * |
| 9779 | * Return: 0 for Success, errno on failure |
| 9780 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9781 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9782 | { |
| 9783 | struct cds_config_info *cds_cfg; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9784 | int value; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9785 | uint8_t band_capability; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9786 | uint8_t ito_repeat_count; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9787 | bool crash_inject; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9788 | bool self_recovery; |
| 9789 | bool fw_timeout_crash; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9790 | QDF_STATUS status; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9791 | |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9792 | cds_cfg = qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9793 | if (!cds_cfg) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9794 | return -ENOMEM; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9795 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9796 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 9797 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 9798 | &cds_cfg->sta_maxlimod_dtim); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9799 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9800 | status = ucfg_mlme_get_crash_inject(hdd_ctx->psoc, &crash_inject); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9801 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9802 | hdd_err("Failed to get crash inject ini config"); |
| 9803 | goto exit; |
| 9804 | } |
| 9805 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9806 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 9807 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9808 | hdd_err("Failed to get self recovery ini config"); |
| 9809 | goto exit; |
| 9810 | } |
| 9811 | |
| 9812 | status = ucfg_mlme_get_fw_timeout_crash(hdd_ctx->psoc, |
| 9813 | &fw_timeout_crash); |
| 9814 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9815 | hdd_err("Failed to get fw timeout crash ini config"); |
| 9816 | goto exit; |
| 9817 | } |
| 9818 | |
| 9819 | status = ucfg_mlme_get_ito_repeat_count(hdd_ctx->psoc, |
| 9820 | &ito_repeat_count); |
| 9821 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9822 | hdd_err("Failed to get ITO repeat count ini config"); |
| 9823 | goto exit; |
| 9824 | } |
| 9825 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9826 | cds_cfg->force_target_assert_enabled = crash_inject; |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9827 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9828 | ucfg_mlme_get_sap_max_offload_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9829 | cds_cfg->ap_maxoffload_peers = value; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9830 | ucfg_mlme_get_sap_max_offload_reorder_buffs(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9831 | &value); |
| 9832 | cds_cfg->ap_maxoffload_reorderbuffs = value; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9833 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9834 | cds_cfg->reorder_offload = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9835 | cfg_get(hdd_ctx->psoc, CFG_DP_REORDER_OFFLOAD_SUPPORT); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9836 | |
| 9837 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9838 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9839 | |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9840 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9841 | ucfg_mlme_get_sap_max_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9842 | cds_cfg->max_station = value; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9843 | 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] | 9844 | cds_cfg->max_msdus_per_rxinorderind = |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 9845 | cfg_get(hdd_ctx->psoc, CFG_DP_MAX_MSDUS_PER_RXIND); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9846 | cds_cfg->self_recovery_enabled = self_recovery; |
| 9847 | cds_cfg->fw_timeout_crash = fw_timeout_crash; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9848 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9849 | cds_cfg->ito_repeat_count = ito_repeat_count; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9850 | |
| 9851 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9852 | if (QDF_IS_STATUS_ERROR(status)) |
| 9853 | goto exit; |
| 9854 | |
| 9855 | cds_cfg->bandcapability = band_capability; |
Rachit Kankane | 0106e38 | 2018-05-16 18:59:28 +0530 | [diff] [blame] | 9856 | cds_cfg->num_vdevs = hdd_ctx->config->num_vdevs; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9857 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9858 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 9859 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9860 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9861 | cds_init_ini_config(cds_cfg); |
| 9862 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9863 | |
| 9864 | exit: |
| 9865 | qdf_mem_free(cds_cfg); |
| 9866 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9867 | } |
| 9868 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9869 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9870 | * hdd_update_user_config() - API to update user configuration |
| 9871 | * parameters to obj mgr which are used by multiple components |
| 9872 | * @hdd_ctx: HDD Context |
| 9873 | * |
| 9874 | * Return: 0 for Success, errno on failure |
| 9875 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9876 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9877 | { |
| 9878 | struct wlan_objmgr_psoc_user_config *user_config; |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9879 | bool skip_dfs_in_p2p_search = false; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9880 | uint8_t band_capability; |
| 9881 | QDF_STATUS status; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9882 | bool value = false; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9883 | |
| 9884 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9885 | if (QDF_IS_STATUS_ERROR(status)) |
| 9886 | return -EIO; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9887 | |
| 9888 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9889 | if (!user_config) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9890 | return -ENOMEM; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9891 | |
| 9892 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9893 | status = ucfg_mlme_is_11d_enabled(hdd_ctx->psoc, &value); |
| 9894 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9895 | hdd_err("Invalid 11d_enable flag"); |
| 9896 | user_config->is_11d_support_enabled = value; |
| 9897 | |
| 9898 | value = false; |
| 9899 | status = ucfg_mlme_is_11h_enabled(hdd_ctx->psoc, &value); |
| 9900 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9901 | hdd_err("Invalid 11h_enable flag"); |
| 9902 | user_config->is_11h_support_enabled = value; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9903 | cfg_p2p_get_skip_dfs_channel_p2p_search(hdd_ctx->psoc, |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9904 | &skip_dfs_in_p2p_search); |
| 9905 | user_config->skip_dfs_chnl_in_p2p_search = skip_dfs_in_p2p_search; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9906 | user_config->band_capability = band_capability; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9907 | wlan_objmgr_psoc_set_user_config(hdd_ctx->psoc, user_config); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9908 | |
| 9909 | qdf_mem_free(user_config); |
| 9910 | return 0; |
| 9911 | } |
| 9912 | |
| 9913 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9914 | * hdd_init_thermal_info - Initialize thermal level |
| 9915 | * @hdd_ctx: HDD context |
| 9916 | * |
| 9917 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9918 | * which would be called when a configured thermal threshold is hit. |
| 9919 | * |
| 9920 | * Return: 0 on success and errno on failure |
| 9921 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9922 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9923 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9924 | QDF_STATUS status; |
Manikandan Mohan | 9045e2e | 2018-11-26 16:44:19 -0800 | [diff] [blame] | 9925 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9926 | |
Manikandan Mohan | 9045e2e | 2018-11-26 16:44:19 -0800 | [diff] [blame] | 9927 | status = sme_init_thermal_info(mac_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9928 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9929 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9930 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9931 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9932 | sme_add_set_thermal_level_callback(mac_handle, |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9933 | hdd_set_thermal_level_cb); |
| 9934 | |
| 9935 | return 0; |
| 9936 | |
| 9937 | } |
| 9938 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9939 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9940 | /** |
| 9941 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9942 | * |
| 9943 | * Hold RTNL lock |
| 9944 | * |
| 9945 | * Return: True if held and false otherwise |
| 9946 | */ |
| 9947 | static inline bool hdd_hold_rtnl_lock(void) |
| 9948 | { |
| 9949 | rtnl_lock(); |
| 9950 | return true; |
| 9951 | } |
| 9952 | |
| 9953 | /** |
| 9954 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9955 | * |
| 9956 | * Release RTNL lock |
| 9957 | * |
| 9958 | * Return: None |
| 9959 | */ |
| 9960 | static inline void hdd_release_rtnl_lock(void) |
| 9961 | { |
| 9962 | rtnl_unlock(); |
| 9963 | } |
| 9964 | #else |
| 9965 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9966 | static inline void hdd_release_rtnl_lock(void) { } |
| 9967 | #endif |
| 9968 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9969 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9970 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9971 | /* MAX iwpriv command support */ |
| 9972 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9973 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9974 | #define MAX_PKTLOG_SIZE 16 |
| 9975 | |
| 9976 | /** |
| 9977 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9978 | * @hdd_ctx: hdd context |
| 9979 | * @set_value2: pktlog buffer size value |
| 9980 | * |
| 9981 | * |
| 9982 | * Return: 0 for success or error. |
| 9983 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9984 | 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] | 9985 | { |
| 9986 | struct sir_wifi_start_log start_log = { 0 }; |
| 9987 | QDF_STATUS status; |
| 9988 | |
| 9989 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9990 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9991 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9992 | start_log.user_triggered = 1; |
| 9993 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9994 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9995 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9996 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9997 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9998 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9999 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10000 | return -EINVAL; |
| 10001 | } |
| 10002 | |
| 10003 | return 0; |
| 10004 | } |
| 10005 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10006 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10007 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 10008 | * @hdd_ctx: hdd context |
| 10009 | * |
| 10010 | * Return: 0 for success or error. |
| 10011 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10012 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10013 | { |
| 10014 | struct sir_wifi_start_log start_log; |
| 10015 | QDF_STATUS status; |
| 10016 | |
| 10017 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10018 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 10019 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10020 | start_log.user_triggered = 1; |
| 10021 | start_log.size = 0; |
| 10022 | start_log.is_pktlog_buff_clear = true; |
| 10023 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10024 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10025 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10026 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10027 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10028 | return -EINVAL; |
| 10029 | } |
| 10030 | |
| 10031 | return 0; |
| 10032 | } |
| 10033 | |
| 10034 | |
| 10035 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10036 | * hdd_process_pktlog_command() - process pktlog command |
| 10037 | * @hdd_ctx: hdd context |
| 10038 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10039 | * @set_value2: pktlog buffer size value |
| 10040 | * |
| 10041 | * This function process pktlog command. |
| 10042 | * set_value2 only matters when set_value is 3 (set buff size) |
| 10043 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10044 | * |
| 10045 | * Return: 0 for success or error. |
| 10046 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10047 | 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] | 10048 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10049 | { |
| 10050 | int ret; |
| 10051 | bool enable; |
| 10052 | uint8_t user_triggered = 0; |
| 10053 | |
| 10054 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10055 | if (0 != ret) |
| 10056 | return ret; |
| 10057 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10058 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10059 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10060 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10061 | hdd_err("invalid pktlog value %d", set_value); |
| 10062 | return -EINVAL; |
| 10063 | } |
| 10064 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10065 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 10066 | if (set_value2 <= 0) { |
| 10067 | hdd_err("invalid pktlog size %d", set_value2); |
| 10068 | return -EINVAL; |
| 10069 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 10070 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 10071 | return -EINVAL; |
| 10072 | } |
| 10073 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10074 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 10075 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10076 | } |
| 10077 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10078 | /* |
| 10079 | * set_value = 0 then disable packetlog |
| 10080 | * set_value = 1 enable packetlog forcefully |
| 10081 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 10082 | * enable packetlog with AUTO type. |
| 10083 | */ |
| 10084 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 10085 | true : false; |
| 10086 | |
| 10087 | if (1 == set_value) { |
| 10088 | enable = true; |
| 10089 | user_triggered = 1; |
| 10090 | } |
| 10091 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10092 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10093 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10094 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10095 | /** |
| 10096 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 10097 | * @hdd_ctx: HDD context |
| 10098 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10099 | * @user_triggered: triggered through iwpriv |
| 10100 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10101 | * |
| 10102 | * Return: 0 on success; error number otherwise |
| 10103 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10104 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10105 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10106 | { |
| 10107 | struct sir_wifi_start_log start_log; |
| 10108 | QDF_STATUS status; |
| 10109 | |
| 10110 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10111 | start_log.verbose_level = |
| 10112 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10113 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10114 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10115 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10116 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 10117 | /* |
| 10118 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 10119 | * commands. Host uses this flag to decide whether to send pktlog |
| 10120 | * disable command to fw without sending pktlog enable command |
| 10121 | * previously. For eg, If vendor sends pktlog disable command without |
| 10122 | * sending pktlog enable command, then host discards the packet |
| 10123 | * but for iwpriv command, host will send it to fw. |
| 10124 | */ |
| 10125 | start_log.is_iwpriv_command = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10126 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10127 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10128 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10129 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10130 | return -EINVAL; |
| 10131 | } |
| 10132 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10133 | if (enable == true) |
| 10134 | hdd_ctx->is_pktlog_enabled = 1; |
| 10135 | else |
| 10136 | hdd_ctx->is_pktlog_enabled = 0; |
| 10137 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10138 | return 0; |
| 10139 | } |
| 10140 | #endif /* REMOVE_PKT_LOG */ |
| 10141 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10142 | void hdd_free_mac_address_lists(struct hdd_context *hdd_ctx) |
| 10143 | { |
| 10144 | hdd_debug("Resetting MAC address lists"); |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 10145 | qdf_mem_zero(hdd_ctx->provisioned_mac_addr, |
| 10146 | sizeof(hdd_ctx->provisioned_mac_addr)); |
| 10147 | qdf_mem_zero(hdd_ctx->derived_mac_addr, |
| 10148 | sizeof(hdd_ctx->derived_mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10149 | hdd_ctx->num_provisioned_addr = 0; |
| 10150 | hdd_ctx->num_derived_addr = 0; |
| 10151 | hdd_ctx->provisioned_intf_addr_mask = 0; |
| 10152 | hdd_ctx->derived_intf_addr_mask = 0; |
| 10153 | } |
| 10154 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10155 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10156 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 10157 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10158 | * @dev: Device Pointer |
| 10159 | * @num: Number of Valid Mac address |
| 10160 | * |
| 10161 | * Return: Pointer to MAC address buffer |
| 10162 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10163 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 10164 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10165 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10166 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10167 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10168 | |
| 10169 | /** |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10170 | * hdd_get_platform_wlan_derived_mac_buff() - API to query platform driver |
| 10171 | * for derived MAC address |
| 10172 | * @dev: Device Pointer |
| 10173 | * @num: Number of Valid Mac address |
| 10174 | * |
| 10175 | * Return: Pointer to MAC address buffer |
| 10176 | */ |
| 10177 | static uint8_t *hdd_get_platform_wlan_derived_mac_buff(struct device *dev, |
| 10178 | uint32_t *num) |
| 10179 | { |
| 10180 | return pld_get_wlan_derived_mac_address(dev, num); |
| 10181 | } |
| 10182 | |
| 10183 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10184 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 10185 | * @hdd_ctx: HDD Context |
| 10186 | * @num: Number of random mac addresses needed |
| 10187 | * |
| 10188 | * Generate random addresses using bit manipulation on the base mac address |
| 10189 | * |
| 10190 | * Return: None |
| 10191 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10192 | 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] | 10193 | { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10194 | uint32_t idx = hdd_ctx->num_derived_addr; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10195 | uint32_t iter; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10196 | uint8_t *buf = NULL; |
| 10197 | uint8_t macaddr_b3, tmp_br3; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10198 | /* |
| 10199 | * Consider first provisioned mac address as source address to derive |
| 10200 | * remaining addresses |
| 10201 | */ |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10202 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10203 | uint8_t *src = hdd_ctx->provisioned_mac_addr[0].bytes; |
| 10204 | |
| 10205 | for (iter = 0; iter < num; ++iter, ++idx) { |
| 10206 | buf = hdd_ctx->derived_mac_addr[idx].bytes; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10207 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 10208 | macaddr_b3 = buf[3]; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10209 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + idx) & |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10210 | INTF_MACADDR_MASK; |
| 10211 | macaddr_b3 += tmp_br3; |
| 10212 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 10213 | buf[0] |= 0x02; |
| 10214 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10215 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10216 | hdd_ctx->num_derived_addr++; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10217 | } |
| 10218 | } |
| 10219 | |
| 10220 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10221 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10222 | * @hdd_ctx: HDD Context |
| 10223 | * |
| 10224 | * API to get mac addresses from platform driver and update the driver |
| 10225 | * structures and configure FW with the base mac address. |
| 10226 | * Return: int |
| 10227 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10228 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10229 | { |
| 10230 | uint32_t no_of_mac_addr, iter; |
| 10231 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 10232 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 10233 | uint8_t *addr, *buf; |
| 10234 | struct device *dev = hdd_ctx->parent_dev; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10235 | tSirMacAddr mac_addr; |
| 10236 | QDF_STATUS status; |
| 10237 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10238 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10239 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10240 | if (no_of_mac_addr == 0 || !addr) { |
| 10241 | hdd_debug("No mac configured from platform driver"); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10242 | return -EINVAL; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10243 | } |
| 10244 | |
| 10245 | hdd_free_mac_address_lists(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10246 | |
| 10247 | if (no_of_mac_addr > max_mac_addr) |
| 10248 | no_of_mac_addr = max_mac_addr; |
| 10249 | |
| 10250 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 10251 | |
| 10252 | 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] | 10253 | buf = hdd_ctx->provisioned_mac_addr[iter].bytes; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10254 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10255 | hdd_info("provisioned MAC Addr [%d]" MAC_ADDRESS_STR, iter, |
| 10256 | MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10257 | } |
| 10258 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10259 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10260 | hdd_ctx->num_provisioned_addr = no_of_mac_addr; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10261 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10262 | if (hdd_ctx->config->mac_provision) { |
| 10263 | addr = hdd_get_platform_wlan_derived_mac_buff(dev, |
| 10264 | &no_of_mac_addr); |
| 10265 | |
| 10266 | if (no_of_mac_addr == 0 || !addr) |
| 10267 | hdd_warn("No derived address from platform driver"); |
| 10268 | else if (no_of_mac_addr > |
| 10269 | (max_mac_addr - hdd_ctx->num_provisioned_addr)) |
| 10270 | no_of_mac_addr = (max_mac_addr - |
| 10271 | hdd_ctx->num_provisioned_addr); |
| 10272 | |
| 10273 | for (iter = 0; iter < no_of_mac_addr; ++iter, |
| 10274 | addr += mac_addr_size) { |
| 10275 | buf = hdd_ctx->derived_mac_addr[iter].bytes; |
| 10276 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
| 10277 | hdd_debug("derived MAC Addr [%d]" MAC_ADDRESS_STR, iter, |
| 10278 | MAC_ADDR_ARRAY(buf)); |
| 10279 | } |
| 10280 | hdd_ctx->num_derived_addr = no_of_mac_addr; |
| 10281 | } |
| 10282 | |
| 10283 | no_of_mac_addr = hdd_ctx->num_provisioned_addr + |
| 10284 | hdd_ctx->num_derived_addr; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10285 | if (no_of_mac_addr < max_mac_addr) |
| 10286 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 10287 | no_of_mac_addr); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10288 | |
| 10289 | status = sme_set_custom_mac_addr(mac_addr); |
| 10290 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10291 | return -EAGAIN; |
| 10292 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10293 | return 0; |
| 10294 | } |
| 10295 | |
| 10296 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10297 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 10298 | * @hdd_ctx: HDD Context |
| 10299 | * |
| 10300 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 10301 | * will generate its own MAC and update it to FW. |
| 10302 | * |
| 10303 | * Return: 0 for success |
| 10304 | * Non-zero error code for failure |
| 10305 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10306 | 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] | 10307 | { |
| 10308 | tSirMacAddr customMacAddr; |
| 10309 | QDF_STATUS status; |
| 10310 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10311 | if (hdd_ctx->num_provisioned_addr) |
| 10312 | qdf_mem_copy(&customMacAddr, |
| 10313 | &hdd_ctx->provisioned_mac_addr[0].bytes[0], |
| 10314 | sizeof(tSirMacAddr)); |
| 10315 | else |
| 10316 | qdf_mem_copy(&customMacAddr, |
| 10317 | &hdd_ctx->derived_mac_addr[0].bytes[0], |
| 10318 | sizeof(tSirMacAddr)); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10319 | status = sme_set_custom_mac_addr(customMacAddr); |
| 10320 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10321 | return -EAGAIN; |
| 10322 | return 0; |
| 10323 | } |
| 10324 | |
| 10325 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10326 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 10327 | * @hdd_ctx: HDD Context |
| 10328 | * |
| 10329 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 10330 | * is provisioned with mac addresses, driver uses it, else it will use |
| 10331 | * wlan_mac.bin to update HW MAC addresses. |
| 10332 | * |
| 10333 | * Return: None |
| 10334 | */ |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10335 | static int hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10336 | { |
| 10337 | QDF_STATUS status; |
| 10338 | int ret; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10339 | bool update_mac_addr_to_fw = true; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10340 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10341 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10342 | if (hdd_ctx->config->mac_provision || !ret) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10343 | hdd_info("using MAC address from platform driver"); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10344 | return ret; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10345 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10346 | |
| 10347 | status = hdd_update_mac_config(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10348 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 10349 | hdd_info("using MAC address from wlan_mac.bin"); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10350 | return 0; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10351 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10352 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10353 | hdd_info("using default MAC address"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10354 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10355 | /* Use fw provided MAC */ |
| 10356 | if (!qdf_is_macaddr_zero(&hdd_ctx->hw_macaddr)) { |
| 10357 | hdd_update_macaddr(hdd_ctx, hdd_ctx->hw_macaddr, false); |
| 10358 | update_mac_addr_to_fw = false; |
| 10359 | return 0; |
| 10360 | } else if (hdd_generate_macaddr_auto(hdd_ctx) != 0) { |
| 10361 | struct qdf_mac_addr mac_addr; |
| 10362 | |
| 10363 | hdd_err("MAC failure from device serial no."); |
Jeff Johnson | 51a8052 | 2018-12-11 20:19:44 -0800 | [diff] [blame] | 10364 | qdf_get_random_bytes(&mac_addr, sizeof(mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10365 | /* |
| 10366 | * Reset multicast bit (bit-0) and set |
| 10367 | * locally-administered bit |
| 10368 | */ |
| 10369 | mac_addr.bytes[0] = 0x2; |
| 10370 | hdd_update_macaddr(hdd_ctx, mac_addr, true); |
| 10371 | } |
| 10372 | |
| 10373 | if (update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10374 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10375 | if (ret) |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 10376 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10377 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10378 | return ret; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10379 | } |
| 10380 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10381 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10382 | { |
| 10383 | int vdev_id = 0; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10384 | QDF_STATUS status; |
| 10385 | bool smart_chainmask_enabled; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10386 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10387 | int vpdev = PDEV_CMD; |
| 10388 | int ret; |
| 10389 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10390 | status = ucfg_get_smart_chainmask_enabled(hdd_ctx->psoc, |
| 10391 | &smart_chainmask_enabled); |
| 10392 | if (QDF_IS_STATUS_ERROR(status)) |
| 10393 | return -EINVAL; |
| 10394 | |
| 10395 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10396 | (int)smart_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10397 | if (ret) |
| 10398 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 10399 | |
| 10400 | return ret; |
| 10401 | } |
| 10402 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10403 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10404 | { |
| 10405 | int vdev_id = 0; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10406 | QDF_STATUS status; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10407 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10408 | bool alternative_chainmask_enabled; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10409 | int vpdev = PDEV_CMD; |
| 10410 | int ret; |
| 10411 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10412 | status = ucfg_get_alternative_chainmask_enabled( |
| 10413 | hdd_ctx->psoc, |
| 10414 | &alternative_chainmask_enabled); |
| 10415 | if (QDF_IS_STATUS_ERROR(status)) |
| 10416 | return -EINVAL; |
| 10417 | |
| 10418 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10419 | (int)alternative_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10420 | if (ret) |
| 10421 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 10422 | ret); |
| 10423 | |
| 10424 | return ret; |
| 10425 | } |
| 10426 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10427 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10428 | { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10429 | QDF_STATUS status; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10430 | int vdev_id = 0; |
| 10431 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10432 | bool value; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10433 | int vpdev = PDEV_CMD; |
| 10434 | int ret; |
| 10435 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10436 | status = ucfg_fwol_get_ani_enabled(hdd_ctx->psoc, &value); |
| 10437 | if (QDF_IS_STATUS_ERROR(status)) |
| 10438 | return -EINVAL; |
| 10439 | |
| 10440 | ret = sme_cli_set_command(vdev_id, param_id, (int)value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10441 | if (ret) |
| 10442 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 10443 | |
| 10444 | return ret; |
| 10445 | } |
| 10446 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 10447 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10448 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 10449 | * @hdd_ctx: HDD context |
| 10450 | * |
| 10451 | * Pre configurations to be done at lower layer before calling cds enable. |
| 10452 | * |
| 10453 | * Return: 0 on success and errno on failure. |
| 10454 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10455 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10456 | { |
| 10457 | int ret; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10458 | uint8_t val = 0; |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10459 | QDF_STATUS status; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10460 | uint32_t arp_ac_category; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10461 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10462 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10463 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Ajit Pal Singh | 5d26961 | 2018-04-19 16:29:12 +0530 | [diff] [blame] | 10464 | /* Register HL netdev flow control callback */ |
| 10465 | cdp_hl_fc_register(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10466 | |
| 10467 | /* |
| 10468 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 10469 | * The cfg download must occur before we update the SME config |
| 10470 | * since the SME config operation must access the cfg database |
| 10471 | */ |
| 10472 | status = hdd_set_sme_config(hdd_ctx); |
| 10473 | |
| 10474 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10475 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10476 | ret = qdf_status_to_os_return(status); |
| 10477 | goto out; |
| 10478 | } |
| 10479 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 10480 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 10481 | if (QDF_STATUS_SUCCESS != status) { |
| 10482 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 10483 | ret = qdf_status_to_os_return(status); |
| 10484 | goto out; |
| 10485 | } |
| 10486 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10487 | status = ucfg_mlme_get_tx_chainmask_1ss(hdd_ctx->psoc, &val); |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10488 | if (QDF_STATUS_SUCCESS != status) { |
| 10489 | hdd_err("Get tx_chainmask_1ss from mlme failed"); |
| 10490 | ret = qdf_status_to_os_return(status); |
| 10491 | goto out; |
| 10492 | } |
| 10493 | 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] | 10494 | PDEV_CMD); |
| 10495 | if (0 != ret) { |
| 10496 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 10497 | goto out; |
| 10498 | } |
| 10499 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10500 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 10501 | if (ret) |
| 10502 | goto out; |
| 10503 | |
| 10504 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 10505 | if (ret) |
| 10506 | goto out; |
| 10507 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10508 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 10509 | if (ret) |
| 10510 | goto out; |
| 10511 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10512 | status = ucfg_get_arp_ac_category(hdd_ctx->psoc, &arp_ac_category); |
| 10513 | |
| 10514 | if (QDF_IS_STATUS_ERROR(status)) |
| 10515 | return -EINVAL; |
| 10516 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10517 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10518 | arp_ac_category, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10519 | PDEV_CMD); |
| 10520 | if (0 != ret) { |
| 10521 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10522 | arp_ac_category, ret); |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10523 | goto out; |
| 10524 | } |
| 10525 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10526 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 10527 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10528 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10529 | ret = qdf_status_to_os_return(status); |
| 10530 | goto out; |
| 10531 | } |
| 10532 | |
| 10533 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 10534 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10535 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10536 | ret = -EINVAL; |
| 10537 | goto out; |
| 10538 | } |
| 10539 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10540 | |
| 10541 | hdd_init_channel_avoidance(hdd_ctx); |
| 10542 | |
| 10543 | out: |
| 10544 | return ret; |
| 10545 | } |
| 10546 | |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10547 | #ifdef FEATURE_P2P_LISTEN_OFFLOAD |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10548 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10549 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10550 | * @context: context registered with sme_register_p2p_lo_event(). HDD |
| 10551 | * always registers a hdd context pointer |
| 10552 | * @evt:event structure pointer |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10553 | * |
| 10554 | * This is the p2p listen offload stop event handler, it sends vendor |
| 10555 | * event back to supplicant to notify the stop reason. |
| 10556 | * |
| 10557 | * Return: None |
| 10558 | */ |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10559 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10560 | struct sir_p2p_lo_event *evt) |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10561 | { |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10562 | struct hdd_context *hdd_ctx = context; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10563 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10564 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10565 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10566 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10567 | |
| 10568 | if (hdd_ctx == NULL) { |
| 10569 | hdd_err("Invalid HDD context pointer"); |
| 10570 | return; |
| 10571 | } |
| 10572 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10573 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 10574 | if (!adapter) { |
| 10575 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 10576 | evt->vdev_id); |
| 10577 | return; |
| 10578 | } |
| 10579 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10580 | vendor_event = |
| 10581 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10582 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10583 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 10584 | GFP_KERNEL); |
| 10585 | |
| 10586 | if (!vendor_event) { |
| 10587 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 10588 | return; |
| 10589 | } |
| 10590 | |
| 10591 | if (nla_put_u32(vendor_event, |
| 10592 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 10593 | evt->reason_code)) { |
| 10594 | hdd_err("nla put failed"); |
| 10595 | kfree_skb(vendor_event); |
| 10596 | return; |
| 10597 | } |
| 10598 | |
| 10599 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10600 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 10601 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10602 | } |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10603 | #else |
| 10604 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10605 | struct sir_p2p_lo_event *evt) |
| 10606 | { |
| 10607 | } |
| 10608 | #endif |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10609 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10610 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 10611 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10612 | { |
| 10613 | return sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap); |
| 10614 | } |
| 10615 | #else |
| 10616 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10617 | { |
| 10618 | return QDF_STATUS_SUCCESS; |
| 10619 | } |
| 10620 | #endif |
| 10621 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10622 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10623 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 10624 | * @hdd_ctx: HDD context |
| 10625 | * |
| 10626 | * This function sends the adaptive dwell time config configuration to the |
| 10627 | * firmware via WMA |
| 10628 | * |
| 10629 | * Return: 0 - success, < 0 - failure |
| 10630 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10631 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10632 | { |
| 10633 | QDF_STATUS status; |
| 10634 | struct adaptive_dwelltime_params dwelltime_params; |
| 10635 | |
Harprit Chhabada | d59ae76 | 2019-01-08 16:40:43 -0800 | [diff] [blame] | 10636 | status = ucfg_fwol_get_all_adaptive_dwelltime_params(hdd_ctx->psoc, |
| 10637 | &dwelltime_params); |
| 10638 | status = ucfg_fwol_set_adaptive_dwelltime_config(&dwelltime_params); |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10639 | |
| 10640 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 10641 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10642 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 10643 | return -EAGAIN; |
| 10644 | } |
| 10645 | return 0; |
| 10646 | } |
| 10647 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10648 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10649 | { |
| 10650 | QDF_STATUS status; |
| 10651 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 10652 | uint32_t i = 0; |
| 10653 | uint8_t count = 0, numentries = 0; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10654 | uint8_t dual_mac_feature; |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10655 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10656 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 10657 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10658 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 10659 | &dual_mac_feature); |
| 10660 | |
| 10661 | if (status != QDF_STATUS_SUCCESS) { |
| 10662 | hdd_err("can't get dual mac feature flag"); |
| 10663 | return -EINVAL; |
| 10664 | } |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10665 | /* check if DBS is enabled or supported */ |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10666 | if ((dual_mac_feature == DISABLE_DBS_CXN_AND_SCAN) || |
| 10667 | (dual_mac_feature == ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10668 | return -EINVAL; |
| 10669 | |
| 10670 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 10671 | dbs_scan_config, &numentries, |
| 10672 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10673 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 10674 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10675 | if (!numentries) { |
Dustin Brown | 6a8d39b | 2018-08-14 15:27:26 -0700 | [diff] [blame] | 10676 | hdd_debug("Do not send scan_selection_config"); |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10677 | return 0; |
| 10678 | } |
| 10679 | |
| 10680 | /* hdd_set_fw_log_params */ |
| 10681 | dbs_scan_params.num_clients = 0; |
| 10682 | while (count < (numentries - 2)) { |
| 10683 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 10684 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 10685 | dbs_scan_params.num_non_dbs_scans[i] = |
| 10686 | dbs_scan_config[count + 2]; |
| 10687 | dbs_scan_params.num_clients++; |
| 10688 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 10689 | dbs_scan_params.module_id[i], |
| 10690 | dbs_scan_params.num_dbs_scans[i], |
| 10691 | dbs_scan_params.num_non_dbs_scans[i]); |
| 10692 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 10693 | i++; |
| 10694 | } |
| 10695 | |
| 10696 | dbs_scan_params.pdev_id = 0; |
| 10697 | |
| 10698 | hdd_debug("clients:%d pdev:%d", |
| 10699 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 10700 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10701 | status = sme_set_dbs_scan_selection_config(hdd_ctx->mac_handle, |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10702 | &dbs_scan_params); |
| 10703 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 10704 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10705 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 10706 | return -EAGAIN; |
| 10707 | } |
| 10708 | return 0; |
| 10709 | } |
| 10710 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10711 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10712 | /** |
| 10713 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 10714 | * @hdd_ctx: HDD context |
| 10715 | * |
| 10716 | * Set auto shutdown callback to get indications from firmware to indicate |
| 10717 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 10718 | * |
| 10719 | * Return: 0 on success and errno on failure. |
| 10720 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10721 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10722 | { |
| 10723 | QDF_STATUS status; |
| 10724 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 10725 | if (!hdd_ctx->config->wlan_auto_shutdown) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10726 | return 0; |
| 10727 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10728 | status = sme_set_auto_shutdown_cb(hdd_ctx->mac_handle, |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10729 | wlan_hdd_auto_shutdown_cb); |
| 10730 | if (status != QDF_STATUS_SUCCESS) |
| 10731 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 10732 | status); |
| 10733 | |
| 10734 | return qdf_status_to_os_return(status); |
| 10735 | } |
| 10736 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10737 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10738 | { |
| 10739 | return 0; |
| 10740 | } |
| 10741 | #endif |
| 10742 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10743 | #ifdef MWS_COEX |
| 10744 | /** |
| 10745 | * hdd_set_mws_coex() - Set MWS coex configurations |
| 10746 | * @hdd_ctx: HDD context |
| 10747 | * |
| 10748 | * This function sends MWS-COEX 4G quick FTDM and |
| 10749 | * MWS-COEX 5G-NR power limit to FW |
| 10750 | * |
| 10751 | * Return: 0 on success and errno on failure. |
| 10752 | */ |
| 10753 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10754 | { |
| 10755 | int ret = 0; |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10756 | uint32_t mws_coex_4g_quick_tdm = 0, mws_coex_5g_nr_pwr_limit = 0; |
| 10757 | |
| 10758 | ucfg_mlme_get_mws_coex_4g_quick_tdm(hdd_ctx->psoc, |
| 10759 | &mws_coex_4g_quick_tdm); |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10760 | |
| 10761 | 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] | 10762 | mws_coex_4g_quick_tdm, |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10763 | PDEV_CMD); |
| 10764 | if (ret) { |
| 10765 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10766 | return ret; |
| 10767 | } |
| 10768 | |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10769 | ucfg_mlme_get_mws_coex_5g_nr_pwr_limit(hdd_ctx->psoc, |
| 10770 | &mws_coex_5g_nr_pwr_limit); |
| 10771 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10772 | 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] | 10773 | mws_coex_5g_nr_pwr_limit, |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10774 | PDEV_CMD); |
| 10775 | if (ret) { |
| 10776 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10777 | return ret; |
| 10778 | } |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10779 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10780 | return ret; |
| 10781 | } |
| 10782 | #else |
| 10783 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10784 | { |
| 10785 | return 0; |
| 10786 | } |
| 10787 | #endif |
| 10788 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10789 | /** |
| 10790 | * hdd_features_init() - Init features |
| 10791 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10792 | * |
| 10793 | * Initialize features and their feature context after WLAN firmware is up. |
| 10794 | * |
| 10795 | * Return: 0 on success and errno on failure. |
| 10796 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10797 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10798 | { |
| 10799 | tSirTxPowerLimit hddtxlimit; |
| 10800 | QDF_STATUS status; |
| 10801 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10802 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10803 | struct hdd_config *cfg; |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 10804 | bool b_cts2self, is_imps_enabled; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10805 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10806 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10807 | |
Dustin Brown | ad698ae | 2018-09-05 17:19:30 -0700 | [diff] [blame] | 10808 | ret = hdd_update_country_code(hdd_ctx); |
| 10809 | if (ret) { |
| 10810 | hdd_err("Failed to update country code; errno:%d", ret); |
| 10811 | return -EINVAL; |
| 10812 | } |
| 10813 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10814 | ret = hdd_init_mws_coex(hdd_ctx); |
| 10815 | if (ret) |
| 10816 | hdd_warn("Error initializing mws-coex"); |
| 10817 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10818 | cfg = hdd_ctx->config; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10819 | /* FW capabilities received, Set the Dot11 mode */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10820 | mac_handle = hdd_ctx->mac_handle; |
| 10821 | sme_setdef_dot11mode(mac_handle); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10822 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 10823 | ucfg_mlme_is_imps_enabled(hdd_ctx->psoc, &is_imps_enabled); |
| 10824 | hdd_set_idle_ps_config(hdd_ctx, is_imps_enabled); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10825 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10826 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10827 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 10828 | cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 10829 | cfg_dp_enable_data_stall), PDEV_CMD); |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10830 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10831 | ucfg_mlme_get_go_cts2self_for_sta(hdd_ctx->psoc, &b_cts2self); |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 10832 | if (b_cts2self) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10833 | sme_set_cts2self_for_p2p_go(mac_handle); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10834 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10835 | if (hdd_set_vc_mode_config(hdd_ctx)) |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10836 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10837 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10838 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10839 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10840 | |
| 10841 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10842 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10843 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10844 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10845 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10846 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10847 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10848 | if (ret) { |
| 10849 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10850 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10851 | } |
| 10852 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10853 | /** |
| 10854 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 10855 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 10856 | * device up. |
| 10857 | */ |
| 10858 | if (cds_is_driver_recovering()) { |
| 10859 | if (hdd_ctx->is_pktlog_enabled) |
| 10860 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Alok Kumar | 5a75b9d | 2018-08-31 10:55:43 +0530 | [diff] [blame] | 10861 | } else if (cds_is_packet_log_enabled()) |
| 10862 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10863 | |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 10864 | hddtxlimit.txPower2g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_2G); |
| 10865 | hddtxlimit.txPower5g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_5G); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10866 | status = sme_txpower_limit(mac_handle, &hddtxlimit); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10867 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10868 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10869 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10870 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10871 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 10872 | status = sme_enable_disable_chanavoidind_event(mac_handle, 0); |
| 10873 | if (QDF_IS_STATUS_ERROR(status) && (status != QDF_STATUS_E_NOSUPPORT)) { |
| 10874 | hdd_err("Failed to disable Chan Avoidance Indication"); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10875 | return -EINVAL; |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10876 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10877 | |
| 10878 | /* register P2P Listen Offload event callback */ |
| 10879 | if (wma_is_p2p_lo_capable()) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10880 | sme_register_p2p_lo_event(mac_handle, hdd_ctx, |
| 10881 | wlan_hdd_p2p_lo_event_callback); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10882 | |
| 10883 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10884 | |
| 10885 | if (ret) |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10886 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10887 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10888 | wlan_hdd_init_chan_info(hdd_ctx); |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10889 | wlan_hdd_twt_init(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10890 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10891 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10892 | return 0; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10893 | } |
| 10894 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10895 | /** |
| 10896 | * hdd_features_deinit() - Deinit features |
| 10897 | * @hdd_ctx: HDD context |
| 10898 | * |
| 10899 | * De-Initialize features and their feature context. |
| 10900 | * |
| 10901 | * Return: none. |
| 10902 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10903 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10904 | { |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10905 | wlan_hdd_twt_deinit(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10906 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10907 | wlan_hdd_tsf_deinit(hdd_ctx); |
jitiphil | 4e3bef4 | 2018-11-14 14:31:13 +0530 | [diff] [blame] | 10908 | if (cds_is_packet_log_enabled()) |
| 10909 | hdd_pktlog_enable_disable(hdd_ctx, false, 0, 0); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10910 | } |
| 10911 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10912 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10913 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10914 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10915 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10916 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10917 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10918 | 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] | 10919 | { |
| 10920 | QDF_STATUS status; |
| 10921 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10922 | status = ucfg_scan_register_bcn_cb(hdd_ctx->psoc, |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10923 | wlan_cfg80211_inform_bss_frame, |
| 10924 | SCAN_CB_TYPE_INFORM_BCN); |
| 10925 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10926 | hdd_err("failed with status code %08d [x%08x]", |
| 10927 | status, status); |
| 10928 | return status; |
| 10929 | } |
| 10930 | |
| 10931 | return QDF_STATUS_SUCCESS; |
| 10932 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10933 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10934 | /** |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 10935 | * hdd_v2_flow_pool_map() - Flow pool create callback when vdev is active |
| 10936 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10937 | * |
| 10938 | * Return: none. |
| 10939 | */ |
| 10940 | static void hdd_v2_flow_pool_map(int vdev_id) |
| 10941 | { |
| 10942 | QDF_STATUS status; |
| 10943 | |
| 10944 | status = cdp_flow_pool_map(cds_get_context(QDF_MODULE_ID_SOC), |
| 10945 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 10946 | vdev_id); |
| 10947 | /* |
| 10948 | * For Adrastea flow control v2 is based on FW MAP events, |
| 10949 | * so this above callback is not implemented. |
| 10950 | * Hence this is not actual failure. Dont return failure |
| 10951 | */ |
| 10952 | if ((status != QDF_STATUS_SUCCESS) && |
| 10953 | (status != QDF_STATUS_E_INVAL)) { |
| 10954 | hdd_err("vdev_id: %d, failed to create flow pool status %d", |
| 10955 | vdev_id, status); |
| 10956 | } |
| 10957 | } |
| 10958 | |
| 10959 | /** |
| 10960 | * hdd_v2_flow_pool_unmap() - Flow pool create callback when vdev is not active |
| 10961 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10962 | * |
| 10963 | * Return: none. |
| 10964 | */ |
| 10965 | static void hdd_v2_flow_pool_unmap(int vdev_id) |
| 10966 | { |
| 10967 | cdp_flow_pool_unmap(cds_get_context(QDF_MODULE_ID_SOC), |
| 10968 | cds_get_context(QDF_MODULE_ID_TXRX), vdev_id); |
| 10969 | } |
| 10970 | |
| 10971 | /** |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10972 | * hdd_action_oui_config() - Configure action_oui strings |
| 10973 | * @hdd_ctx: pointer to hdd context |
| 10974 | * |
| 10975 | * This is a HDD wrapper function which invokes ucfg api |
| 10976 | * of action_oui component to parse action oui strings. |
| 10977 | * |
| 10978 | * Return: None |
| 10979 | */ |
| 10980 | static void hdd_action_oui_config(struct hdd_context *hdd_ctx) |
| 10981 | { |
| 10982 | QDF_STATUS status; |
| 10983 | uint32_t id; |
| 10984 | uint8_t *str; |
| 10985 | |
| 10986 | if (!hdd_ctx->config->action_oui_enable) |
| 10987 | return; |
| 10988 | |
| 10989 | for (id = 0; id < ACTION_OUI_MAXIMUM_ID; id++) { |
| 10990 | str = hdd_ctx->config->action_oui_str[id]; |
| 10991 | if (!qdf_str_len(str)) |
| 10992 | continue; |
| 10993 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10994 | status = ucfg_action_oui_parse(hdd_ctx->psoc, str, id); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10995 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10996 | hdd_err("Failed to parse action_oui str: %u", id); |
| 10997 | } |
| 10998 | } |
| 10999 | |
| 11000 | /** |
| 11001 | * hdd_action_oui_send() - Send action_oui extensions to firmware |
| 11002 | * @hdd_ctx: pointer to hdd context |
| 11003 | * |
| 11004 | * This is a HDD wrapper function which invokes ucfg api |
| 11005 | * of action_oui component to send action oui extensions to firmware. |
| 11006 | * |
| 11007 | * Return: None |
| 11008 | */ |
| 11009 | static void hdd_action_oui_send(struct hdd_context *hdd_ctx) |
| 11010 | { |
| 11011 | QDF_STATUS status; |
| 11012 | |
| 11013 | if (!hdd_ctx->config->action_oui_enable) |
| 11014 | return; |
| 11015 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11016 | status = ucfg_action_oui_send(hdd_ctx->psoc); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11017 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11018 | hdd_err("Failed to send one or all action_ouis"); |
| 11019 | } |
| 11020 | |
Jeff Johnson | 0187c62 | 2019-01-04 06:39:44 -0800 | [diff] [blame] | 11021 | static void hdd_hastings_bt_war_initialize(struct hdd_context *hdd_ctx) |
| 11022 | { |
| 11023 | if (hdd_ctx->config->iface_change_wait_time) |
| 11024 | hdd_hastings_bt_war_disable_fw(hdd_ctx); |
| 11025 | else |
| 11026 | hdd_hastings_bt_war_enable_fw(hdd_ctx); |
| 11027 | } |
| 11028 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11029 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11030 | * hdd_configure_cds() - Configure cds modules |
| 11031 | * @hdd_ctx: HDD context |
| 11032 | * @adapter: Primary adapter context |
| 11033 | * |
| 11034 | * Enable Cds modules after WLAN firmware is up. |
| 11035 | * |
| 11036 | * Return: 0 on success and errno on failure. |
| 11037 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11038 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11039 | { |
| 11040 | int ret; |
| 11041 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11042 | int set_value; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11043 | mac_handle_t mac_handle; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11044 | bool enable_rts_sifsbursting; |
| 11045 | uint8_t enable_phy_reg_retention; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11046 | uint8_t max_mpdus_inampdu, is_force_1x1 = 0; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11047 | uint32_t num_abg_tx_chains = 0; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11048 | uint16_t num_11b_tx_chains = 0; |
| 11049 | uint16_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 11050 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11051 | bool value; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11052 | enum pmo_auto_pwr_detect_failure_mode auto_power_fail_mode; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11053 | bool bval = false; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11054 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11055 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11056 | |
| 11057 | hdd_action_oui_send(hdd_ctx); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11058 | status = ucfg_policy_mgr_get_force_1x1(hdd_ctx->psoc, &is_force_1x1); |
| 11059 | if (status != QDF_STATUS_SUCCESS) { |
| 11060 | hdd_err("Failed to get force 1x1 value"); |
| 11061 | goto out; |
| 11062 | } |
| 11063 | if (is_force_1x1) |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11064 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 11065 | 1, PDEV_CMD); |
| 11066 | /* set chip power save failure detected callback */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11067 | sme_set_chip_pwr_save_fail_cb(mac_handle, |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11068 | hdd_chip_pwr_save_fail_detected_cb); |
| 11069 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11070 | status = ucfg_get_max_mpdus_inampdu(hdd_ctx->psoc, |
| 11071 | &max_mpdus_inampdu); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11072 | if (status) { |
| 11073 | hdd_err("Failed to get max mpdus in ampdu value"); |
| 11074 | goto out; |
| 11075 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11076 | |
| 11077 | if (max_mpdus_inampdu) { |
| 11078 | set_value = max_mpdus_inampdu; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11079 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 11080 | set_value, PDEV_CMD); |
| 11081 | } |
| 11082 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11083 | status = ucfg_get_enable_rts_sifsbursting(hdd_ctx->psoc, |
| 11084 | &enable_rts_sifsbursting); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11085 | if (status) { |
| 11086 | hdd_err("Failed to get rts sifs bursting value"); |
| 11087 | goto out; |
| 11088 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11089 | |
| 11090 | if (enable_rts_sifsbursting) { |
| 11091 | set_value = enable_rts_sifsbursting; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11092 | sme_cli_set_command(0, |
| 11093 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 11094 | set_value, PDEV_CMD); |
| 11095 | } |
| 11096 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 11097 | ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11098 | if (value) { |
| 11099 | set_value = value; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11100 | sme_cli_set_command(0, |
| 11101 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 11102 | set_value, PDEV_CMD); |
| 11103 | } |
| 11104 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11105 | status = ucfg_mlme_get_num_11b_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11106 | &num_11b_tx_chains); |
| 11107 | if (status != QDF_STATUS_SUCCESS) { |
| 11108 | hdd_err("Failed to get num_11b_tx_chains"); |
| 11109 | goto out; |
| 11110 | } |
| 11111 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11112 | status = ucfg_mlme_get_num_11ag_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11113 | &num_11ag_tx_chains); |
| 11114 | if (status != QDF_STATUS_SUCCESS) { |
| 11115 | hdd_err("Failed to get num_11ag_tx_chains"); |
| 11116 | goto out; |
| 11117 | } |
| 11118 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11119 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 11120 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11121 | hdd_err("unable to get vht_enable2x2"); |
| 11122 | |
| 11123 | if (!bval) { |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11124 | if (num_11b_tx_chains > 1) |
| 11125 | num_11b_tx_chains = 1; |
| 11126 | if (num_11ag_tx_chains > 1) |
| 11127 | num_11ag_tx_chains = 1; |
| 11128 | } |
| 11129 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11130 | num_11b_tx_chains); |
| 11131 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11132 | num_11ag_tx_chains); |
| 11133 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 11134 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11135 | |
Paul Zhang | 02526cd | 2018-09-20 17:47:46 +0800 | [diff] [blame] | 11136 | if (!ucfg_reg_is_regdb_offloaded(hdd_ctx->psoc)) |
| 11137 | ucfg_reg_program_default_cc(hdd_ctx->pdev, |
| 11138 | hdd_ctx->reg.reg_domain); |
| 11139 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11140 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 11141 | if (ret) { |
| 11142 | hdd_err("Failed to pre-configure cds"); |
| 11143 | goto out; |
| 11144 | } |
| 11145 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11146 | /* Always get latest IPA resources allocated from cds_open and configure |
| 11147 | * IPA module before configuring them to FW. Sequence required as crash |
| 11148 | * observed otherwise. |
| 11149 | */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11150 | if (ucfg_ipa_uc_ol_init(hdd_ctx->pdev, |
| 11151 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 11152 | hdd_err("Failed to setup pipes"); |
| 11153 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11154 | } |
| 11155 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11156 | /* |
| 11157 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 11158 | * else |
| 11159 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11160 | status = cds_enable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11161 | |
| 11162 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11163 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11164 | goto out; |
| 11165 | } |
| 11166 | |
| 11167 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 11168 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11169 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11170 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11171 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11172 | status = hdd_register_bcn_cb(hdd_ctx); |
| 11173 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 11174 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11175 | goto cds_disable; |
| 11176 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11177 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11178 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11179 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11180 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11181 | |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 11182 | /* Donot disable rx offload on concurrency for lithium based targets */ |
| 11183 | if (!(hdd_ctx->target_type == TARGET_TYPE_QCA6290 || |
| 11184 | hdd_ctx->target_type == TARGET_TYPE_QCA6390)) |
| 11185 | if (hdd_ctx->ol_enable) |
| 11186 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 11187 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11188 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 11189 | 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] | 11190 | dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; |
| 11191 | dp_cbs.hdd_v2_flow_pool_unmap = hdd_v2_flow_pool_unmap; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11192 | status = policy_mgr_register_dp_cb(hdd_ctx->psoc, &dp_cbs); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11193 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11194 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11195 | goto cds_disable; |
| 11196 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11197 | status = policy_mgr_register_mode_change_cb(hdd_ctx->psoc, |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11198 | wlan_hdd_send_mode_change_event); |
| 11199 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 11200 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 11201 | goto cds_disable; |
| 11202 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11203 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 11204 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 11205 | hdd_debug("enhance green ap is not enabled"); |
| 11206 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 11207 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 11208 | hdd_debug("Failed to set wow pulse"); |
| 11209 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 11210 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
Manikandan Mohan | 66df7fc | 2019-01-08 17:57:05 -0800 | [diff] [blame] | 11211 | ucfg_fwol_get_gcmp_enable(hdd_ctx->psoc), PDEV_CMD); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11212 | |
| 11213 | auto_power_fail_mode = |
| 11214 | ucfg_pmo_get_auto_power_fail_mode(hdd_ctx->psoc); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11215 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11216 | auto_power_fail_mode, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11217 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11218 | status = ucfg_get_enable_phy_reg_retention(hdd_ctx->psoc, |
| 11219 | &enable_phy_reg_retention); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11220 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11221 | if (QDF_IS_STATUS_ERROR(status)) |
| 11222 | return -EINVAL; |
| 11223 | |
| 11224 | if (enable_phy_reg_retention) |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11225 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11226 | enable_phy_reg_retention, PDEV_CMD); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11227 | |
Jeff Johnson | 0187c62 | 2019-01-04 06:39:44 -0800 | [diff] [blame] | 11228 | hdd_hastings_bt_war_initialize(hdd_ctx); |
| 11229 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11230 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11231 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11232 | cds_disable: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11233 | cds_disable(hdd_ctx->psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11234 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11235 | out: |
| 11236 | return -EINVAL; |
| 11237 | } |
| 11238 | |
| 11239 | /** |
| 11240 | * hdd_deconfigure_cds() -De-Configure cds |
| 11241 | * @hdd_ctx: HDD context |
| 11242 | * |
| 11243 | * Deconfigure Cds modules before WLAN firmware is down. |
| 11244 | * |
| 11245 | * Return: 0 on success and errno on failure. |
| 11246 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11247 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11248 | { |
| 11249 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11250 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11251 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11252 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 11253 | |
| 11254 | /* De-init features */ |
| 11255 | hdd_features_deinit(hdd_ctx); |
| 11256 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11257 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->psoc); |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 11258 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11259 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11260 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11261 | qdf_status = cds_disable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11262 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11263 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 11264 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11265 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11266 | } |
| 11267 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11268 | 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] | 11269 | hdd_err("Failed to disconnect pipes"); |
| 11270 | ret = -EINVAL; |
| 11271 | } |
| 11272 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11273 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11274 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11275 | } |
| 11276 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11277 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 11278 | static void hdd_deregister_policy_manager_callback( |
| 11279 | struct wlan_objmgr_psoc *psoc) |
| 11280 | { |
| 11281 | if (QDF_STATUS_SUCCESS != |
| 11282 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 11283 | hdd_err("HDD callback deregister with policy manager failed"); |
| 11284 | } |
| 11285 | } |
| 11286 | #else |
| 11287 | static void hdd_deregister_policy_manager_callback( |
| 11288 | struct wlan_objmgr_psoc *psoc) |
| 11289 | { |
| 11290 | } |
| 11291 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11292 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11293 | 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] | 11294 | { |
| 11295 | void *hif_ctx; |
| 11296 | qdf_device_t qdf_ctx; |
| 11297 | QDF_STATUS qdf_status; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11298 | bool is_recovery_stop = cds_is_driver_recovering(); |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11299 | int ret = 0; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11300 | int active_threads; |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11301 | int debugfs_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11302 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11303 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11304 | hdd_enter(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11305 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11306 | hdd_deregister_policy_manager_callback(hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11307 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11308 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11309 | if (!qdf_ctx) { |
| 11310 | hdd_err("QDF device context NULL"); |
| 11311 | return -EINVAL; |
| 11312 | } |
| 11313 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11314 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 11315 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11316 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11317 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11318 | active_threads = cds_return_external_threads_count(); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11319 | debugfs_threads = hdd_return_debugfs_threads_count(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11320 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11321 | if (active_threads > 0 || debugfs_threads > 0 || |
| 11322 | hdd_ctx->is_wiphy_suspended) { |
| 11323 | hdd_warn("External threads %d, Debugfs threads %d, wiphy suspend %d", |
| 11324 | active_threads, debugfs_threads, |
| 11325 | hdd_ctx->is_wiphy_suspended); |
| 11326 | |
| 11327 | if (active_threads) |
| 11328 | cds_print_external_threads(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11329 | |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11330 | if (IS_IDLE_STOP && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11331 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 11332 | hdd_psoc_idle_timer_start(hdd_ctx); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11333 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11334 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11335 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11336 | return 0; |
| 11337 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 11338 | } |
| 11339 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 11340 | /* free user wowl patterns */ |
| 11341 | hdd_free_user_wowl_ptrns(); |
| 11342 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11343 | switch (hdd_ctx->driver_status) { |
| 11344 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11345 | hdd_debug("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11346 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11347 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11348 | hdd_debug("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11349 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11350 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 11351 | hdd_info("Wlan transitioning (CLOSED <- ENABLED)"); |
| 11352 | |
| 11353 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) |
| 11354 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11355 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 11356 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11357 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11358 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11359 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11360 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11361 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11362 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11363 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11364 | break; |
| 11365 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11366 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11367 | hdd_ctx->driver_status); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11368 | ret = -EINVAL; |
| 11369 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11370 | } |
| 11371 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11372 | hdd_sysfs_destroy_powerstats_interface(); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11373 | hdd_sysfs_destroy_version_interface(); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11374 | hdd_sysfs_destroy_driver_root_obj(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11375 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11376 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 11377 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 11378 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11379 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 11380 | qdf_status); |
| 11381 | ret = -EINVAL; |
| 11382 | QDF_ASSERT(0); |
| 11383 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11384 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 11385 | /* De-register the SME callbacks */ |
| 11386 | hdd_deregister_cb(hdd_ctx); |
| 11387 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 11388 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 11389 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11390 | qdf_status = cds_dp_close(hdd_ctx->psoc); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11391 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11392 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 11393 | ret = -EINVAL; |
| 11394 | QDF_ASSERT(0); |
| 11395 | } |
| 11396 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11397 | qdf_status = cds_close(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11398 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11399 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 11400 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11401 | QDF_ASSERT(0); |
| 11402 | } |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11403 | |
| 11404 | qdf_status = wbuff_module_deinit(); |
| 11405 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 11406 | hdd_err("WBUFF de-init unsuccessful; status: %d", qdf_status); |
| 11407 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 11408 | hdd_component_pdev_close(hdd_ctx->pdev); |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11409 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11410 | hdd_component_psoc_close(hdd_ctx->psoc); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11411 | dispatcher_pdev_close(hdd_ctx->pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11412 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 11413 | if (ret) { |
| 11414 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 11415 | QDF_ASSERT(0); |
| 11416 | } |
| 11417 | |
| 11418 | /* |
| 11419 | * Reset total mac phy during module stop such that during |
| 11420 | * next module start same psoc is used to populate new service |
| 11421 | * ready data |
| 11422 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11423 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11424 | if (tgt_hdl) |
| 11425 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 11426 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11427 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11428 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 11429 | if (!hif_ctx) { |
| 11430 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11431 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11432 | } |
| 11433 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 11434 | if (hdd_ctx->target_hw_name) { |
| 11435 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 11436 | hdd_ctx->target_hw_name = NULL; |
| 11437 | } |
| 11438 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 11439 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11440 | |
| 11441 | ol_cds_free(); |
| 11442 | |
Dustin Brown | c2a156e | 2018-10-25 16:56:27 -0700 | [diff] [blame] | 11443 | if (IS_IDLE_STOP) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11444 | ret = pld_power_off(qdf_ctx->dev); |
| 11445 | if (ret) |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11446 | hdd_err("Failed to power down device; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11447 | } |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11448 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11449 | /* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */ |
| 11450 | wlan_hdd_free_cache_channels(hdd_ctx); |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11451 | |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 11452 | hdd_check_for_leaks(hdd_ctx, is_recovery_stop); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 11453 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11454 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11455 | /* Once the firmware sequence is completed reset this flag */ |
| 11456 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11457 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11458 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11459 | |
Kai Liu | eabb1df | 2018-11-08 14:58:54 +0800 | [diff] [blame] | 11460 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, PLD_BUS_WIDTH_NONE); |
| 11461 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11462 | done: |
| 11463 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11464 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11465 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11466 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11467 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11468 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11469 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11470 | } |
| 11471 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11472 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11473 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11474 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11475 | * hdd_state_info_dump() - prints state information of hdd layer |
| 11476 | * @buf: buffer pointer |
| 11477 | * @size: size of buffer to be filled |
| 11478 | * |
| 11479 | * This function is used to dump state information of hdd layer |
| 11480 | * |
| 11481 | * Return: None |
| 11482 | */ |
| 11483 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 11484 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11485 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 11486 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11487 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11488 | uint16_t len = 0; |
| 11489 | char *buf = *buf_ptr; |
| 11490 | |
| 11491 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11492 | if (!hdd_ctx) { |
| 11493 | hdd_err("Failed to get hdd context "); |
| 11494 | return; |
| 11495 | } |
| 11496 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11497 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11498 | |
| 11499 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 11500 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11501 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 11502 | "\n is_scheduler_suspended %d", |
| 11503 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11504 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11505 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11506 | if (adapter->dev) |
| 11507 | len += scnprintf(buf + len, *size - len, |
| 11508 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 11509 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11510 | "\n device_mode: %d", adapter->device_mode); |
| 11511 | switch (adapter->device_mode) { |
| 11512 | case QDF_STA_MODE: |
| 11513 | case QDF_P2P_CLIENT_MODE: |
| 11514 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11515 | len += scnprintf(buf + len, *size - len, |
| 11516 | "\n connState: %d", |
| 11517 | hdd_sta_ctx->conn_info.connState); |
| 11518 | break; |
| 11519 | |
| 11520 | default: |
| 11521 | break; |
| 11522 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11523 | } |
| 11524 | |
| 11525 | *size -= len; |
| 11526 | *buf_ptr += len; |
| 11527 | } |
| 11528 | |
| 11529 | /** |
| 11530 | * hdd_register_debug_callback() - registration function for hdd layer |
| 11531 | * to print hdd state information |
| 11532 | * |
| 11533 | * Return: None |
| 11534 | */ |
| 11535 | static void hdd_register_debug_callback(void) |
| 11536 | { |
| 11537 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 11538 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11539 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 11540 | static void hdd_register_debug_callback(void) |
| 11541 | { |
| 11542 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11543 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11544 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11545 | /* |
| 11546 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 11547 | * |
| 11548 | * This function is used to create bug report lock |
| 11549 | * |
| 11550 | * Return: None |
| 11551 | */ |
| 11552 | static void wlan_init_bug_report_lock(void) |
| 11553 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 11554 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11555 | |
| 11556 | p_cds_context = cds_get_global_context(); |
| 11557 | if (!p_cds_context) { |
| 11558 | hdd_err("cds context is NULL"); |
| 11559 | return; |
| 11560 | } |
| 11561 | |
| 11562 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 11563 | } |
| 11564 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11565 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11566 | void hdd_dp_trace_init(struct hdd_config *config) |
| 11567 | { |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11568 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 11569 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 11570 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 11571 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 11572 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 11573 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 11574 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11575 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11576 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11577 | if (!config->enable_dp_trace) { |
| 11578 | hdd_err("dp trace is disabled from ini"); |
| 11579 | return; |
| 11580 | } |
| 11581 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11582 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 11583 | &num_entries, sizeof(config_params)); |
| 11584 | |
| 11585 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11586 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11587 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11588 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11589 | else if (bw_compute_interval > 1000) { |
| 11590 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 11591 | thresh_time_limit = 1; |
| 11592 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11593 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 11594 | |
| 11595 | switch (num_entries) { |
| 11596 | case 4: |
| 11597 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11598 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11599 | case 3: |
| 11600 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11601 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11602 | case 2: |
| 11603 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11604 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11605 | case 1: |
| 11606 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11607 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11608 | default: |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 11609 | hdd_debug("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 11610 | live_mode, thresh, thresh_time_limit, |
| 11611 | verbosity, proto_bitmap); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11612 | }; |
| 11613 | |
| 11614 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 11615 | verbosity, proto_bitmap); |
| 11616 | |
| 11617 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11618 | #endif |
| 11619 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11620 | #ifdef DISABLE_CHANNEL_LIST |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11621 | 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] | 11622 | { |
| 11623 | return qdf_mutex_create(&hdd_ctx->cache_channel_lock); |
| 11624 | } |
| 11625 | #else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11626 | 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] | 11627 | { |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11628 | return QDF_STATUS_SUCCESS; |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11629 | } |
| 11630 | #endif |
| 11631 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11632 | static QDF_STATUS hdd_open_adapter_no_trans(struct hdd_context *hdd_ctx, |
| 11633 | enum QDF_OPMODE op_mode, |
| 11634 | const char *iface_name, |
| 11635 | uint8_t *mac_addr_bytes) |
| 11636 | { |
| 11637 | struct hdd_vdev_sync *vdev_sync; |
| 11638 | struct hdd_adapter *adapter; |
| 11639 | QDF_STATUS status; |
| 11640 | int errno; |
| 11641 | |
| 11642 | QDF_BUG(rtnl_is_locked()); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11643 | |
Dustin Brown | d01590f | 2019-01-31 16:52:06 -0800 | [diff] [blame] | 11644 | errno = hdd_vdev_sync_create(hdd_ctx->parent_dev, &vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11645 | if (errno) |
| 11646 | return qdf_status_from_os_return(errno); |
| 11647 | |
| 11648 | adapter = hdd_open_adapter(hdd_ctx, op_mode, iface_name, |
| 11649 | mac_addr_bytes, NET_NAME_UNKNOWN, true); |
| 11650 | if (!adapter) { |
| 11651 | status = QDF_STATUS_E_INVAL; |
| 11652 | goto destroy_sync; |
| 11653 | } |
| 11654 | |
| 11655 | hdd_vdev_sync_register(adapter->dev, vdev_sync); |
| 11656 | |
| 11657 | return QDF_STATUS_SUCCESS; |
| 11658 | |
| 11659 | destroy_sync: |
| 11660 | hdd_vdev_sync_destroy(vdev_sync); |
| 11661 | |
| 11662 | return status; |
| 11663 | } |
| 11664 | |
| 11665 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 11666 | /** |
| 11667 | * hdd_open_p2p_interface - Open P2P interface |
| 11668 | * @hdd_ctx: HDD context |
| 11669 | * |
| 11670 | * Return: QDF_STATUS |
| 11671 | */ |
| 11672 | static QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
| 11673 | { |
| 11674 | QDF_STATUS status; |
| 11675 | bool p2p_dev_addr_admin; |
| 11676 | bool is_p2p_locally_administered = false; |
| 11677 | |
| 11678 | cfg_p2p_get_device_addr_admin(hdd_ctx->psoc, &p2p_dev_addr_admin); |
| 11679 | |
| 11680 | if (p2p_dev_addr_admin) { |
| 11681 | if (hdd_ctx->num_provisioned_addr && |
| 11682 | !(hdd_ctx->provisioned_mac_addr[0].bytes[0] & 0x02)) { |
| 11683 | hdd_ctx->p2p_device_address = |
| 11684 | hdd_ctx->provisioned_mac_addr[0]; |
| 11685 | |
| 11686 | /* |
| 11687 | * Generate the P2P Device Address. This consists of |
| 11688 | * the device's primary MAC address with the locally |
| 11689 | * administered bit set. |
| 11690 | */ |
| 11691 | |
| 11692 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
| 11693 | is_p2p_locally_administered = true; |
| 11694 | } else if (!(hdd_ctx->derived_mac_addr[0].bytes[0] & 0x02)) { |
| 11695 | hdd_ctx->p2p_device_address = |
| 11696 | hdd_ctx->derived_mac_addr[0]; |
| 11697 | /* |
| 11698 | * Generate the P2P Device Address. This consists of |
| 11699 | * the device's primary MAC address with the locally |
| 11700 | * administered bit set. |
| 11701 | */ |
| 11702 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
| 11703 | is_p2p_locally_administered = true; |
| 11704 | } |
| 11705 | } |
| 11706 | if (!is_p2p_locally_administered) { |
| 11707 | uint8_t *p2p_dev_addr; |
| 11708 | |
| 11709 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx, |
| 11710 | QDF_P2P_DEVICE_MODE); |
| 11711 | if (!p2p_dev_addr) { |
| 11712 | hdd_err("Failed to get MAC address for new p2p device"); |
| 11713 | return QDF_STATUS_E_INVAL; |
| 11714 | } |
| 11715 | |
| 11716 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
| 11717 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
| 11718 | } |
| 11719 | |
| 11720 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_P2P_DEVICE_MODE, |
| 11721 | "p2p%d", |
| 11722 | hdd_ctx->p2p_device_address.bytes); |
| 11723 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11724 | hdd_err("Failed to open p2p interface"); |
| 11725 | return QDF_STATUS_E_INVAL; |
| 11726 | } |
| 11727 | |
| 11728 | return QDF_STATUS_SUCCESS; |
| 11729 | } |
| 11730 | #else |
| 11731 | static inline QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
| 11732 | { |
| 11733 | return QDF_STATUS_SUCCESS; |
| 11734 | } |
| 11735 | #endif |
| 11736 | |
| 11737 | static QDF_STATUS hdd_open_ocb_interface(struct hdd_context *hdd_ctx) |
| 11738 | { |
| 11739 | QDF_STATUS status; |
| 11740 | uint8_t *mac_addr; |
| 11741 | |
| 11742 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_OCB_MODE); |
| 11743 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_OCB_MODE, |
| 11744 | "wlanocb%d", mac_addr); |
| 11745 | if (QDF_IS_STATUS_ERROR(status)) |
| 11746 | hdd_err("Failed to open 802.11p interface"); |
| 11747 | |
| 11748 | return status; |
| 11749 | } |
| 11750 | |
| 11751 | static QDF_STATUS hdd_open_concurrent_interface(struct hdd_context *hdd_ctx) |
| 11752 | { |
| 11753 | QDF_STATUS status; |
| 11754 | const char *iface_name; |
| 11755 | uint8_t *mac_addr; |
| 11756 | |
| 11757 | if (qdf_str_eq(hdd_ctx->config->enable_concurrent_sta, "")) |
| 11758 | return QDF_STATUS_SUCCESS; |
| 11759 | |
| 11760 | iface_name = hdd_ctx->config->enable_concurrent_sta; |
| 11761 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_STA_MODE); |
| 11762 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_STA_MODE, |
| 11763 | iface_name, mac_addr); |
| 11764 | if (QDF_IS_STATUS_ERROR(status)) |
| 11765 | hdd_err("Failed to open concurrent station interface"); |
| 11766 | |
| 11767 | return status; |
| 11768 | } |
| 11769 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11770 | static QDF_STATUS |
| 11771 | hdd_open_adapters_for_mission_mode(struct hdd_context *hdd_ctx) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11772 | { |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11773 | enum dot11p_mode dot11p_mode; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11774 | QDF_STATUS status; |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11775 | uint8_t *mac_addr; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11776 | |
| 11777 | ucfg_mlme_get_dot11p_mode(hdd_ctx->psoc, &dot11p_mode); |
| 11778 | |
| 11779 | /* Create only 802.11p interface? */ |
| 11780 | if (dot11p_mode == CFG_11P_STANDALONE) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11781 | return hdd_open_ocb_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11782 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11783 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_STA_MODE); |
| 11784 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_STA_MODE, |
| 11785 | "wlan%d", mac_addr); |
| 11786 | if (QDF_IS_STATUS_ERROR(status)) |
| 11787 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11788 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11789 | /* opening concurrent STA is best effort, continue on error */ |
| 11790 | hdd_open_concurrent_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11791 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11792 | status = hdd_open_p2p_interface(hdd_ctx); |
| 11793 | if (status) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11794 | goto err_close_adapters; |
| 11795 | |
| 11796 | /* Open 802.11p Interface */ |
| 11797 | if (dot11p_mode == CFG_11P_CONCURRENT) { |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11798 | status = hdd_open_ocb_interface(hdd_ctx); |
| 11799 | if (QDF_IS_STATUS_ERROR(status)) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11800 | goto err_close_adapters; |
| 11801 | } |
| 11802 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11803 | return QDF_STATUS_SUCCESS; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11804 | |
| 11805 | err_close_adapters: |
| 11806 | hdd_close_all_adapters(hdd_ctx, true); |
| 11807 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11808 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11809 | } |
| 11810 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11811 | 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] | 11812 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11813 | 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] | 11814 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11815 | return hdd_open_adapter_no_trans(hdd_ctx, QDF_FTM_MODE, |
| 11816 | "wlan%d", mac_addr); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11817 | } |
| 11818 | |
| 11819 | static QDF_STATUS |
| 11820 | hdd_open_adapters_for_monitor_mode(struct hdd_context *hdd_ctx) |
| 11821 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11822 | 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] | 11823 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11824 | return hdd_open_adapter_no_trans(hdd_ctx, QDF_MONITOR_MODE, |
| 11825 | "wlan%d", mac_addr); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11826 | } |
| 11827 | |
| 11828 | static QDF_STATUS hdd_open_adapters_for_epping_mode(struct hdd_context *hdd_ctx) |
| 11829 | { |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11830 | QDF_STATUS status; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11831 | qdf_device_t qdf_dev; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11832 | |
| 11833 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11834 | QDF_BUG(qdf_dev); |
| 11835 | if (!qdf_dev) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11836 | return QDF_STATUS_E_INVAL; |
| 11837 | |
| 11838 | status = epping_open(); |
| 11839 | if (QDF_IS_STATUS_ERROR(status)) |
| 11840 | return status; |
| 11841 | |
| 11842 | if (epping_enable(qdf_dev->dev)) { |
| 11843 | status = QDF_STATUS_E_INVAL; |
| 11844 | goto epping_close; |
| 11845 | } |
| 11846 | |
| 11847 | return QDF_STATUS_SUCCESS; |
| 11848 | |
| 11849 | epping_close: |
| 11850 | epping_close(); |
| 11851 | |
| 11852 | return status; |
| 11853 | } |
| 11854 | |
| 11855 | typedef QDF_STATUS (*hdd_open_mode_handler)(struct hdd_context *hdd_ctx); |
| 11856 | |
| 11857 | static const hdd_open_mode_handler |
| 11858 | hdd_open_mode_handlers[QDF_GLOBAL_MAX_MODE] = { |
| 11859 | [QDF_GLOBAL_MISSION_MODE] = hdd_open_adapters_for_mission_mode, |
| 11860 | [QDF_GLOBAL_FTM_MODE] = hdd_open_adapters_for_ftm_mode, |
| 11861 | [QDF_GLOBAL_MONITOR_MODE] = hdd_open_adapters_for_monitor_mode, |
| 11862 | [QDF_GLOBAL_EPPING_MODE] = hdd_open_adapters_for_epping_mode, |
| 11863 | }; |
| 11864 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11865 | static QDF_STATUS hdd_open_adapters_for_mode(struct hdd_context *hdd_ctx, |
| 11866 | enum QDF_GLOBAL_MODE driver_mode) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11867 | { |
| 11868 | QDF_STATUS status; |
| 11869 | |
| 11870 | if (driver_mode < 0 || |
| 11871 | driver_mode >= QDF_GLOBAL_MAX_MODE || |
| 11872 | !hdd_open_mode_handlers[driver_mode]) { |
| 11873 | hdd_err("Driver mode %d not supported", driver_mode); |
| 11874 | return -ENOTSUPP; |
| 11875 | } |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11876 | |
| 11877 | hdd_hold_rtnl_lock(); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11878 | status = hdd_open_mode_handlers[driver_mode](hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11879 | hdd_release_rtnl_lock(); |
| 11880 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11881 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11882 | } |
| 11883 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11884 | int hdd_wlan_startup(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11885 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11886 | QDF_STATUS status; |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11887 | int errno; |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 11888 | bool is_imps_enabled; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11889 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11890 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11891 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11892 | hdd_action_oui_config(hdd_ctx); |
| 11893 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11894 | qdf_nbuf_init_replenish_timer(); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11895 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11896 | status = wlan_hdd_cache_chann_mutex_create(hdd_ctx); |
| 11897 | if (QDF_IS_STATUS_ERROR(status)) |
| 11898 | return qdf_status_to_os_return(status); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11899 | |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 11900 | #ifdef FEATURE_WLAN_CH_AVOID |
| 11901 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 11902 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11903 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11904 | osif_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 11905 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11906 | hdd_driver_memdump_init(); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11907 | hdd_bus_bandwidth_init(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11908 | |
Arunk Khandavalli | 5ff037547 | 2019-01-11 17:26:47 +0530 | [diff] [blame] | 11909 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 11910 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
| 11911 | QDF_TIMER_TYPE_SW, |
| 11912 | hdd_skip_acs_scan_timer_handler, |
| 11913 | hdd_ctx); |
| 11914 | if (QDF_IS_STATUS_ERROR(status)) |
| 11915 | hdd_err("Failed to init ACS Skip timer"); |
| 11916 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
| 11917 | #endif |
| 11918 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11919 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 11920 | if (errno) { |
| 11921 | hdd_err("Failed to start modules; errno:%d", errno); |
| 11922 | goto memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11923 | } |
| 11924 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 11925 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11926 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11927 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 11928 | if (!hdd_ctx->mac_handle) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11929 | hdd_err("Mac Handle is null"); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11930 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11931 | } |
| 11932 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11933 | errno = hdd_wiphy_init(hdd_ctx); |
| 11934 | if (errno) { |
| 11935 | hdd_err("Failed to initialize wiphy; errno:%d", errno); |
| 11936 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11937 | } |
| 11938 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11939 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 11940 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 11941 | errno = hdd_initialize_mac_address(hdd_ctx); |
| 11942 | if (errno) { |
| 11943 | hdd_err("MAC initializtion failed: %d", errno); |
| 11944 | goto unregister_wiphy; |
| 11945 | } |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 11946 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11947 | errno = register_netdevice_notifier(&hdd_netdev_notifier); |
| 11948 | if (errno) { |
| 11949 | hdd_err("register_netdevice_notifier failed; errno:%d", errno); |
| 11950 | goto unregister_wiphy; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11951 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 11952 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11953 | errno = register_reboot_notifier(&system_reboot_notifier); |
| 11954 | if (errno) { |
| 11955 | hdd_err("Failed to register reboot notifier; errno:%d", errno); |
| 11956 | goto unregister_netdev; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11957 | } |
| 11958 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 11959 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 11960 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 11961 | hdd_lpass_notify_wlan_version(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11962 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11963 | errno = hdd_register_notifiers(hdd_ctx); |
| 11964 | if (errno) |
| 11965 | goto unregister_reboot; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 11966 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11967 | status = wlansap_global_init(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11968 | if (QDF_IS_STATUS_ERROR(status)) |
| 11969 | goto unregister_notifiers; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11970 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 11971 | ucfg_mlme_is_imps_enabled(hdd_ctx->psoc, &is_imps_enabled); |
| 11972 | hdd_set_idle_ps_config(hdd_ctx, is_imps_enabled); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11973 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11974 | hdd_exit(); |
| 11975 | |
| 11976 | return 0; |
| 11977 | |
| 11978 | unregister_notifiers: |
| 11979 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11980 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11981 | unregister_reboot: |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11982 | unregister_reboot_notifier(&system_reboot_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11983 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11984 | unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11985 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 11986 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11987 | unregister_wiphy: |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 11988 | qdf_dp_trace_deinit(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11989 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11990 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11991 | stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11992 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11993 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11994 | memdump_deinit: |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11995 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11996 | hdd_driver_memdump_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11997 | osif_request_manager_deinit(); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11998 | qdf_nbuf_deinit_replenish_timer(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 11999 | |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 12000 | if (cds_is_fw_down()) |
| 12001 | hdd_err("Not setting the complete event as fw is down"); |
| 12002 | else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12003 | hdd_start_complete(errno); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12004 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12005 | hdd_exit(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12006 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12007 | return errno; |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12008 | } |
| 12009 | |
| 12010 | QDF_STATUS hdd_psoc_create_vdevs(struct hdd_context *hdd_ctx) |
| 12011 | { |
| 12012 | enum QDF_GLOBAL_MODE driver_mode = hdd_get_conparam(); |
| 12013 | QDF_STATUS status; |
| 12014 | |
| 12015 | status = hdd_open_adapters_for_mode(hdd_ctx, driver_mode); |
| 12016 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12017 | hdd_err("Failed to create vdevs; status:%d", status); |
| 12018 | return status; |
| 12019 | } |
| 12020 | |
| 12021 | if (hdd_ctx->rps) |
| 12022 | hdd_set_rps_cpu_mask(hdd_ctx); |
| 12023 | |
| 12024 | if (driver_mode != QDF_GLOBAL_FTM_MODE) |
| 12025 | hdd_psoc_idle_timer_start(hdd_ctx); |
| 12026 | |
| 12027 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12028 | } |
| 12029 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12030 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12031 | * hdd_wlan_update_target_info() - update target type info |
| 12032 | * @hdd_ctx: HDD context |
| 12033 | * @context: hif context |
| 12034 | * |
| 12035 | * Update target info received from firmware in hdd context |
| 12036 | * Return:None |
| 12037 | */ |
| 12038 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12039 | 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] | 12040 | { |
| 12041 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 12042 | |
| 12043 | if (!tgt_info) { |
| 12044 | hdd_err("Target info is Null"); |
| 12045 | return; |
| 12046 | } |
| 12047 | |
| 12048 | hdd_ctx->target_type = tgt_info->target_type; |
| 12049 | } |
| 12050 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12051 | 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] | 12052 | { |
| 12053 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12054 | int status; |
| 12055 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12056 | struct osif_request *request = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12057 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12058 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12059 | |
| 12060 | if (!rsp) { |
| 12061 | hdd_err("data is null"); |
| 12062 | return; |
| 12063 | } |
| 12064 | |
| 12065 | status = wlan_hdd_validate_context(hdd_ctx); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12066 | if (status != 0) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12067 | return; |
| 12068 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12069 | request = osif_request_get(context); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12070 | if (!request) { |
| 12071 | hdd_err("obselete request"); |
| 12072 | return; |
| 12073 | } |
| 12074 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12075 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 12076 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 12077 | hdd_err("Invalid adapter or adapter has invalid magic"); |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12078 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12079 | return; |
| 12080 | } |
| 12081 | |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 12082 | hdd_debug("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 12083 | hdd_debug("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 12084 | hdd_debug("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 12085 | hdd_debug("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 12086 | hdd_debug("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 12087 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 12088 | hdd_debug("rsp->dad_detected :%x", rsp->dad_detected); |
| 12089 | hdd_debug("rsp->connect_status :%x", rsp->connect_status); |
| 12090 | hdd_debug("rsp->ba_session_establishment_status :%x", |
| 12091 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12092 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12093 | 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] | 12094 | adapter->dad |= rsp->dad_detected; |
| 12095 | adapter->con_status = rsp->connect_status; |
| 12096 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12097 | /* Flag true indicates connectivity check stats present. */ |
| 12098 | if (rsp->connect_stats_present) { |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 12099 | hdd_debug("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 12100 | hdd_debug("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12101 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 12102 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 12103 | rsp->icmpv4_rsp_recvd; |
| 12104 | } |
| 12105 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12106 | osif_request_complete(request); |
| 12107 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12108 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12109 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12110 | } |
| 12111 | |
Visweswara Tanuku | 633976b | 2019-01-07 16:13:12 +0530 | [diff] [blame] | 12112 | #ifdef WLAN_FEATURE_MOTION_DETECTION |
| 12113 | /** |
| 12114 | * hdd_md_host_evt_cb - Callback for Motion Detection Event |
| 12115 | * @ctx: HDD context |
| 12116 | * @event: motion detect event |
| 12117 | * |
| 12118 | * Callback for Motion Detection Event. Re-enables Motion |
| 12119 | * Detection again upon event |
| 12120 | * |
| 12121 | * Return: QDF_STATUS QDF_STATUS_SUCCESS on Success and |
| 12122 | * QDF_STATUS_E_FAILURE on failure |
| 12123 | */ |
| 12124 | QDF_STATUS hdd_md_host_evt_cb(void *ctx, struct sir_md_evt *event) |
| 12125 | { |
| 12126 | struct hdd_adapter *adapter = NULL; |
| 12127 | struct hdd_context *hdd_ctx; |
| 12128 | QDF_STATUS status; |
| 12129 | struct sme_motion_det_en motion_det; |
| 12130 | |
| 12131 | if (!ctx || !event) |
| 12132 | return QDF_STATUS_E_INVAL; |
| 12133 | |
| 12134 | hdd_ctx = (struct hdd_context *)ctx; |
| 12135 | status = wlan_hdd_validate_context(hdd_ctx); |
| 12136 | if (0 != status) |
| 12137 | return QDF_STATUS_E_INVAL; |
| 12138 | |
| 12139 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, event->vdev_id); |
| 12140 | if (!adapter || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 12141 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 12142 | return QDF_STATUS_E_INVAL; |
| 12143 | } |
| 12144 | |
| 12145 | hdd_debug("Motion Detection CB vdev_id=%u, status=%u", |
| 12146 | event->vdev_id, event->status); |
| 12147 | |
| 12148 | if (adapter->motion_detection_mode) { |
| 12149 | motion_det.vdev_id = event->vdev_id; |
| 12150 | motion_det.enable = 1; |
| 12151 | hdd_debug("Motion Detect CB -> Enable Motion Detection again"); |
| 12152 | sme_motion_det_enable(hdd_ctx->mac_handle, &motion_det); |
| 12153 | } |
| 12154 | |
| 12155 | return QDF_STATUS_SUCCESS; |
| 12156 | } |
| 12157 | #endif /* WLAN_FEATURE_MOTION_DETECTION */ |
| 12158 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12159 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12160 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12161 | * @hdd_ctx: HDD context |
| 12162 | * |
| 12163 | * Register the HDD callbacks to CDS/SME. |
| 12164 | * |
| 12165 | * Return: 0 for success or Error code for failure |
| 12166 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12167 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12168 | { |
| 12169 | QDF_STATUS status; |
| 12170 | int ret = 0; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12171 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12172 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12173 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12174 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12175 | hdd_err("in ftm mode, no need to register callbacks"); |
| 12176 | return ret; |
| 12177 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12178 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12179 | mac_handle = hdd_ctx->mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12180 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12181 | sme_register_oem_data_rsp_callback(mac_handle, |
| 12182 | hdd_send_oem_data_rsp_msg); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12183 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12184 | sme_register_mgmt_frame_ind_callback(mac_handle, |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 12185 | hdd_indicate_mgmt_frame); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12186 | sme_set_tsfcb(mac_handle, hdd_get_tsf_cb, hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12187 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12188 | wlan_hdd_cfg80211_stats_ext_callback); |
| 12189 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12190 | sme_ext_scan_register_callback(mac_handle, |
| 12191 | wlan_hdd_cfg80211_extscan_callback); |
| 12192 | sme_stats_ext2_register_callback(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 12193 | wlan_hdd_cfg80211_stats_ext2_callback); |
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_set_rssi_threshold_breached_cb(mac_handle, |
| 12196 | hdd_rssi_threshold_breached); |
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_set_link_layer_stats_ind_cb(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12199 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 12200 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12201 | 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] | 12202 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12203 | sme_set_link_layer_ext_cb(mac_handle, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 12204 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 12205 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12206 | status = sme_set_lost_link_info_cb(mac_handle, |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 12207 | hdd_lost_link_info_cb); |
| 12208 | /* print error and not block the startup process */ |
| 12209 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12210 | hdd_err("set lost link info callback failed"); |
| 12211 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12212 | ret = hdd_register_data_stall_detect_cb(); |
| 12213 | if (ret) { |
| 12214 | hdd_err("Register data stall detect detect callback failed."); |
| 12215 | return ret; |
| 12216 | } |
| 12217 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12218 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 12219 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12220 | sme_register_set_connection_info_cb(mac_handle, |
| 12221 | hdd_set_connection_in_progress, |
| 12222 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12223 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12224 | status = sme_congestion_register_callback(mac_handle, |
| 12225 | hdd_update_cca_info_cb); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12226 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12227 | hdd_err("set congestion callback failed"); |
| 12228 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12229 | status = sme_set_bt_activity_info_cb(mac_handle, |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 12230 | hdd_bt_activity_cb); |
| 12231 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12232 | hdd_err("set bt activity info callback failed"); |
| 12233 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12234 | status = sme_register_tx_queue_cb(mac_handle, |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 12235 | hdd_tx_queue_cb); |
| 12236 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12237 | hdd_err("Register tx queue callback failed"); |
| 12238 | |
Visweswara Tanuku | 633976b | 2019-01-07 16:13:12 +0530 | [diff] [blame] | 12239 | #ifdef WLAN_FEATURE_MOTION_DETECTION |
| 12240 | sme_set_md_host_evt_cb(mac_handle, hdd_md_host_evt_cb, (void *)hdd_ctx); |
| 12241 | #endif /* WLAN_FEATURE_MOTION_DETECTION */ |
| 12242 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12243 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12244 | |
| 12245 | return ret; |
| 12246 | } |
| 12247 | |
| 12248 | /** |
| 12249 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 12250 | * @hdd_ctx: HDD context |
| 12251 | * |
| 12252 | * De-Register the HDD callbacks to CDS/SME. |
| 12253 | * |
| 12254 | * Return: void |
| 12255 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12256 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12257 | { |
| 12258 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12259 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12260 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12261 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12262 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12263 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12264 | hdd_err("in ftm mode, no need to deregister callbacks"); |
| 12265 | return; |
| 12266 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12267 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12268 | mac_handle = hdd_ctx->mac_handle; |
| 12269 | sme_deregister_tx_queue_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12270 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12271 | sme_reset_link_layer_stats_ind_cb(mac_handle); |
| 12272 | sme_reset_rssi_threshold_breached_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12273 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12274 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12275 | wlan_hdd_cfg80211_stats_ext_callback); |
| 12276 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12277 | status = sme_reset_tsfcb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12278 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12279 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 12280 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12281 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12282 | ret = hdd_deregister_data_stall_detect_cb(); |
| 12283 | if (ret) |
| 12284 | hdd_err("Failed to de-register data stall detect event callback"); |
| 12285 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12286 | sme_deregister_oem_data_rsp_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12287 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12288 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12289 | } |
| 12290 | |
| 12291 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12292 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 12293 | * @adapter: Pointer to the HDD |
| 12294 | * @enable: bool value |
| 12295 | * |
| 12296 | * This to take counter measure to handle deauth req from HDD |
| 12297 | * |
| 12298 | * Return: None |
| 12299 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12300 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 12301 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12302 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12303 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12304 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12305 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12306 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12307 | /* Ignore request to deauth bcmc station */ |
| 12308 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12309 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12310 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12311 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12312 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 12313 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12314 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12315 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12316 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12317 | } |
| 12318 | |
| 12319 | /** |
| 12320 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 12321 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 12322 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12323 | * |
| 12324 | * This to take counter measure to handle deauth req from HDD |
| 12325 | * |
| 12326 | * Return: None |
| 12327 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12328 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 12329 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12330 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12331 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12332 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12333 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 12334 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12335 | return; |
| 12336 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12337 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 12338 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12339 | } |
| 12340 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12341 | void wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12342 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12343 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12344 | struct hdd_adapter *adapter = NULL; |
| 12345 | struct csr_roam_profile *roam_profile; |
| 12346 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12347 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12348 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12349 | hdd_debug("No active sta session"); |
| 12350 | return; |
| 12351 | } |
| 12352 | |
| 12353 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12354 | roam_profile = hdd_roam_profile(adapter); |
| 12355 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12356 | |
| 12357 | if (cur_adapter->session_id != adapter->session_id && |
| 12358 | adapter->device_mode == QDF_STA_MODE && |
| 12359 | hdd_conn_is_connected(sta_ctx)) { |
| 12360 | hdd_debug("%d Disable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12361 | sme_stop_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12362 | adapter->session_id, |
| 12363 | ecsr_driver_disabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12364 | } |
| 12365 | } |
| 12366 | } |
| 12367 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12368 | void wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12369 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12370 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12371 | struct hdd_adapter *adapter = NULL; |
| 12372 | struct csr_roam_profile *roam_profile; |
| 12373 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12374 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12375 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12376 | hdd_debug("No active sta session"); |
| 12377 | return; |
| 12378 | } |
| 12379 | |
| 12380 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12381 | roam_profile = hdd_roam_profile(adapter); |
| 12382 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12383 | |
| 12384 | if (cur_adapter->session_id != adapter->session_id && |
| 12385 | adapter->device_mode == QDF_STA_MODE && |
| 12386 | hdd_conn_is_connected(sta_ctx)) { |
| 12387 | hdd_debug("%d Enable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12388 | sme_start_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12389 | adapter->session_id, |
| 12390 | REASON_DRIVER_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12391 | } |
| 12392 | } |
| 12393 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12394 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12395 | /** |
| 12396 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 12397 | * @skb: sk buffer pointer |
| 12398 | * |
| 12399 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 12400 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 12401 | * |
| 12402 | * Return: None |
| 12403 | */ |
| 12404 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 12405 | { |
| 12406 | #ifdef CNSS_GENL |
| 12407 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 12408 | #else |
| 12409 | nl_srv_bcast(skb); |
| 12410 | #endif |
| 12411 | } |
| 12412 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12413 | 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] | 12414 | { |
| 12415 | struct sk_buff *skb; |
| 12416 | struct nlmsghdr *nlh; |
| 12417 | tAniMsgHdr *ani_hdr; |
| 12418 | void *nl_data = NULL; |
| 12419 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12420 | struct radio_index_tlv *radio_info; |
| 12421 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12422 | |
| 12423 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 12424 | flags = GFP_ATOMIC; |
| 12425 | |
| 12426 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 12427 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12428 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12429 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12430 | |
| 12431 | nlh = (struct nlmsghdr *)skb->data; |
| 12432 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 12433 | nlh->nlmsg_flags = 0; |
| 12434 | nlh->nlmsg_seq = 0; |
| 12435 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 12436 | |
| 12437 | ani_hdr = NLMSG_DATA(nlh); |
| 12438 | ani_hdr->type = type; |
| 12439 | |
| 12440 | switch (type) { |
| 12441 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 12442 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12443 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12444 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12445 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12446 | ani_hdr->length = 0; |
| 12447 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12448 | break; |
| 12449 | case WLAN_SVC_WLAN_STATUS_IND: |
| 12450 | case WLAN_SVC_WLAN_VERSION_IND: |
| 12451 | case WLAN_SVC_DFS_CAC_START_IND: |
| 12452 | case WLAN_SVC_DFS_CAC_END_IND: |
| 12453 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 12454 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 12455 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 12456 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 12457 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 12458 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12459 | ani_hdr->length = len; |
| 12460 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 12461 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 12462 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12463 | break; |
| 12464 | |
| 12465 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 12466 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12467 | type); |
| 12468 | kfree_skb(skb); |
| 12469 | return; |
| 12470 | } |
| 12471 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12472 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 12473 | * Add radio index at the end of the svc event in TLV format |
| 12474 | * to maintain the backward compatibility with userspace |
| 12475 | * applications. |
| 12476 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12477 | |
| 12478 | tlv_len = 0; |
| 12479 | |
| 12480 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 12481 | < WLAN_NL_MAX_PAYLOAD) { |
| 12482 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 12483 | sizeof(*ani_hdr) + len); |
| 12484 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 12485 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 12486 | radio_info->radio = radio; |
| 12487 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12488 | hdd_debug("Added radio index tlv - radio index %d", |
| 12489 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12490 | } |
| 12491 | |
| 12492 | nlh->nlmsg_len += tlv_len; |
| 12493 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 12494 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12495 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12496 | } |
| 12497 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12498 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 12499 | void wlan_hdd_auto_shutdown_cb(void) |
| 12500 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12501 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12502 | |
| 12503 | if (!hdd_ctx) |
| 12504 | return; |
| 12505 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12506 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12507 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 12508 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12509 | } |
| 12510 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12511 | 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] | 12512 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12513 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12514 | bool ap_connected = false, sta_connected = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12515 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12516 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12517 | mac_handle = hdd_ctx->mac_handle; |
| 12518 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12519 | return; |
| 12520 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12521 | if (hdd_ctx->config->wlan_auto_shutdown == 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12522 | return; |
| 12523 | |
| 12524 | if (enable == false) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12525 | if (sme_set_auto_shutdown_timer(mac_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12526 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12527 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12528 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12529 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12530 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12531 | return; |
| 12532 | } |
| 12533 | |
| 12534 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12535 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->psoc)) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12536 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12537 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12538 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 12539 | conn_info.connState == |
| 12540 | eConnectionState_Associated) { |
| 12541 | sta_connected = true; |
| 12542 | break; |
| 12543 | } |
| 12544 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12545 | |
| 12546 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12547 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12548 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12549 | ap_connected = true; |
| 12550 | break; |
| 12551 | } |
| 12552 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12553 | } |
| 12554 | } |
| 12555 | |
| 12556 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12557 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12558 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12559 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12560 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12561 | if (sme_set_auto_shutdown_timer(mac_handle, |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12562 | hdd_ctx->config->wlan_auto_shutdown) |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12563 | != QDF_STATUS_SUCCESS) |
| 12564 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 12565 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 12566 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12567 | hdd_ctx->config->wlan_auto_shutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12568 | } |
| 12569 | #endif |
| 12570 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12571 | struct hdd_adapter * |
| 12572 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 12573 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12574 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12575 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12576 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12577 | |
| 12578 | con_sap_adapter = NULL; |
| 12579 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12580 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12581 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 12582 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12583 | adapter != this_sap_adapter) { |
| 12584 | if (check_start_bss) { |
| 12585 | if (test_bit(SOFTAP_BSS_STARTED, |
| 12586 | &adapter->event_flags)) { |
| 12587 | con_sap_adapter = adapter; |
| 12588 | break; |
| 12589 | } |
| 12590 | } else { |
| 12591 | con_sap_adapter = adapter; |
| 12592 | break; |
| 12593 | } |
| 12594 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12595 | } |
| 12596 | |
| 12597 | return con_sap_adapter; |
| 12598 | } |
| 12599 | |
| 12600 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12601 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12602 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12603 | return adapter->device_mode == QDF_STA_MODE || |
| 12604 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12605 | } |
| 12606 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12607 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12608 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12609 | return adapter->device_mode == QDF_SAP_MODE || |
| 12610 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 12611 | } |
| 12612 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12613 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12614 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12615 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12616 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12617 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12618 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12619 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 12620 | conn_info.connState == eConnectionState_Associated) { |
| 12621 | return true; |
| 12622 | } |
| 12623 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12624 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12625 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12626 | return true; |
| 12627 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12628 | } |
| 12629 | |
| 12630 | return false; |
| 12631 | } |
| 12632 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12633 | static bool hdd_bus_bw_compute_timer_is_running(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12634 | { |
| 12635 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12636 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 12637 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12638 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 12639 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12640 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12641 | return is_running; |
| 12642 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12643 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12644 | 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] | 12645 | { |
| 12646 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 12647 | hdd_ctx->bus_bw_timer_running = true; |
| 12648 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 12649 | hdd_ctx->config->bus_bw_compute_interval); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12650 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 12651 | } |
| 12652 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12653 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12654 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12655 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12656 | |
| 12657 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12658 | hdd_debug("Bandwidth compute timer already started"); |
| 12659 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12660 | } |
| 12661 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12662 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12663 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12664 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12665 | } |
| 12666 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12667 | 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] | 12668 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12669 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12670 | |
| 12671 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12672 | hdd_debug("Bandwidth compute timer already started"); |
| 12673 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 12674 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12675 | |
| 12676 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12677 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12678 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12679 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12680 | } |
| 12681 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12682 | 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] | 12683 | { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12684 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12685 | |
| 12686 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12687 | hdd_ctx->bus_bw_timer_running = false; |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 12688 | qdf_timer_sync_cancel(&hdd_ctx->bus_bw_timer); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12689 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 12690 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 12691 | /* work callback is long running; flush outside of lock */ |
| 12692 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12693 | hdd_reset_tcp_delack(hdd_ctx); |
| 12694 | } |
| 12695 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12696 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12697 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12698 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12699 | |
| 12700 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12701 | hdd_debug("Bandwidth compute timer already stopped"); |
| 12702 | return; |
| 12703 | } |
| 12704 | |
| 12705 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12706 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12707 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12708 | } |
| 12709 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12710 | 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] | 12711 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12712 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12713 | |
| 12714 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12715 | hdd_debug("Bandwidth compute timer already stopped"); |
| 12716 | return; |
| 12717 | } |
| 12718 | |
| 12719 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12720 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12721 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12722 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12723 | } |
| 12724 | #endif |
| 12725 | |
| 12726 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12727 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 12728 | * @ap_adapter: SAP adapter |
| 12729 | * |
| 12730 | * This function will process the stopping of sap adapter. |
| 12731 | * |
| 12732 | * Return: None |
| 12733 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12734 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12735 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12736 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12737 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12738 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12739 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12740 | |
| 12741 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12742 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12743 | return; |
| 12744 | } |
| 12745 | |
| 12746 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12747 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12748 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12749 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12750 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12751 | mutex_lock(&hdd_ctx->sap_lock); |
| 12752 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 12753 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12754 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12755 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12756 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12757 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12758 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12759 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 12760 | qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 12761 | SME_CMD_STOP_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12762 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12763 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12764 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12765 | return; |
| 12766 | } |
| 12767 | } |
| 12768 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12769 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12770 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12771 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12772 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12773 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12774 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12775 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12776 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12777 | } |
| 12778 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12779 | } |
| 12780 | |
| 12781 | /** |
| 12782 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 12783 | * @ap_adapter: SAP adapter |
| 12784 | * |
| 12785 | * This function will process the starting of sap adapter. |
| 12786 | * |
| 12787 | * Return: None |
| 12788 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12789 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12790 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12791 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12792 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12793 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12794 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 12795 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12796 | |
| 12797 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12798 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12799 | return; |
| 12800 | } |
| 12801 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12802 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 12803 | hdd_err("SoftAp role has not been enabled"); |
| 12804 | return; |
| 12805 | } |
| 12806 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12807 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 12808 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12809 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 12810 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12811 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12812 | mutex_lock(&hdd_ctx->sap_lock); |
| 12813 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 12814 | goto end; |
| 12815 | |
| 12816 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12817 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12818 | goto end; |
| 12819 | } |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12820 | wlan_reg_set_channel_params(hdd_ctx->pdev, |
Abhinav Kumar | 6f69448 | 2018-09-04 16:07:39 +0530 | [diff] [blame] | 12821 | hdd_ap_ctx->sap_config.channel, 0, |
| 12822 | &hdd_ap_ctx->sap_config.ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12823 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 12824 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12825 | 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] | 12826 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12827 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12828 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12829 | goto end; |
| 12830 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12831 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12832 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 12833 | SME_CMD_START_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12834 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12835 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12836 | goto end; |
| 12837 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12838 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12839 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12840 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12841 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12842 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12843 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12844 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12845 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12846 | true); |
| 12847 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 12848 | mutex_unlock(&hdd_ctx->sap_lock); |
| 12849 | |
| 12850 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12851 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12852 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12853 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 12854 | /* SAP context and beacon cleanup will happen during driver unload |
| 12855 | * in hdd_stop_adapter |
| 12856 | */ |
| 12857 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 12858 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12859 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12860 | |
| 12861 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12862 | * hdd_get_fw_version() - Get FW version |
| 12863 | * @hdd_ctx: pointer to HDD context. |
| 12864 | * @major_spid: FW version - major spid. |
| 12865 | * @minor_spid: FW version - minor spid |
| 12866 | * @ssid: FW version - ssid |
| 12867 | * @crmid: FW version - crmid |
| 12868 | * |
| 12869 | * This function is called to get the firmware build version stored |
| 12870 | * as part of the HDD context |
| 12871 | * |
| 12872 | * Return: None |
| 12873 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12874 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12875 | uint32_t *major_spid, uint32_t *minor_spid, |
| 12876 | uint32_t *siid, uint32_t *crmid) |
| 12877 | { |
| 12878 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 12879 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 12880 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 12881 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 12882 | } |
| 12883 | |
| 12884 | #ifdef QCA_CONFIG_SMP |
| 12885 | /** |
| 12886 | * wlan_hdd_get_cpu() - get cpu_index |
| 12887 | * |
| 12888 | * Return: cpu_index |
| 12889 | */ |
| 12890 | int wlan_hdd_get_cpu(void) |
| 12891 | { |
| 12892 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12893 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12894 | put_cpu(); |
| 12895 | return cpu_index; |
| 12896 | } |
| 12897 | #endif |
| 12898 | |
| 12899 | /** |
| 12900 | * hdd_get_fwpath() - get framework path |
| 12901 | * |
| 12902 | * This function is used to get the string written by |
| 12903 | * userspace to start the wlan driver |
| 12904 | * |
| 12905 | * Return: string |
| 12906 | */ |
| 12907 | const char *hdd_get_fwpath(void) |
| 12908 | { |
| 12909 | return fwpath.string; |
| 12910 | } |
| 12911 | |
Dustin Brown | 94ce20f | 2018-09-04 13:11:38 -0700 | [diff] [blame] | 12912 | static inline int hdd_state_query_cb(void) |
| 12913 | { |
| 12914 | return !!wlan_hdd_validate_context(cds_get_context(QDF_MODULE_ID_HDD)); |
| 12915 | } |
| 12916 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12917 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12918 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12919 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12920 | * This function initilizes CDS global context with the help of cds_init. This |
| 12921 | * has to be the first function called after probe to get a valid global |
| 12922 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12923 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12924 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12925 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12926 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12927 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12928 | QDF_STATUS status; |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 12929 | int ret; |
| 12930 | |
| 12931 | hdd_dsc_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12932 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12933 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12934 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12935 | hdd_err("Failed to allocate CDS context"); |
| 12936 | ret = -ENOMEM; |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 12937 | goto deinit_dsc; |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12938 | } |
Dustin Brown | 94ce20f | 2018-09-04 13:11:38 -0700 | [diff] [blame] | 12939 | qdf_register_module_state_query_callback(hdd_state_query_cb); |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 12940 | |
| 12941 | wlan_init_bug_report_lock(); |
| 12942 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12943 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12944 | wlan_logging_sock_init_svc(); |
| 12945 | #endif |
| 12946 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12947 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 12948 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 12949 | QDF_TIMER_TYPE_SW); |
| 12950 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12951 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 12952 | hdd_register_debug_callback(); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12953 | wlan_roam_debug_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12954 | |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 12955 | return 0; |
| 12956 | |
| 12957 | deinit_dsc: |
| 12958 | hdd_dsc_deinit(); |
| 12959 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12960 | return ret; |
| 12961 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12962 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12963 | /** |
| 12964 | * hdd_deinit() - Deinitialize Driver |
| 12965 | * |
| 12966 | * This function frees CDS global context with the help of cds_deinit. This |
| 12967 | * has to be the last function call in remove callback to free the global |
| 12968 | * context. |
| 12969 | */ |
| 12970 | void hdd_deinit(void) |
| 12971 | { |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12972 | wlan_roam_debug_deinit(); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12973 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12974 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12975 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12976 | wlan_logging_sock_deinit_svc(); |
| 12977 | #endif |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12978 | |
| 12979 | wlan_destroy_bug_report_lock(); |
| 12980 | cds_deinit(); |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 12981 | |
| 12982 | hdd_dsc_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12983 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12984 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12985 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 12986 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 12987 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12988 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12989 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12990 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12991 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 12992 | struct file *file) |
| 12993 | { |
| 12994 | return 0; |
| 12995 | } |
| 12996 | |
| 12997 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 12998 | const char __user *user_buf, |
| 12999 | size_t count, |
| 13000 | loff_t *f_pos) |
| 13001 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 13002 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13003 | static const char wlan_off_str[] = "OFF"; |
| 13004 | static const char wlan_on_str[] = "ON"; |
| 13005 | int ret; |
| 13006 | unsigned long rc; |
| 13007 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 13008 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13009 | pr_err("Failed to read buffer\n"); |
| 13010 | return -EINVAL; |
| 13011 | } |
| 13012 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 13013 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13014 | pr_debug("Wifi turning off from UI\n"); |
| 13015 | goto exit; |
| 13016 | } |
| 13017 | |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 13018 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13019 | pr_info("Wifi Turning On from UI\n"); |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13020 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 13021 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13022 | pr_err("Invalid value received from framework"); |
| 13023 | goto exit; |
| 13024 | } |
| 13025 | |
| 13026 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 13027 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13028 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 13029 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 13030 | if (!rc) { |
Srinivas Girigowda | 09625b0 | 2018-09-10 15:28:09 -0700 | [diff] [blame] | 13031 | hdd_alert("Timed-out!!"); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13032 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13033 | return ret; |
| 13034 | } |
| 13035 | |
| 13036 | hdd_start_complete(0); |
| 13037 | } |
| 13038 | |
| 13039 | exit: |
| 13040 | return count; |
| 13041 | } |
| 13042 | |
| 13043 | |
| 13044 | const struct file_operations wlan_hdd_state_fops = { |
| 13045 | .owner = THIS_MODULE, |
| 13046 | .open = wlan_hdd_state_ctrl_param_open, |
| 13047 | .write = wlan_hdd_state_ctrl_param_write, |
| 13048 | }; |
| 13049 | |
| 13050 | static int wlan_hdd_state_ctrl_param_create(void) |
| 13051 | { |
| 13052 | unsigned int wlan_hdd_state_major = 0; |
| 13053 | int ret; |
| 13054 | struct device *dev; |
| 13055 | |
| 13056 | device = MKDEV(wlan_hdd_state_major, 0); |
| 13057 | |
| 13058 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 13059 | if (ret) { |
| 13060 | pr_err("Failed to register qcwlanstate"); |
| 13061 | goto dev_alloc_err; |
| 13062 | } |
| 13063 | wlan_hdd_state_major = MAJOR(device); |
| 13064 | |
| 13065 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 13066 | if (IS_ERR(class)) { |
| 13067 | pr_err("wlan_hdd_state class_create error"); |
| 13068 | goto class_err; |
| 13069 | } |
| 13070 | |
| 13071 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 13072 | if (IS_ERR(dev)) { |
| 13073 | pr_err("wlan_hdd_statedevice_create error"); |
| 13074 | goto err_class_destroy; |
| 13075 | } |
| 13076 | |
| 13077 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 13078 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 13079 | if (ret) { |
| 13080 | pr_err("Failed to add cdev error"); |
| 13081 | goto cdev_add_err; |
| 13082 | } |
| 13083 | |
| 13084 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 13085 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 13086 | |
| 13087 | return 0; |
| 13088 | |
| 13089 | cdev_add_err: |
| 13090 | device_destroy(class, device); |
| 13091 | err_class_destroy: |
| 13092 | class_destroy(class); |
| 13093 | class_err: |
| 13094 | unregister_chrdev_region(device, dev_num); |
| 13095 | dev_alloc_err: |
| 13096 | return -ENODEV; |
| 13097 | } |
| 13098 | |
| 13099 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 13100 | { |
| 13101 | cdev_del(&wlan_hdd_state_cdev); |
| 13102 | device_destroy(class, device); |
| 13103 | class_destroy(class); |
| 13104 | unregister_chrdev_region(device, dev_num); |
| 13105 | |
| 13106 | pr_info("Device node unregistered"); |
| 13107 | } |
| 13108 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13109 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13110 | * hdd_component_init() - Initialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13111 | * |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13112 | * Return: QDF_STATUS |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13113 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13114 | static QDF_STATUS hdd_component_init(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13115 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13116 | QDF_STATUS status; |
| 13117 | |
| 13118 | /* initialize converged components */ |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13119 | status = target_if_init(wma_get_psoc_from_scn_handle); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13120 | if (QDF_IS_STATUS_ERROR(status)) |
| 13121 | return status; |
| 13122 | |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13123 | status = ucfg_mlme_global_init(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13124 | if (QDF_IS_STATUS_ERROR(status)) |
| 13125 | goto target_if_deinit; |
| 13126 | |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13127 | status = dispatcher_init(); |
| 13128 | if (QDF_IS_STATUS_ERROR(status)) |
| 13129 | goto mlme_global_deinit; |
| 13130 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13131 | /* initialize non-converged components */ |
| 13132 | status = ucfg_mlme_init(); |
| 13133 | if (QDF_IS_STATUS_ERROR(status)) |
| 13134 | goto dispatcher_deinit; |
| 13135 | |
| 13136 | status = ucfg_fwol_init(); |
| 13137 | if (QDF_IS_STATUS_ERROR(status)) |
| 13138 | goto mlme_deinit; |
| 13139 | |
| 13140 | status = disa_init(); |
| 13141 | if (QDF_IS_STATUS_ERROR(status)) |
| 13142 | goto fwol_deinit; |
| 13143 | |
| 13144 | status = pmo_init(); |
| 13145 | if (QDF_IS_STATUS_ERROR(status)) |
| 13146 | goto disa_deinit; |
| 13147 | |
| 13148 | status = ucfg_ocb_init(); |
| 13149 | if (QDF_IS_STATUS_ERROR(status)) |
| 13150 | goto pmo_deinit; |
| 13151 | |
| 13152 | status = ipa_init(); |
| 13153 | if (QDF_IS_STATUS_ERROR(status)) |
| 13154 | goto ocb_deinit; |
| 13155 | |
| 13156 | status = ucfg_action_oui_init(); |
| 13157 | if (QDF_IS_STATUS_ERROR(status)) |
| 13158 | goto ipa_deinit; |
| 13159 | |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13160 | status = nan_init(); |
| 13161 | if (QDF_IS_STATUS_ERROR(status)) |
| 13162 | goto action_oui_deinit; |
| 13163 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13164 | status = ucfg_p2p_init(); |
| 13165 | if (QDF_IS_STATUS_ERROR(status)) |
| 13166 | goto nan_deinit; |
| 13167 | |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13168 | status = policy_mgr_init(); |
| 13169 | if (QDF_IS_STATUS_ERROR(status)) |
| 13170 | goto p2p_deinit; |
| 13171 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13172 | status = ucfg_tdls_init(); |
| 13173 | if (QDF_IS_STATUS_ERROR(status)) |
| 13174 | goto policy_deinit; |
| 13175 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13176 | return QDF_STATUS_SUCCESS; |
| 13177 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13178 | policy_deinit: |
| 13179 | policy_mgr_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13180 | p2p_deinit: |
| 13181 | ucfg_p2p_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13182 | nan_deinit: |
| 13183 | nan_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13184 | action_oui_deinit: |
| 13185 | ucfg_action_oui_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13186 | ipa_deinit: |
| 13187 | ipa_deinit(); |
| 13188 | ocb_deinit: |
| 13189 | ucfg_ocb_deinit(); |
| 13190 | pmo_deinit: |
| 13191 | pmo_deinit(); |
| 13192 | disa_deinit: |
| 13193 | disa_deinit(); |
| 13194 | fwol_deinit: |
| 13195 | ucfg_fwol_deinit(); |
| 13196 | mlme_deinit: |
| 13197 | ucfg_mlme_deinit(); |
| 13198 | dispatcher_deinit: |
| 13199 | dispatcher_deinit(); |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13200 | mlme_global_deinit: |
| 13201 | ucfg_mlme_global_deinit(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13202 | target_if_deinit: |
| 13203 | target_if_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13204 | |
| 13205 | return status; |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13206 | } |
| 13207 | |
| 13208 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13209 | * hdd_component_deinit() - Deinitialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13210 | * |
| 13211 | * Return: None |
| 13212 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13213 | static void hdd_component_deinit(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13214 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13215 | /* deinitialize non-converged components */ |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13216 | ucfg_tdls_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13217 | policy_mgr_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13218 | ucfg_p2p_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13219 | nan_deinit(); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 13220 | ucfg_action_oui_deinit(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 13221 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13222 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13223 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13224 | disa_deinit(); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13225 | ucfg_fwol_deinit(); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13226 | ucfg_mlme_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13227 | |
| 13228 | /* deinitialize converged components */ |
| 13229 | dispatcher_deinit(); |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13230 | ucfg_mlme_global_deinit(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13231 | target_if_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13232 | } |
| 13233 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13234 | QDF_STATUS hdd_component_psoc_open(struct wlan_objmgr_psoc *psoc) |
| 13235 | { |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13236 | QDF_STATUS status; |
| 13237 | |
| 13238 | status = ucfg_mlme_psoc_open(psoc); |
| 13239 | if (QDF_IS_STATUS_ERROR(status)) |
| 13240 | return status; |
| 13241 | |
| 13242 | status = ucfg_fwol_psoc_open(psoc); |
| 13243 | if (QDF_IS_STATUS_ERROR(status)) |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13244 | goto err_fwol; |
| 13245 | |
| 13246 | status = ucfg_pmo_psoc_open(psoc); |
| 13247 | if (QDF_IS_STATUS_ERROR(status)) |
| 13248 | goto err_pmo; |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13249 | |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13250 | status = ucfg_policy_mgr_psoc_open(psoc); |
| 13251 | if (QDF_IS_STATUS_ERROR(status)) |
| 13252 | goto err_plcy_mgr; |
| 13253 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13254 | status = ucfg_p2p_psoc_open(psoc); |
| 13255 | if (QDF_IS_STATUS_ERROR(status)) |
| 13256 | goto err_p2p; |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13257 | |
| 13258 | status = ucfg_tdls_psoc_open(psoc); |
| 13259 | if (QDF_IS_STATUS_ERROR(status)) |
| 13260 | goto err_tdls; |
| 13261 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13262 | return status; |
| 13263 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13264 | err_tdls: |
| 13265 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13266 | err_p2p: |
| 13267 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13268 | err_plcy_mgr: |
| 13269 | ucfg_pmo_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13270 | err_pmo: |
| 13271 | ucfg_fwol_psoc_close(psoc); |
| 13272 | err_fwol: |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13273 | ucfg_mlme_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13274 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13275 | return status; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13276 | } |
| 13277 | |
| 13278 | void hdd_component_psoc_close(struct wlan_objmgr_psoc *psoc) |
| 13279 | { |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13280 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13281 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13282 | ucfg_policy_mgr_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13283 | ucfg_pmo_psoc_close(psoc); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13284 | ucfg_fwol_psoc_close(psoc); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13285 | ucfg_mlme_psoc_close(psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13286 | } |
| 13287 | |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13288 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 13289 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13290 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13291 | disa_psoc_enable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13292 | nan_psoc_enable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13293 | p2p_psoc_enable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13294 | policy_mgr_psoc_enable(psoc); |
Wu Gao | a67c380 | 2018-12-27 12:07:52 +0800 | [diff] [blame] | 13295 | ucfg_tdls_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13296 | } |
| 13297 | |
| 13298 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 13299 | { |
Wu Gao | a67c380 | 2018-12-27 12:07:52 +0800 | [diff] [blame] | 13300 | ucfg_tdls_psoc_disable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13301 | policy_mgr_psoc_disable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13302 | p2p_psoc_disable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13303 | nan_psoc_disable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13304 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13305 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13306 | } |
| 13307 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 13308 | QDF_STATUS hdd_component_pdev_open(struct wlan_objmgr_pdev *pdev) |
| 13309 | { |
| 13310 | return ucfg_mlme_pdev_open(pdev); |
| 13311 | } |
| 13312 | |
| 13313 | void hdd_component_pdev_close(struct wlan_objmgr_pdev *pdev) |
| 13314 | { |
| 13315 | ucfg_mlme_pdev_close(pdev); |
| 13316 | } |
| 13317 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13318 | static struct hdd_driver __hdd_driver; |
| 13319 | |
| 13320 | static QDF_STATUS hdd_driver_ctx_init(struct hdd_driver *hdd_driver) |
| 13321 | { |
| 13322 | QDF_BUG(hdd_driver); |
| 13323 | if (!hdd_driver) |
| 13324 | return QDF_STATUS_E_INVAL; |
| 13325 | |
| 13326 | hdd_driver->state = driver_state_uninit; |
| 13327 | |
| 13328 | return dsc_driver_create(&hdd_driver->dsc_driver); |
| 13329 | } |
| 13330 | |
| 13331 | static void hdd_driver_ctx_deinit(struct hdd_driver *hdd_driver) |
| 13332 | { |
| 13333 | QDF_BUG(hdd_driver); |
| 13334 | if (!hdd_driver) |
| 13335 | return; |
| 13336 | |
| 13337 | dsc_driver_destroy(&hdd_driver->dsc_driver); |
| 13338 | qdf_mem_zero(hdd_driver, sizeof(*hdd_driver)); |
| 13339 | } |
| 13340 | |
| 13341 | struct hdd_driver *hdd_driver_get(void) |
| 13342 | { |
| 13343 | return &__hdd_driver; |
| 13344 | } |
| 13345 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13346 | static QDF_STATUS hdd_qdf_print_init(void) |
| 13347 | { |
| 13348 | QDF_STATUS status; |
| 13349 | int qdf_print_idx; |
| 13350 | |
| 13351 | status = qdf_print_setup(); |
| 13352 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13353 | pr_err("Failed qdf_print_setup; status:%u\n", status); |
| 13354 | return status; |
| 13355 | } |
| 13356 | |
| 13357 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 13358 | if (qdf_print_idx < 0) { |
| 13359 | pr_err("Failed to register for qdf_print_ctrl\n"); |
| 13360 | return QDF_STATUS_E_FAILURE; |
| 13361 | } |
| 13362 | |
| 13363 | qdf_set_pidx(qdf_print_idx); |
| 13364 | |
| 13365 | return QDF_STATUS_SUCCESS; |
| 13366 | } |
| 13367 | |
| 13368 | static void hdd_qdf_print_deinit(void) |
| 13369 | { |
| 13370 | int qdf_pidx = qdf_get_pidx(); |
| 13371 | |
| 13372 | qdf_set_pidx(-1); |
| 13373 | qdf_print_ctrl_cleanup(qdf_pidx); |
| 13374 | |
| 13375 | /* currently, no qdf print 'un-setup'*/ |
| 13376 | } |
| 13377 | |
| 13378 | static QDF_STATUS hdd_qdf_init(void) |
| 13379 | { |
| 13380 | QDF_STATUS status; |
| 13381 | |
| 13382 | status = hdd_qdf_print_init(); |
| 13383 | if (QDF_IS_STATUS_ERROR(status)) |
| 13384 | goto exit; |
| 13385 | |
| 13386 | status = qdf_debugfs_init(); |
| 13387 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13388 | hdd_err("Failed to init debugfs; status:%u", status); |
| 13389 | goto print_deinit; |
| 13390 | } |
| 13391 | |
| 13392 | qdf_lock_stats_init(); |
| 13393 | qdf_mem_init(); |
| 13394 | qdf_mc_timer_manager_init(); |
| 13395 | qdf_event_list_init(); |
| 13396 | |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13397 | status = qdf_talloc_feature_init(); |
| 13398 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13399 | hdd_err("Failed to init talloc; status:%u", status); |
| 13400 | goto event_deinit; |
| 13401 | } |
| 13402 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13403 | status = qdf_cpuhp_init(); |
| 13404 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13405 | hdd_err("Failed to init cpuhp; status:%u", status); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13406 | goto talloc_deinit; |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13407 | } |
| 13408 | |
| 13409 | status = qdf_trace_spin_lock_init(); |
| 13410 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13411 | hdd_err("Failed to init spinlock; status:%u", status); |
| 13412 | goto cpuhp_deinit; |
| 13413 | } |
| 13414 | |
| 13415 | qdf_trace_init(); |
| 13416 | qdf_register_debugcb_init(); |
| 13417 | |
| 13418 | return QDF_STATUS_SUCCESS; |
| 13419 | |
| 13420 | cpuhp_deinit: |
| 13421 | qdf_cpuhp_deinit(); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13422 | talloc_deinit: |
| 13423 | qdf_talloc_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13424 | event_deinit: |
| 13425 | qdf_event_list_destroy(); |
| 13426 | qdf_mc_timer_manager_exit(); |
| 13427 | qdf_mem_exit(); |
| 13428 | qdf_lock_stats_deinit(); |
| 13429 | qdf_debugfs_exit(); |
| 13430 | print_deinit: |
| 13431 | hdd_qdf_print_deinit(); |
| 13432 | |
| 13433 | exit: |
| 13434 | return status; |
| 13435 | } |
| 13436 | |
| 13437 | static void hdd_qdf_deinit(void) |
| 13438 | { |
| 13439 | /* currently, no debugcb deinit */ |
| 13440 | |
| 13441 | qdf_trace_deinit(); |
| 13442 | |
| 13443 | /* currently, no trace spinlock deinit */ |
| 13444 | |
| 13445 | qdf_cpuhp_deinit(); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13446 | qdf_talloc_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13447 | qdf_event_list_destroy(); |
| 13448 | qdf_mc_timer_manager_exit(); |
| 13449 | qdf_mem_exit(); |
| 13450 | qdf_lock_stats_deinit(); |
| 13451 | qdf_debugfs_exit(); |
| 13452 | hdd_qdf_print_deinit(); |
| 13453 | } |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13454 | |
| 13455 | /** |
| 13456 | * hdd_driver_load() - Perform the driver-level load operation |
| 13457 | * |
| 13458 | * Note: this is used in both static and DLKM driver builds |
| 13459 | * |
| 13460 | * Return: Errno |
| 13461 | */ |
| 13462 | static int hdd_driver_load(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13463 | { |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13464 | struct hdd_driver *hdd_driver = hdd_driver_get(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13465 | QDF_STATUS status; |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13466 | int errno; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13467 | |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 13468 | pr_err("%s: Loading driver v%s\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13469 | WLAN_MODULE_NAME, |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 13470 | g_wlan_driver_version); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13471 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13472 | status = hdd_qdf_init(); |
| 13473 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13474 | errno = qdf_status_to_os_return(status); |
| 13475 | goto exit; |
| 13476 | } |
| 13477 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13478 | status = hdd_driver_ctx_init(hdd_driver); |
| 13479 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13480 | hdd_err("Failed to init driver context; status:%u", status); |
| 13481 | errno = qdf_status_to_os_return(status); |
| 13482 | goto qdf_deinit; |
| 13483 | } |
| 13484 | |
| 13485 | status = dsc_driver_trans_start(hdd_driver->dsc_driver, "load"); |
| 13486 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13487 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13488 | errno = qdf_status_to_os_return(status); |
| 13489 | goto hdd_driver_deinit; |
| 13490 | } |
| 13491 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13492 | errno = hdd_init(); |
| 13493 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13494 | hdd_err("Failed to init HDD; errno:%d", errno); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13495 | goto trans_stop; |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13496 | } |
| 13497 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13498 | status = hdd_component_init(); |
| 13499 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13500 | hdd_err("Failed to init components; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13501 | errno = qdf_status_to_os_return(status); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13502 | goto hdd_deinit; |
| 13503 | } |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13504 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13505 | status = qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
| 13506 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13507 | hdd_err("Failed to create wake lock; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13508 | errno = qdf_status_to_os_return(status); |
| 13509 | goto comp_deinit; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13510 | } |
| 13511 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13512 | hdd_set_conparam(con_mode); |
| 13513 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13514 | errno = wlan_hdd_state_ctrl_param_create(); |
| 13515 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13516 | hdd_err("Failed to create ctrl param; errno:%d", errno); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13517 | goto wakelock_destroy; |
| 13518 | } |
| 13519 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13520 | errno = pld_init(); |
| 13521 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13522 | hdd_err("Failed to init PLD; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13523 | goto param_destroy; |
| 13524 | } |
| 13525 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13526 | hdd_driver->state = driver_state_loaded; |
| 13527 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
| 13528 | |
| 13529 | /* psoc probe can happen in registration; do after 'load' transition */ |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13530 | errno = wlan_hdd_register_driver(); |
| 13531 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13532 | hdd_err("Failed to register driver; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13533 | goto pld_deinit; |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13534 | } |
| 13535 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13536 | hdd_debug("%s: driver loaded", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13537 | |
| 13538 | return 0; |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13539 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13540 | pld_deinit: |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13541 | status = dsc_driver_trans_start(hdd_driver->dsc_driver, "unload"); |
| 13542 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13543 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13544 | pld_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13545 | |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13546 | param_destroy: |
| 13547 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13548 | wakelock_destroy: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13549 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13550 | comp_deinit: |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13551 | hdd_component_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13552 | hdd_deinit: |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13553 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13554 | trans_stop: |
| 13555 | hdd_driver->state = driver_state_deinit; |
| 13556 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
| 13557 | hdd_driver_deinit: |
| 13558 | hdd_driver_ctx_deinit(hdd_driver); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13559 | qdf_deinit: |
| 13560 | hdd_qdf_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13561 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13562 | exit: |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13563 | return errno; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13564 | } |
| 13565 | |
| 13566 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13567 | * hdd_driver_unload() - Performs the driver-level unload operation |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13568 | * |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13569 | * Note: this is used in both static and DLKM driver builds |
| 13570 | * |
| 13571 | * Return: None |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13572 | */ |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13573 | static void hdd_driver_unload(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13574 | { |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13575 | struct hdd_driver *hdd_driver = hdd_driver_get(); |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 13576 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13577 | QDF_STATUS status; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 13578 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13579 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 13580 | QWLAN_VERSIONSTR); |
| 13581 | |
Dustin Brown | 8c0b5e3 | 2019-01-18 13:56:02 -0800 | [diff] [blame] | 13582 | if (g_is_system_reboot_triggered) { |
| 13583 | hdd_info("System rebooting; Skipping unload"); |
| 13584 | return; |
| 13585 | } |
| 13586 | |
| 13587 | if (hdd_ctx) |
| 13588 | hdd_psoc_idle_timer_stop(hdd_ctx); |
| 13589 | |
| 13590 | /* trigger SoC remove */ |
| 13591 | wlan_hdd_unregister_driver(); |
| 13592 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13593 | status = dsc_driver_trans_start_wait(hdd_driver->dsc_driver, "unload"); |
| 13594 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13595 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13596 | hdd_err("Unable to unload wlan; status:%u", status); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 13597 | return; |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13598 | } |
| 13599 | |
| 13600 | dsc_driver_wait_for_ops(hdd_driver->dsc_driver); |
| 13601 | |
Will Huang | ba035ec | 2018-07-05 11:13:30 +0800 | [diff] [blame] | 13602 | cds_set_driver_loaded(false); |
| 13603 | cds_set_unload_in_progress(true); |
| 13604 | |
| 13605 | if (!cds_wait_for_external_threads_completion(__func__)) |
| 13606 | hdd_warn("External threads are still active attempting " |
| 13607 | "driver unload anyway"); |
| 13608 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13609 | pld_deinit(); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13610 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13611 | hdd_set_conparam(0); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13612 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13613 | hdd_component_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13614 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13615 | |
| 13616 | hdd_driver->state = driver_state_deinit; |
| 13617 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 13618 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13619 | hdd_driver_ctx_deinit(hdd_driver); |
| 13620 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13621 | hdd_qdf_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13622 | } |
| 13623 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13624 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13625 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13626 | * wlan_boot_cb() - Wlan boot callback |
| 13627 | * @kobj: object whose directory we're creating the link in. |
| 13628 | * @attr: attribute the user is interacting with |
| 13629 | * @buff: the buffer containing the user data |
| 13630 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13631 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13632 | * This callback is invoked when the fs is ready to start the |
| 13633 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13634 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13635 | * 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] | 13636 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13637 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13638 | struct kobj_attribute *attr, |
| 13639 | const char *buf, |
| 13640 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13641 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13642 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13643 | if (wlan_loader->loaded_state) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13644 | hdd_err("wlan driver already initialized"); |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13645 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13646 | } |
| 13647 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13648 | if (hdd_driver_load()) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13649 | return -EIO; |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13650 | |
| 13651 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13652 | |
| 13653 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13654 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13655 | |
| 13656 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13657 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 13658 | * |
| 13659 | * Return: None |
| 13660 | * |
| 13661 | */ |
| 13662 | static void hdd_sysfs_cleanup(void) |
| 13663 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13664 | /* remove from group */ |
| 13665 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 13666 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 13667 | wlan_loader->attr_group); |
| 13668 | |
| 13669 | /* unlink the object from parent */ |
| 13670 | kobject_del(wlan_loader->boot_wlan_obj); |
| 13671 | |
| 13672 | /* free the object */ |
| 13673 | kobject_put(wlan_loader->boot_wlan_obj); |
| 13674 | |
| 13675 | kfree(wlan_loader->attr_group); |
| 13676 | kfree(wlan_loader); |
| 13677 | |
| 13678 | wlan_loader = NULL; |
| 13679 | } |
| 13680 | |
| 13681 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13682 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 13683 | * ready |
| 13684 | * |
| 13685 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 13686 | * when the filesystem is ready. |
| 13687 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13688 | * QDF API cannot be used here since this function is called even before |
| 13689 | * initializing WLAN driver. |
| 13690 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13691 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13692 | */ |
| 13693 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13694 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13695 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13696 | |
| 13697 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13698 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13699 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13700 | |
| 13701 | wlan_loader->boot_wlan_obj = NULL; |
| 13702 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 13703 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13704 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13705 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13706 | |
| 13707 | wlan_loader->loaded_state = 0; |
| 13708 | wlan_loader->attr_group->attrs = attrs; |
| 13709 | |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 13710 | wlan_loader->boot_wlan_obj = kobject_create_and_add(WLAN_LOADER_NAME, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13711 | kernel_kobj); |
| 13712 | if (!wlan_loader->boot_wlan_obj) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13713 | hdd_err("sysfs create and add failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13714 | goto error_return; |
| 13715 | } |
| 13716 | |
| 13717 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 13718 | wlan_loader->attr_group); |
| 13719 | if (ret) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13720 | hdd_err("sysfs create group failed; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13721 | goto error_return; |
| 13722 | } |
| 13723 | |
| 13724 | return 0; |
| 13725 | |
| 13726 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13727 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13728 | |
| 13729 | return ret; |
| 13730 | } |
| 13731 | |
| 13732 | /** |
| 13733 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 13734 | * |
| 13735 | * Return: 0 on success or errno on failure |
| 13736 | */ |
| 13737 | static int wlan_deinit_sysfs(void) |
| 13738 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13739 | if (!wlan_loader) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13740 | hdd_err("wlan_loader is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13741 | return -EINVAL; |
| 13742 | } |
| 13743 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13744 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13745 | return 0; |
| 13746 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13747 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13748 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13749 | |
| 13750 | #ifdef MODULE |
| 13751 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13752 | * hdd_module_init() - Module init helper |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13753 | * |
| 13754 | * Module init helper function used by both module and static driver. |
| 13755 | * |
| 13756 | * Return: 0 for success, errno on failure |
| 13757 | */ |
| 13758 | static int hdd_module_init(void) |
| 13759 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13760 | if (hdd_driver_load()) |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13761 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13762 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13763 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13764 | } |
| 13765 | #else |
| 13766 | static int __init hdd_module_init(void) |
| 13767 | { |
| 13768 | int ret = -EINVAL; |
| 13769 | |
| 13770 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13771 | if (ret) |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13772 | hdd_err("Failed to create sysfs entry"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13773 | |
| 13774 | return ret; |
| 13775 | } |
| 13776 | #endif |
| 13777 | |
| 13778 | |
| 13779 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13780 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13781 | * hdd_module_exit() - Exit function |
| 13782 | * |
| 13783 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 13784 | * |
| 13785 | * Return: None |
| 13786 | */ |
| 13787 | static void __exit hdd_module_exit(void) |
| 13788 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13789 | hdd_driver_unload(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13790 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13791 | #else |
| 13792 | static void __exit hdd_module_exit(void) |
| 13793 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13794 | hdd_driver_unload(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13795 | wlan_deinit_sysfs(); |
| 13796 | } |
| 13797 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13798 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13799 | static int fwpath_changed_handler(const char *kmessage, |
| 13800 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13801 | { |
| 13802 | return param_set_copystring(kmessage, kp); |
| 13803 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13804 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13805 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
| 13806 | static bool is_monitor_mode_supported(void) |
| 13807 | { |
| 13808 | return true; |
| 13809 | } |
| 13810 | #else |
| 13811 | static bool is_monitor_mode_supported(void) |
| 13812 | { |
| 13813 | pr_err("Monitor mode not supported!"); |
| 13814 | return false; |
| 13815 | } |
| 13816 | #endif |
| 13817 | |
| 13818 | #ifdef WLAN_FEATURE_EPPING |
| 13819 | static bool is_epping_mode_supported(void) |
| 13820 | { |
| 13821 | return true; |
| 13822 | } |
| 13823 | #else |
| 13824 | static bool is_epping_mode_supported(void) |
| 13825 | { |
| 13826 | pr_err("Epping mode not supported!"); |
| 13827 | return false; |
| 13828 | } |
| 13829 | #endif |
| 13830 | |
Ryan Hsu | 6e9db0b | 2018-06-01 10:45:51 -0700 | [diff] [blame] | 13831 | #ifdef QCA_WIFI_FTM |
| 13832 | static bool is_ftm_mode_supported(void) |
| 13833 | { |
| 13834 | return true; |
| 13835 | } |
| 13836 | #else |
| 13837 | static bool is_ftm_mode_supported(void) |
| 13838 | { |
| 13839 | pr_err("FTM mode not supported!"); |
| 13840 | return false; |
| 13841 | } |
| 13842 | #endif |
| 13843 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13844 | /** |
| 13845 | * is_con_mode_valid() check con mode is valid or not |
| 13846 | * @mode: global con mode |
| 13847 | * |
| 13848 | * Return: TRUE on success FALSE on failure |
| 13849 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13850 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13851 | { |
| 13852 | switch (mode) { |
| 13853 | case QDF_GLOBAL_MONITOR_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13854 | return is_monitor_mode_supported(); |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13855 | case QDF_GLOBAL_EPPING_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13856 | return is_epping_mode_supported(); |
| 13857 | case QDF_GLOBAL_FTM_MODE: |
Ryan Hsu | 6e9db0b | 2018-06-01 10:45:51 -0700 | [diff] [blame] | 13858 | return is_ftm_mode_supported(); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13859 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13860 | return true; |
| 13861 | default: |
| 13862 | return false; |
| 13863 | } |
| 13864 | } |
| 13865 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13866 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13867 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13868 | { |
| 13869 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 13870 | return; |
| 13871 | |
| 13872 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13873 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 13874 | hdd_info("Release wakelock for monitor mode!"); |
| 13875 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 13876 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
Dundi Raviteja | 0a2a65b | 2018-04-30 12:34:11 +0530 | [diff] [blame] | 13877 | /* fallthrough */ |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 13878 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13879 | case QDF_GLOBAL_FTM_MODE: |
| 13880 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 13881 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 13882 | hdd_stop_all_adapters(hdd_ctx); |
Ashish Kumar Dhanotiya | 6ff329e | 2018-10-05 20:38:10 +0530 | [diff] [blame] | 13883 | hdd_deinit_all_adapters(hdd_ctx, false); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13884 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13885 | break; |
| 13886 | default: |
| 13887 | break; |
| 13888 | } |
| 13889 | } |
| 13890 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13891 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13892 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13893 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 13894 | int driver_status; |
| 13895 | |
| 13896 | driver_status = hdd_ctx->driver_status; |
| 13897 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13898 | switch (curr_mode) { |
| 13899 | case QDF_GLOBAL_MISSION_MODE: |
| 13900 | case QDF_GLOBAL_MONITOR_MODE: |
| 13901 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13902 | hdd_close_all_adapters(hdd_ctx, false); |
| 13903 | break; |
| 13904 | case QDF_GLOBAL_EPPING_MODE: |
| 13905 | epping_disable(); |
| 13906 | epping_close(); |
| 13907 | break; |
| 13908 | default: |
| 13909 | return; |
| 13910 | } |
| 13911 | } |
| 13912 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13913 | static int |
| 13914 | hdd_parse_driver_mode(const char *mode_str, enum QDF_GLOBAL_MODE *out_mode) |
| 13915 | { |
| 13916 | int mode; |
| 13917 | int errno; |
| 13918 | |
Dustin Brown | 62743f4 | 2018-10-24 14:53:18 -0700 | [diff] [blame] | 13919 | *out_mode = QDF_GLOBAL_MAX_MODE; |
| 13920 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13921 | errno = kstrtoint(mode_str, 0, &mode); |
| 13922 | if (!errno) |
| 13923 | *out_mode = (enum QDF_GLOBAL_MODE)mode; |
| 13924 | |
| 13925 | return errno; |
| 13926 | } |
| 13927 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13928 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13929 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13930 | * @kmessage: con mode name on which driver to be bring up |
| 13931 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13932 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13933 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13934 | * This function is invoked when user updates con mode using sys entry, |
| 13935 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13936 | * |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13937 | * Return: Errno |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13938 | */ |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13939 | static int __con_mode_handler(const char *kmessage, |
| 13940 | const struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13941 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13942 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13943 | enum QDF_GLOBAL_MODE curr_mode; |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13944 | enum QDF_GLOBAL_MODE next_mode; |
| 13945 | int errno; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13946 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13947 | hdd_info("Driver mode changing to %s", kmessage); |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 13948 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13949 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13950 | if (errno) |
| 13951 | return errno; |
| 13952 | |
| 13953 | errno = hdd_parse_driver_mode(kmessage, &next_mode); |
| 13954 | if (errno) { |
| 13955 | hdd_err_rl("Failed to parse driver mode '%s'", kmessage); |
| 13956 | return errno; |
| 13957 | } |
| 13958 | |
| 13959 | if (!is_con_mode_valid(next_mode)) { |
| 13960 | hdd_err_rl("Requested driver mode is invalid"); |
| 13961 | return -EINVAL; |
| 13962 | } |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13963 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13964 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13965 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13966 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13967 | curr_mode = hdd_get_conparam(); |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13968 | if (curr_mode == next_mode) { |
| 13969 | hdd_err_rl("Driver is already in the requested mode"); |
| 13970 | errno = 0; |
| 13971 | goto unlock; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13972 | } |
| 13973 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13974 | /* ensure adapters are stopped */ |
| 13975 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 13976 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13977 | errno = hdd_wlan_stop_modules(hdd_ctx, true); |
| 13978 | if (errno) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13979 | hdd_err("Stop wlan modules failed"); |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13980 | goto unlock; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13981 | } |
| 13982 | |
Dustin Brown | dd4e50f | 2018-05-24 15:43:42 -0700 | [diff] [blame] | 13983 | /* Cleanup present mode before switching to new mode */ |
| 13984 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 13985 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13986 | hdd_set_conparam(next_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13987 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13988 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 13989 | if (errno) { |
| 13990 | hdd_err("Start wlan modules failed: %d", errno); |
| 13991 | goto unlock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13992 | } |
| 13993 | |
jitiphil | 7af5cf2 | 2018-10-26 16:06:27 +0530 | [diff] [blame] | 13994 | errno = hdd_open_adapters_for_mode(hdd_ctx, next_mode); |
| 13995 | if (errno) { |
| 13996 | hdd_err("Failed to open adapters"); |
| 13997 | goto unlock; |
| 13998 | } |
| 13999 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 14000 | if (next_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 14001 | struct hdd_adapter *adapter = |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 14002 | hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 14003 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 14004 | QDF_BUG(adapter); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 14005 | if (!adapter) { |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 14006 | hdd_err("Failed to get monitor adapter"); |
| 14007 | goto unlock; |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 14008 | } |
| 14009 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 14010 | errno = hdd_start_adapter(adapter); |
| 14011 | if (errno) { |
| 14012 | hdd_err("Failed to start monitor adapter"); |
| 14013 | goto unlock; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 14014 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14015 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 14016 | hdd_info("Acquire wakelock for monitor mode"); |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 14017 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 14018 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 14019 | } |
| 14020 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 14021 | /* con_mode is a global module parameter */ |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 14022 | con_mode = next_mode; |
| 14023 | hdd_info("Driver mode successfully changed to %s", kmessage); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 14024 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 14025 | errno = 0; |
| 14026 | |
| 14027 | unlock: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 14028 | mutex_unlock(&hdd_init_deinit_lock); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 14029 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 14030 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 14031 | return errno; |
| 14032 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 14033 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14034 | static int con_mode_handler(const char *kmessage, const struct kernel_param *kp) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 14035 | { |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 14036 | struct hdd_driver *hdd_driver = hdd_driver_get(); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14037 | struct hdd_context *hdd_ctx; |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 14038 | QDF_STATUS status; |
| 14039 | int errno; |
| 14040 | |
| 14041 | hdd_enter(); |
| 14042 | |
Dustin Brown | 13fa987 | 2018-11-13 10:57:45 -0800 | [diff] [blame] | 14043 | /* This handler will be invoked before module init when the wlan driver |
| 14044 | * is loaded using 'insmod wlan.ko con_mode=5' for example. Return |
| 14045 | * success in this case, as module init will bring up the correct |
| 14046 | * con_mode when it runs. |
| 14047 | */ |
| 14048 | if (hdd_driver->state == driver_state_uninit) |
| 14049 | return 0; |
| 14050 | |
Rajeev Kumar | acb73d0 | 2018-12-18 14:07:40 -0800 | [diff] [blame] | 14051 | if (hdd_driver->state == driver_state_deinit) { |
| 14052 | hdd_err_rl("driver is unloaded so load again"); |
| 14053 | return -EAGAIN; |
| 14054 | } |
| 14055 | |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 14056 | status = dsc_driver_trans_start_wait(hdd_driver->dsc_driver, |
| 14057 | "mode change"); |
| 14058 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14059 | hdd_err("Failed to start 'mode change'; status:%u", status); |
| 14060 | errno = qdf_status_to_os_return(status); |
| 14061 | goto exit; |
| 14062 | } |
| 14063 | |
| 14064 | dsc_driver_wait_for_ops(hdd_driver->dsc_driver); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 14065 | |
| 14066 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 14067 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 14068 | if (errno) |
| 14069 | goto trans_stop; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 14070 | |
Ashish Kumar Dhanotiya | 759b327 | 2018-05-18 17:49:46 +0530 | [diff] [blame] | 14071 | if (!cds_wait_for_external_threads_completion(__func__)) { |
| 14072 | hdd_warn("External threads are still active, can not change mode"); |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 14073 | errno = -EAGAIN; |
| 14074 | goto trans_stop; |
Ashish Kumar Dhanotiya | 759b327 | 2018-05-18 17:49:46 +0530 | [diff] [blame] | 14075 | } |
| 14076 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 14077 | cds_ssr_protect(__func__); |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 14078 | errno = __con_mode_handler(kmessage, kp, hdd_ctx); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 14079 | cds_ssr_unprotect(__func__); |
| 14080 | |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 14081 | trans_stop: |
| 14082 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
| 14083 | |
| 14084 | exit: |
| 14085 | hdd_exit(); |
| 14086 | |
| 14087 | return errno; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14088 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14089 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14090 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14091 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14092 | { |
| 14093 | int ret; |
| 14094 | |
| 14095 | ret = param_set_int(kmessage, kp); |
| 14096 | |
| 14097 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 14098 | pr_err("Only FTM mode supported!"); |
| 14099 | return -ENOTSUPP; |
| 14100 | } |
| 14101 | |
| 14102 | hdd_set_conparam(con_mode_ftm); |
| 14103 | con_mode = con_mode_ftm; |
| 14104 | |
| 14105 | return ret; |
| 14106 | } |
| 14107 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14108 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14109 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14110 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14111 | { |
| 14112 | int ret; |
| 14113 | |
| 14114 | ret = param_set_int(kmessage, kp); |
| 14115 | |
| 14116 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 14117 | pr_err("Only Monitor mode supported!"); |
| 14118 | return -ENOTSUPP; |
| 14119 | } |
| 14120 | |
| 14121 | hdd_set_conparam(con_mode_monitor); |
| 14122 | con_mode = con_mode_monitor; |
| 14123 | |
| 14124 | return ret; |
| 14125 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14126 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14127 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14128 | /** |
| 14129 | * hdd_get_conparam() - driver exit point |
| 14130 | * |
| 14131 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 14132 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14133 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14134 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14135 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14136 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14137 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14138 | } |
| 14139 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14140 | void hdd_set_conparam(int32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14141 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 14142 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14143 | } |
| 14144 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14145 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14146 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 14147 | * @hdd_ctx: HDD context |
| 14148 | * |
| 14149 | * Cleans up the pre cac interface, if it exists |
| 14150 | * |
| 14151 | * Return: None |
| 14152 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14153 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14154 | { |
| 14155 | uint8_t session_id; |
| 14156 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 14157 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14158 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14159 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->mac_handle, &session_id); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14160 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14161 | hdd_err("failed to get pre cac vdev id"); |
| 14162 | return; |
| 14163 | } |
| 14164 | |
| 14165 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 14166 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 14167 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14168 | return; |
| 14169 | } |
| 14170 | |
| 14171 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 14172 | wlan_hdd_sap_pre_cac_failure, |
| 14173 | (void *)precac_adapter); |
| 14174 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 14175 | |
| 14176 | } |
| 14177 | |
| 14178 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14179 | * hdd_update_ol_config - API to update ol configuration parameters |
| 14180 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14181 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14182 | * Return: void |
| 14183 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14184 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14185 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14186 | struct ol_config_info cfg = {0}; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14187 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14188 | bool self_recovery = false; |
| 14189 | QDF_STATUS status; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14190 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14191 | if (!ol_ctx) |
| 14192 | return; |
| 14193 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14194 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14195 | if (QDF_IS_STATUS_ERROR(status)) |
| 14196 | hdd_err("Failed to get self recovery ini config"); |
| 14197 | |
| 14198 | cfg.enable_self_recovery = self_recovery; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14199 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 14200 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 14201 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 14202 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14203 | |
| 14204 | ol_init_ini_config(ol_ctx, &cfg); |
| 14205 | } |
| 14206 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14207 | #ifdef FEATURE_RUNTIME_PM |
| 14208 | /** |
| 14209 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 14210 | * @hdd_ctx: hdd context |
| 14211 | * @cfg: pointer to the configuration memory being populated |
| 14212 | * |
| 14213 | * Return: void |
| 14214 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14215 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14216 | struct hif_config_info *cfg) |
| 14217 | { |
| 14218 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14219 | cfg->runtime_pm_delay = |
| 14220 | ucfg_pmo_get_runtime_pm_delay(hdd_ctx->psoc); |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14221 | } |
| 14222 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14223 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14224 | struct hif_config_info *cfg) |
| 14225 | { |
| 14226 | } |
| 14227 | #endif |
| 14228 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14229 | /** |
| 14230 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 14231 | * @hdd_ctx: HDD Context |
| 14232 | * |
| 14233 | * Return: void |
| 14234 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14235 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14236 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14237 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14238 | struct hif_config_info cfg = {0}; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14239 | bool prevent_link_down = false; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14240 | bool self_recovery = false; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14241 | QDF_STATUS status; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14242 | |
| 14243 | if (!scn) |
| 14244 | return; |
| 14245 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14246 | status = ucfg_mlme_get_prevent_link_down(hdd_ctx->psoc, |
| 14247 | &prevent_link_down); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14248 | if (QDF_IS_STATUS_ERROR(status)) |
| 14249 | hdd_err("Failed to get prevent_link_down config"); |
| 14250 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14251 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14252 | if (QDF_IS_STATUS_ERROR(status)) |
| 14253 | hdd_err("Failed to get self recovery ini config"); |
| 14254 | |
| 14255 | cfg.enable_self_recovery = self_recovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14256 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14257 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14258 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14259 | if (prevent_link_down) |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14260 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14261 | } |
| 14262 | |
| 14263 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14264 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 14265 | * datapath |
| 14266 | * @hdd_ctx: HDD Context |
| 14267 | * |
| 14268 | * Return: 0 for success/errno for failure |
| 14269 | */ |
| 14270 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 14271 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14272 | struct cdp_config_params params = {0}; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14273 | QDF_STATUS status; |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14274 | void *soc; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14275 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14276 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 14277 | params.tso_enable = cfg_get(hdd_ctx->psoc, CFG_DP_TSO); |
| 14278 | 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] | 14279 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 14280 | params.tx_flow_stop_queue_threshold = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 14281 | 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] | 14282 | params.tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 14283 | cfg_get(hdd_ctx->psoc, |
| 14284 | CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14285 | #endif |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14286 | params.flow_steering_enable = |
| 14287 | cfg_get(hdd_ctx->psoc, CFG_DP_FLOW_STEERING_ENABLED); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14288 | params.napi_enable = hdd_ctx->napi_enable; |
| 14289 | params.tcp_udp_checksumoffload = |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14290 | cfg_get(hdd_ctx->psoc, |
| 14291 | CFG_DP_TCP_UDP_CKSUM_OFFLOAD); |
Sravan Kumar Kairam | 0af1ee5 | 2018-12-12 20:37:51 +0530 | [diff] [blame] | 14292 | params.ipa_enable = ucfg_ipa_is_enabled(); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 14293 | 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] | 14294 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14295 | status = cdp_update_config_parameters(soc, ¶ms); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14296 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 14297 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14298 | return status; |
| 14299 | } |
| 14300 | |
| 14301 | return 0; |
| 14302 | } |
| 14303 | |
| 14304 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14305 | * hdd_update_config() - Initialize driver per module ini parameters |
| 14306 | * @hdd_ctx: HDD Context |
| 14307 | * |
| 14308 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14309 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14310 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14311 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14312 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14313 | int ret; |
| 14314 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14315 | if (ucfg_pmo_is_ns_offloaded(hdd_ctx->psoc)) |
| 14316 | hdd_ctx->ns_offload_enable = true; |
| 14317 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14318 | hdd_update_ol_config(hdd_ctx); |
| 14319 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14320 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 14321 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 14322 | else |
| 14323 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 14324 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14325 | |
| 14326 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14327 | } |
| 14328 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14329 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 14330 | /** |
| 14331 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 14332 | * @psoc_cfg: pmo psoc Configuration |
| 14333 | * @hdd_ctx: Pointer to hdd context |
| 14334 | * |
| 14335 | * Return: none |
| 14336 | */ |
| 14337 | static inline void hdd_ra_populate_pmo_config( |
| 14338 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14339 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14340 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 14341 | bool is_rate_limit_enabled; |
| 14342 | QDF_STATUS status; |
| 14343 | |
| 14344 | status = ucfg_fwol_get_is_rate_limit_enabled(hdd_ctx->psoc, |
| 14345 | &is_rate_limit_enabled); |
| 14346 | if (QDF_IS_STATUS_ERROR(status)) |
| 14347 | return; |
| 14348 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14349 | psoc_cfg->ra_ratelimit_enable = |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 14350 | is_rate_limit_enabled; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14351 | } |
| 14352 | #else |
| 14353 | static inline void hdd_ra_populate_pmo_config( |
| 14354 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14355 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14356 | { |
| 14357 | } |
| 14358 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 14359 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14360 | /** |
| 14361 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 14362 | * @hdd_ctx: HDD context |
| 14363 | * |
| 14364 | * Return: void |
| 14365 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14366 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14367 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14368 | struct pmo_psoc_cfg psoc_cfg = {0}; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14369 | QDF_STATUS status; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14370 | enum pmo_wow_enable_type wow_enable; |
| 14371 | |
| 14372 | ucfg_pmo_get_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14373 | |
| 14374 | /* |
| 14375 | * Value of hdd_ctx->wowEnable can be, |
| 14376 | * 0 - Disable both magic pattern match and pattern byte match. |
| 14377 | * 1 - Enable magic pattern match on all interfaces. |
| 14378 | * 2 - Enable pattern byte match on all interfaces. |
| 14379 | * 3 - Enable both magic patter and pattern byte match on |
| 14380 | * all interfaces. |
| 14381 | */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14382 | wow_enable = ucfg_pmo_get_wow_enable(hdd_ctx->psoc); |
| 14383 | psoc_cfg.magic_ptrn_enable = (wow_enable & 0x01) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14384 | psoc_cfg.ptrn_match_enable_all_vdev = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14385 | (wow_enable & 0x02) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14386 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 14387 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 14388 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 14389 | &psoc_cfg.sta_max_li_mod_dtim); |
| 14390 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14391 | |
| 14392 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 14393 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14394 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14395 | status = ucfg_pmo_update_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 14396 | if (QDF_IS_STATUS_ERROR(status)) |
| 14397 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 14398 | |
| 14399 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14400 | } |
| 14401 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14402 | 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] | 14403 | struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14404 | { |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14405 | struct wlan_fwol_ie_whitelist whitelist = {0}; |
| 14406 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14407 | QDF_STATUS status; |
| 14408 | bool is_ie_whitelist_enable = false; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14409 | uint8_t i = 0; |
| 14410 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14411 | status = ucfg_fwol_get_ie_whitelist(psoc, &is_ie_whitelist_enable); |
| 14412 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14413 | hdd_err("Unable to get IE whitelist param"); |
| 14414 | return; |
| 14415 | } |
| 14416 | |
| 14417 | ie_whitelist->white_list = is_ie_whitelist_enable; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14418 | if (!ie_whitelist->white_list) |
| 14419 | return; |
| 14420 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14421 | status = ucfg_fwol_get_all_whitelist_params(psoc, &whitelist); |
| 14422 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14423 | hdd_err("Unable to get all whitelist params"); |
| 14424 | return; |
| 14425 | } |
| 14426 | |
| 14427 | ie_whitelist->ie_bitmap[0] = whitelist.ie_bitmap_0; |
| 14428 | ie_whitelist->ie_bitmap[1] = whitelist.ie_bitmap_1; |
| 14429 | ie_whitelist->ie_bitmap[2] = whitelist.ie_bitmap_2; |
| 14430 | ie_whitelist->ie_bitmap[3] = whitelist.ie_bitmap_3; |
| 14431 | ie_whitelist->ie_bitmap[4] = whitelist.ie_bitmap_4; |
| 14432 | ie_whitelist->ie_bitmap[5] = whitelist.ie_bitmap_5; |
| 14433 | ie_whitelist->ie_bitmap[6] = whitelist.ie_bitmap_6; |
| 14434 | ie_whitelist->ie_bitmap[7] = whitelist.ie_bitmap_7; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14435 | |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14436 | ie_whitelist->num_vendor_oui = whitelist.no_of_probe_req_ouis; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14437 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14438 | ie_whitelist->voui[i] = whitelist.probe_req_voui[i]; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14439 | } |
| 14440 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14441 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 14442 | { |
| 14443 | uint8_t i, score; |
| 14444 | |
| 14445 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 14446 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 14447 | if (score > MAX_INDEX_SCORE) |
| 14448 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 14449 | MAX_INDEX_SCORE, i); |
| 14450 | } |
| 14451 | |
| 14452 | return per_index_score; |
| 14453 | } |
| 14454 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14455 | QDF_STATUS hdd_update_score_config( |
| 14456 | struct scoring_config *score_config, struct hdd_context *hdd_ctx) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14457 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14458 | struct hdd_config *cfg = hdd_ctx->config; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14459 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14460 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14461 | bool bval = false; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 14462 | uint32_t channel_bonding_mode; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14463 | |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14464 | qdf_mem_zero(&vdev_ini_cfg, sizeof(struct wlan_mlme_nss_chains)); |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14465 | /* Populate the nss chain params from ini for this vdev type */ |
| 14466 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 14467 | QDF_STA_MODE, |
| 14468 | hdd_ctx->num_rf_chains); |
| 14469 | |
| 14470 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]; |
| 14471 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]; |
| 14472 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14473 | sme_update_score_config(hdd_ctx->mac_handle, score_config); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14474 | |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 14475 | ucfg_mlme_get_channel_bonding_24ghz(hdd_ctx->psoc, |
| 14476 | &channel_bonding_mode); |
| 14477 | score_config->cb_mode_24G = channel_bonding_mode; |
| 14478 | ucfg_mlme_get_channel_bonding_5ghz(hdd_ctx->psoc, |
| 14479 | &channel_bonding_mode); |
| 14480 | score_config->cb_mode_5G = channel_bonding_mode; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14481 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14482 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 14483 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 14484 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 14485 | score_config->he_cap = 1; |
| 14486 | |
| 14487 | if (score_config->he_cap || |
| 14488 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 14489 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 14490 | score_config->vht_cap = 1; |
| 14491 | |
| 14492 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 14493 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 14494 | score_config->ht_cap = 1; |
| 14495 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14496 | status = ucfg_mlme_get_vht_for_24ghz(hdd_ctx->psoc, &bval); |
| 14497 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14498 | hdd_err("Failed to get vht_for_24ghz"); |
| 14499 | if (score_config->vht_cap && bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14500 | score_config->vht_24G_cap = 1; |
| 14501 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14502 | status = ucfg_mlme_get_vht_enable_tx_bf(hdd_ctx->psoc, |
| 14503 | &bval); |
| 14504 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14505 | hdd_err("unable to get vht_enable_tx_bf"); |
| 14506 | |
| 14507 | if (bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14508 | score_config->beamformee_cap = 1; |
| 14509 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14510 | return QDF_STATUS_SUCCESS; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14511 | } |
| 14512 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14513 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14514 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 14515 | * @hdd_ctx: HDD context |
| 14516 | * |
| 14517 | * Return: 0 if success else err |
| 14518 | */ |
| 14519 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 14520 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14521 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14522 | struct dfs_user_config dfs_cfg = {0}; |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14523 | QDF_STATUS status; |
| 14524 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 14525 | ucfg_mlme_get_dfs_filter_offload(hdd_ctx->psoc, |
| 14526 | &dfs_cfg.dfs_is_phyerr_filter_offload); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14527 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 14528 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14529 | hdd_err("failed dfs psoc configuration"); |
| 14530 | return -EINVAL; |
| 14531 | } |
| 14532 | |
| 14533 | return 0; |
| 14534 | } |
| 14535 | |
| 14536 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14537 | * hdd_update_scan_config - API to update scan configuration parameters |
| 14538 | * @hdd_ctx: HDD context |
| 14539 | * |
| 14540 | * Return: 0 if success else err |
| 14541 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14542 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14543 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14544 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14545 | struct scan_user_cfg scan_cfg = {0}; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14546 | struct hdd_config *cfg = hdd_ctx->config; |
| 14547 | QDF_STATUS status; |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14548 | uint32_t mcast_mcc_rest_time = 0; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14549 | |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 14550 | /* convert to ms */ |
| 14551 | scan_cfg.scan_cache_aging_time = |
| 14552 | cfg->scanAgingTimeout * 1000; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 14553 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 14554 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14555 | status = ucfg_mlme_get_sta_miracast_mcc_rest_time(hdd_ctx->psoc, |
| 14556 | &mcast_mcc_rest_time); |
| 14557 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14558 | hdd_err("ucfg_mlme_get_sta_miracast_mcc_rest_time, use def"); |
| 14559 | return -EIO; |
| 14560 | } |
| 14561 | scan_cfg.sta_miracast_mcc_rest_time = mcast_mcc_rest_time; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14562 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14563 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14564 | status = hdd_update_score_config(&scan_cfg.score_config, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14565 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14566 | hdd_err("Failed to update scoring config"); |
| 14567 | return -EINVAL; |
| 14568 | } |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14569 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14570 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 14571 | if (status != QDF_STATUS_SUCCESS) { |
| 14572 | hdd_err("failed pmo psoc configuration"); |
| 14573 | return -EINVAL; |
| 14574 | } |
| 14575 | |
| 14576 | return 0; |
| 14577 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14578 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14579 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14580 | { |
| 14581 | int ret; |
| 14582 | |
| 14583 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14584 | if (ret) |
| 14585 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14586 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14587 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14588 | if (ret) |
| 14589 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14590 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14591 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14592 | if (ret) |
| 14593 | return ret; |
| 14594 | |
| 14595 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14596 | if (ret) |
| 14597 | return ret; |
| 14598 | |
| 14599 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14600 | |
| 14601 | return ret; |
| 14602 | } |
| 14603 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14604 | /** |
| 14605 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 14606 | * @mode : cfg80211 DFS mode |
| 14607 | * |
| 14608 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 14609 | */ |
| 14610 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 14611 | { |
| 14612 | switch (mode) { |
| 14613 | case DFS_MODE_ENABLE: |
| 14614 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14615 | case DFS_MODE_DISABLE: |
| 14616 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14617 | case DFS_MODE_DEPRIORITIZE: |
| 14618 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14619 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14620 | hdd_debug("ACS dfs mode is NONE"); |
| 14621 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14622 | } |
| 14623 | } |
| 14624 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14625 | /** |
| 14626 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 14627 | * @hddctx: pointer to hdd context |
| 14628 | * @set_value: enable/disable |
| 14629 | * |
| 14630 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 14631 | * Host(even though it is duplicate). When Host send vendor command |
| 14632 | * disable,FW doesn't perform any action. Whenever any change in |
| 14633 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 14634 | * |
| 14635 | * return - 0 on success, appropriate error values on failure. |
| 14636 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14637 | 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] | 14638 | { |
| 14639 | QDF_STATUS status; |
| 14640 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14641 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14642 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14643 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14644 | status = sme_enable_disable_chanavoidind_event(hdd_ctx->mac_handle, |
| 14645 | set_value); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14646 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14647 | hdd_err("Failed to send chan avoid command to SME"); |
| 14648 | return -EINVAL; |
| 14649 | } |
| 14650 | return 0; |
| 14651 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14652 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14653 | /** |
| 14654 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 14655 | * @value: value to set |
| 14656 | * |
| 14657 | * This function will set the passed value to roaming in progress flag. |
| 14658 | * |
| 14659 | * Return: None |
| 14660 | */ |
| 14661 | void hdd_set_roaming_in_progress(bool value) |
| 14662 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14663 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14664 | |
| 14665 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14666 | if (!hdd_ctx) { |
| 14667 | hdd_err("HDD context is NULL"); |
| 14668 | return; |
| 14669 | } |
| 14670 | |
| 14671 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14672 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14673 | } |
| 14674 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14675 | bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14676 | { |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14677 | if (!hdd_ctx) { |
| 14678 | hdd_err("HDD context is NULL"); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14679 | return false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14680 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 14681 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14682 | hdd_debug("roaming_in_progress = %d", hdd_ctx->roaming_in_progress); |
| 14683 | |
| 14684 | return hdd_ctx->roaming_in_progress; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14685 | } |
| 14686 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14687 | /** |
| 14688 | * hdd_is_connection_in_progress() - check if connection is in |
| 14689 | * progress |
| 14690 | * @session_id: session id |
| 14691 | * @reason: scan reject reason |
| 14692 | * |
| 14693 | * Go through each adapter and check if Connection is in progress |
| 14694 | * |
| 14695 | * Return: true if connection is in progress else false |
| 14696 | */ |
| 14697 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 14698 | enum scan_reject_states *reason) |
| 14699 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 14700 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14701 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14702 | uint8_t sta_id = 0; |
| 14703 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14704 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14705 | mac_handle_t mac_handle; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14706 | |
| 14707 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14708 | if (!hdd_ctx) { |
| 14709 | hdd_err("HDD context is NULL"); |
| 14710 | return false; |
| 14711 | } |
| 14712 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14713 | mac_handle = hdd_ctx->mac_handle; |
| 14714 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14715 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 929afa4 | 2018-06-01 15:04:44 -0700 | [diff] [blame] | 14716 | hdd_debug("Adapter with device mode %s(%d) exists", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 14717 | qdf_opmode_str(adapter->device_mode), |
| 14718 | adapter->device_mode); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14719 | if (((QDF_STA_MODE == adapter->device_mode) |
| 14720 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 14721 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 14722 | && (eConnectionState_Connecting == |
| 14723 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 14724 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14725 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14726 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14727 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14728 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14729 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14730 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14731 | } |
| 14732 | return true; |
| 14733 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 14734 | /* |
| 14735 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 14736 | * hdd_is_roaming_in_progress is for LFR3 |
| 14737 | */ |
| 14738 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 14739 | sme_neighbor_middle_of_roaming( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14740 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14741 | adapter->session_id)) || |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14742 | hdd_is_roaming_in_progress(hdd_ctx)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14743 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14744 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14745 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14746 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14747 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14748 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14749 | } |
| 14750 | return true; |
| 14751 | } |
| 14752 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 14753 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 14754 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 14755 | hdd_sta_ctx = |
| 14756 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 14757 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 14758 | hdd_sta_ctx->conn_info.connState) |
| 14759 | && sme_is_sta_key_exchange_in_progress( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14760 | mac_handle, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14761 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 14762 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14763 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14764 | " is in middle of WPS/EAPOL exchange.", |
| 14765 | MAC_ADDR_ARRAY(sta_mac)); |
| 14766 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14767 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14768 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14769 | } |
| 14770 | return true; |
| 14771 | } |
| 14772 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 14773 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 14774 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 14775 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14776 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14777 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14778 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14779 | continue; |
| 14780 | |
| 14781 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14782 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 14783 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14784 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14785 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 14786 | MAC_ADDR_ARRAY(sta_mac)); |
| 14787 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14788 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14789 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14790 | } |
| 14791 | return true; |
| 14792 | } |
| 14793 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14794 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14795 | return true; |
| 14796 | } |
| 14797 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14798 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14799 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14800 | return false; |
| 14801 | } |
| 14802 | |
| 14803 | /** |
| 14804 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14805 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14806 | * |
| 14807 | * Return: None |
| 14808 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14809 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14810 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 14811 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 14812 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14813 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14814 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 14815 | tsap_config_t *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14816 | void *sap_ctx; |
| 14817 | |
| 14818 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 14819 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 14820 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14821 | |
| 14822 | mutex_lock(&hdd_ctx->sap_lock); |
| 14823 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 14824 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14825 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 14826 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 14827 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 14828 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14829 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14830 | qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 14831 | SME_CMD_STOP_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14832 | |
| 14833 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14834 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14835 | goto end; |
| 14836 | } |
| 14837 | } |
| 14838 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14839 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14840 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14841 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14842 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14843 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14844 | |
| 14845 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14846 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14847 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14848 | eUPDATE_IE_ALL); |
| 14849 | goto end; |
| 14850 | } |
| 14851 | |
| 14852 | qdf_event_reset(&hostapd_state->qdf_event); |
| 14853 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 14854 | sap_config, |
| 14855 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14856 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14857 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14858 | eUPDATE_IE_ALL); |
| 14859 | goto end; |
| 14860 | } |
| 14861 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14862 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14863 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14864 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 14865 | SME_CMD_START_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14866 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14867 | eUPDATE_IE_ALL); |
| 14868 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14869 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14870 | goto end; |
| 14871 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14872 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14873 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14874 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14875 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14876 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14877 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14878 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14879 | ap_adapter->device_mode, |
| 14880 | true); |
| 14881 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14882 | } |
| 14883 | end: |
| 14884 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14885 | } |
| 14886 | |
| 14887 | /** |
| 14888 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 14889 | * with non dfs acs |
| 14890 | * |
| 14891 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 14892 | * |
| 14893 | * Return: None |
| 14894 | */ |
| 14895 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 14896 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14897 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14898 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 14899 | struct cds_context *cds_ctx; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14900 | uint8_t restart_chan; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14901 | |
| 14902 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14903 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14904 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14905 | return; |
| 14906 | } |
| 14907 | |
| 14908 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 14909 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14910 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14911 | return; |
| 14912 | } |
| 14913 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14914 | if (policy_mgr_get_concurrency_mode(hdd_ctx->psoc) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14915 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 14916 | hdd_debug("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14917 | return; |
| 14918 | } |
| 14919 | |
| 14920 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14921 | if (ap_adapter && |
| 14922 | test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags) && |
| 14923 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, |
| 14924 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14925 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14926 | 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] | 14927 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14928 | restart_chan = |
| 14929 | hdd_get_safe_channel_from_pcl_and_acs_range(ap_adapter); |
| 14930 | if (!restart_chan || |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14931 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, restart_chan)) |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14932 | restart_chan = SAP_DEFAULT_5GHZ_CHANNEL; |
| 14933 | |
| 14934 | hdd_switch_sap_channel(ap_adapter, restart_chan, true); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14935 | } |
| 14936 | } |
| 14937 | |
| 14938 | /** |
| 14939 | * hdd_set_connection_in_progress() - to set the connection in |
| 14940 | * progress flag |
| 14941 | * @value: value to set |
| 14942 | * |
| 14943 | * This function will set the passed value to connection in progress flag. |
| 14944 | * If value is previously being set to true then no need to set it again. |
| 14945 | * |
| 14946 | * Return: true if value is being set correctly and false otherwise. |
| 14947 | */ |
| 14948 | bool hdd_set_connection_in_progress(bool value) |
| 14949 | { |
| 14950 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14951 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14952 | |
| 14953 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14954 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14955 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14956 | return false; |
| 14957 | } |
| 14958 | |
| 14959 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 14960 | /* |
| 14961 | * if the value is set to true previously and if someone is |
| 14962 | * trying to make it true again then it could be some race |
| 14963 | * condition being triggered. Avoid this situation by returning |
| 14964 | * false |
| 14965 | */ |
| 14966 | if (hdd_ctx->connection_in_progress && value) |
| 14967 | status = false; |
| 14968 | else |
| 14969 | hdd_ctx->connection_in_progress = value; |
| 14970 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 14971 | return status; |
| 14972 | } |
| 14973 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14974 | 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] | 14975 | { |
| 14976 | if (!adapter) { |
| 14977 | hdd_err("Invalid adapter"); |
| 14978 | return -EINVAL; |
| 14979 | } |
| 14980 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14981 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14982 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 14983 | set_value, VDEV_CMD); |
| 14984 | return 0; |
| 14985 | |
| 14986 | } |
| 14987 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14988 | 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] | 14989 | { |
| 14990 | if (!adapter) { |
| 14991 | hdd_err("Invalid adapter"); |
| 14992 | return -EINVAL; |
| 14993 | } |
| 14994 | |
| 14995 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14996 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14997 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 14998 | set_value, VDEV_CMD); |
| 14999 | return 0; |
| 15000 | } |
| 15001 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 15002 | 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] | 15003 | *psoc, uint8_t vdev_id) |
| 15004 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 15005 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 15006 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 15007 | |
| 15008 | /* |
| 15009 | * Currently PSOC is not being used. But this logic will |
| 15010 | * change once we have the converged implementation of |
| 15011 | * HDD context per PSOC in place. This would break if |
| 15012 | * multiple vdev objects reuse the vdev id. |
| 15013 | */ |
| 15014 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 15015 | if (!adapter) |
| 15016 | hdd_err("Get adapter by vdev id failed"); |
| 15017 | |
| 15018 | return adapter; |
| 15019 | } |
| 15020 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 15021 | 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] | 15022 | int8_t *rssi, int8_t *snr) |
| 15023 | { |
| 15024 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 15025 | mac_handle_t mac_handle; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 15026 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 15027 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 15028 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 15029 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 15030 | status = sme_get_rssi_snr_by_bssid(mac_handle, |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 15031 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 15032 | if (QDF_STATUS_SUCCESS != status) { |
| 15033 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 15034 | return -EINVAL; |
| 15035 | } |
| 15036 | |
| 15037 | return 0; |
| 15038 | } |
| 15039 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 15040 | /** |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15041 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 15042 | * @adapter - HDD adapter |
| 15043 | * |
| 15044 | * Return: 0 on success and non zero value on failure |
| 15045 | */ |
| 15046 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 15047 | { |
| 15048 | struct hdd_context *hdd_ctx; |
| 15049 | int ret; |
| 15050 | QDF_STATUS status; |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 15051 | uint8_t sys_pref = 0; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15052 | |
| 15053 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 15054 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 15055 | if (ret < 0) |
| 15056 | return ret; |
| 15057 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 15058 | ucfg_policy_mgr_get_sys_pref(hdd_ctx->psoc, |
| 15059 | &sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15060 | /* set the system preferece to default */ |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 15061 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->psoc, sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15062 | |
| 15063 | /* clear the bitmap */ |
| 15064 | adapter->active_ac = 0; |
| 15065 | |
| 15066 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 15067 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15068 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 15069 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
| 15070 | adapter->session_id, |
| 15071 | false, 0, 0, false); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15072 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 15073 | hdd_err("failed to reset limit off chan params"); |
| 15074 | ret = -EINVAL; |
| 15075 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 15076 | |
| 15077 | return ret; |
| 15078 | } |
| 15079 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15080 | /** |
| 15081 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 15082 | * @drv_op: Enum indicating driver op |
| 15083 | * |
| 15084 | * Return: none |
| 15085 | */ |
| 15086 | void hdd_start_driver_ops_timer(int drv_op) |
| 15087 | { |
| 15088 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 15089 | switch (drv_op) { |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 15090 | case HDD_DRV_OP_PROBE: |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15091 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 15092 | break; |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 15093 | case HDD_DRV_OP_REMOVE: |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15094 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 15095 | break; |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 15096 | case HDD_DRV_OP_SHUTDOWN: |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15097 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 15098 | break; |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 15099 | case HDD_DRV_OP_REINIT: |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15100 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 15101 | break; |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 15102 | case HDD_DRV_OP_IFF_UP: |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 15103 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 15104 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15105 | } |
| 15106 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 15107 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15108 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
Dustin Brown | cfc54fe | 2018-06-18 16:17:41 -0700 | [diff] [blame] | 15109 | HDD_OPS_INACTIVITY_TIMEOUT * qdf_timer_get_multiplier()); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15110 | } |
| 15111 | |
| 15112 | /** |
| 15113 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 15114 | * |
| 15115 | * Return: none |
| 15116 | */ |
| 15117 | void hdd_stop_driver_ops_timer(void) |
| 15118 | { |
| 15119 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 15120 | } |
| 15121 | |
| 15122 | /** |
| 15123 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 15124 | * inactivity timer |
| 15125 | * |
| 15126 | * Return: None |
| 15127 | */ |
| 15128 | void hdd_drv_ops_inactivity_handler(void) |
| 15129 | { |
Rajeev Kumar | 4471f1b | 2018-06-08 14:18:28 -0700 | [diff] [blame] | 15130 | hdd_err("WLAN_BUG_RCA %s: %d Sec timer expired while in .%s", |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15131 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 15132 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 15133 | if (hdd_drv_ops_task) { |
| 15134 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 15135 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 15136 | } else { |
| 15137 | hdd_err("hdd_drv_ops_task is null"); |
| 15138 | } |
| 15139 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15140 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 15141 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 15142 | sizeof("shutdown"))) |
| 15143 | QDF_BUG(0); |
| 15144 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 15145 | if (cds_is_fw_down()) { |
| 15146 | hdd_err("FW is down"); |
| 15147 | return; |
| 15148 | } |
| 15149 | |
Dustin Brown | 83044c2 | 2018-08-13 15:00:44 -0700 | [diff] [blame] | 15150 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15151 | } |
| 15152 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15153 | /** |
| 15154 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 15155 | * @struct hdd_context *hdd_ctx |
| 15156 | * @struct hdd_adapter *padapter |
| 15157 | * @bool enble |
| 15158 | * |
| 15159 | * Return: none |
| 15160 | */ |
| 15161 | void hdd_set_rx_mode_rps(bool enable) |
| 15162 | { |
| 15163 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 15164 | struct hdd_context *hdd_ctx; |
| 15165 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15166 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 15167 | if (!cds_cfg) |
| 15168 | return; |
| 15169 | |
| 15170 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 15171 | if (!hdd_ctx) |
| 15172 | return; |
| 15173 | |
| 15174 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 15175 | if (!adapter) |
| 15176 | return; |
| 15177 | |
| 15178 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15179 | if (enable && !cds_cfg->rps_enabled) |
| 15180 | hdd_send_rps_ind(adapter); |
| 15181 | else if (!enable && cds_cfg->rps_enabled) |
| 15182 | hdd_send_rps_disable_ind(adapter); |
| 15183 | } |
| 15184 | } |
| 15185 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15186 | /* Register the module init/exit functions */ |
| 15187 | module_init(hdd_module_init); |
| 15188 | module_exit(hdd_module_exit); |
| 15189 | |
| 15190 | MODULE_LICENSE("Dual BSD/GPL"); |
| 15191 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 15192 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 15193 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15194 | static const struct kernel_param_ops con_mode_ops = { |
| 15195 | .set = con_mode_handler, |
| 15196 | .get = param_get_int, |
| 15197 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15198 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15199 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 15200 | .set = con_mode_handler_ftm, |
| 15201 | .get = param_get_int, |
| 15202 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 15203 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15204 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15205 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 15206 | .set = con_mode_handler_monitor, |
| 15207 | .get = param_get_int, |
| 15208 | }; |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15209 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 15210 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15211 | static const struct kernel_param_ops fwpath_ops = { |
| 15212 | .set = fwpath_changed_handler, |
| 15213 | .get = param_get_string, |
| 15214 | }; |
| 15215 | |
| 15216 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 15217 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15218 | |
| 15219 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 15220 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15221 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15222 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15223 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 15224 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15225 | #endif |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15226 | |
| 15227 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 15228 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15229 | |
| 15230 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15231 | |
| 15232 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15233 | |
| 15234 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |