Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 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> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 43 | #include <wlan_hdd_wowl.h> |
| 44 | #include <wlan_hdd_misc.h> |
| 45 | #include <wlan_hdd_wext.h> |
| 46 | #include "wlan_hdd_trace.h" |
| 47 | #include "wlan_hdd_ioctl.h" |
| 48 | #include "wlan_hdd_ftm.h" |
| 49 | #include "wlan_hdd_power.h" |
| 50 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 51 | #include "wlan_hdd_scan.h" |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 52 | #include "wlan_policy_mgr_ucfg.h" |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 53 | #include <wlan_osif_request_manager.h> |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 54 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 55 | #include "qdf_debug_domain.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 56 | #endif |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 57 | #include "qdf_str.h" |
| 58 | #include "qdf_trace.h" |
| 59 | #include "qdf_types.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 60 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 61 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 62 | #include <cdp_txrx_stats.h> |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 63 | #include "cdp_txrx_flow_ctrl_legacy.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 64 | |
| 65 | #include <net/addrconf.h> |
| 66 | #include <linux/wireless.h> |
| 67 | #include <net/cfg80211.h> |
| 68 | #include <linux/inetdevice.h> |
| 69 | #include <net/addrconf.h> |
| 70 | #include "wlan_hdd_cfg80211.h" |
| 71 | #include "wlan_hdd_ext_scan.h" |
| 72 | #include "wlan_hdd_p2p.h" |
| 73 | #include <linux/rtnetlink.h> |
| 74 | #include "sap_api.h" |
| 75 | #include <linux/semaphore.h> |
| 76 | #include <linux/ctype.h> |
| 77 | #include <linux/compat.h> |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 78 | #include <linux/reboot.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 79 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 80 | #include <soc/qcom/subsystem_restart.h> |
| 81 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 82 | #include <wlan_hdd_hostapd.h> |
| 83 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 84 | #include <wlan_hdd_green_ap.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 85 | #include "cfg_api.h" |
| 86 | #include "qwlan_version.h" |
| 87 | #include "wma_types.h" |
| 88 | #include "wlan_hdd_tdls.h" |
| 89 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 90 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 91 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 92 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 93 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 94 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 95 | #include "wlan_hdd_nan.h" |
| 96 | #include "wlan_hdd_debugfs.h" |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 97 | #include "wlan_hdd_debugfs_csr.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 98 | #include "wlan_hdd_driver_ops.h" |
| 99 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 100 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 101 | |
| 102 | #include <wlan_hdd_ipa.h> |
| 103 | #include "hif.h" |
| 104 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 105 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 106 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 107 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 108 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 109 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 110 | #include "nan_api.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" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 127 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 128 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 129 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 130 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 131 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 132 | #include <cdp_txrx_cmn_struct.h> |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 133 | #include <dp_txrx.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 134 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 135 | #include "wlan_disa_ucfg_api.h" |
Wu Gao | 52084c1 | 2018-05-17 20:47:11 +0800 | [diff] [blame] | 136 | #include "wlan_disa_obj_mgmt_api.h" |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 137 | #include "wlan_action_oui_ucfg_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 138 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 139 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 140 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 141 | #include "wlan_hdd_apf.h" |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 142 | #include "wlan_hdd_twt.h" |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 143 | #include "qc_sap_ioctl.h" |
Sandeep Puligilla | c5609d5 | 2018-05-17 19:23:41 -0700 | [diff] [blame] | 144 | #include "wlan_mlme_main.h" |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 145 | #include "wlan_p2p_cfg_api.h" |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 146 | #include "wlan_cfg80211_p2p.h" |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 147 | #include "wlan_tdls_cfg_api.h" |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 148 | #include <wlan_hdd_rssi_monitor.h> |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 149 | #include "wlan_mlme_ucfg_api.h" |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 150 | #include "wlan_fwol_ucfg_api.h" |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 151 | #include "wlan_policy_mgr_ucfg.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 152 | #ifdef CNSS_GENL |
| 153 | #include <net/cnss_nl.h> |
| 154 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 155 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 156 | #include "wlan_ocb_ucfg_api.h" |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 157 | #include <wlan_hdd_spectralscan.h> |
gaurank kathpalia | 4a205fc | 2018-09-15 00:59:15 +0530 | [diff] [blame] | 158 | #include "wlan_green_ap_ucfg_api.h" |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 159 | #include <wlan_p2p_ucfg_api.h> |
| 160 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 161 | #ifdef MODULE |
| 162 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 163 | #else |
| 164 | #define WLAN_MODULE_NAME "wlan" |
| 165 | #endif |
| 166 | |
| 167 | #ifdef TIMER_MANAGER |
| 168 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 169 | #else |
| 170 | #define TIMER_MANAGER_STR "" |
| 171 | #endif |
| 172 | |
| 173 | #ifdef MEMORY_DEBUG |
| 174 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 175 | #else |
| 176 | #define MEMORY_DEBUG_STR "" |
| 177 | #endif |
| 178 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 179 | #ifdef PANIC_ON_BUG |
| 180 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 181 | #else |
| 182 | #define PANIC_ON_BUG_STR "" |
| 183 | #endif |
| 184 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 185 | bool g_is_system_reboot_triggered; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 186 | int wlan_start_ret_val; |
| 187 | static DECLARE_COMPLETION(wlan_start_comp); |
| 188 | static unsigned int dev_num = 1; |
| 189 | static struct cdev wlan_hdd_state_cdev; |
| 190 | static struct class *class; |
| 191 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 192 | #ifndef MODULE |
| 193 | static struct gwlan_loader *wlan_loader; |
| 194 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 195 | struct kobj_attribute *attr, |
| 196 | const char *buf, size_t count); |
| 197 | struct gwlan_loader { |
| 198 | bool loaded_state; |
| 199 | struct kobject *boot_wlan_obj; |
| 200 | struct attribute_group *attr_group; |
| 201 | }; |
| 202 | |
| 203 | static struct kobj_attribute wlan_boot_attribute = |
| 204 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 205 | |
| 206 | static struct attribute *attrs[] = { |
| 207 | &wlan_boot_attribute.attr, |
| 208 | NULL, |
| 209 | }; |
| 210 | |
| 211 | #define MODULE_INITIALIZED 1 |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 212 | |
| 213 | #ifdef MULTI_IF_NAME |
| 214 | #define WLAN_LOADER_NAME "boot_" MULTI_IF_NAME |
| 215 | #else |
| 216 | #define WLAN_LOADER_NAME "boot_wlan" |
| 217 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 218 | #endif |
| 219 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 220 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 221 | #define MAX_OPS_NAME_STRING_SIZE 20 |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 222 | #define RATE_LIMIT_ERROR_LOG (256) |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 223 | |
| 224 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 225 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 226 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 227 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 228 | /* the Android framework expects this param even though we don't use it */ |
| 229 | #define BUF_LEN 20 |
| 230 | static char fwpath_buffer[BUF_LEN]; |
| 231 | static struct kparam_string fwpath = { |
| 232 | .string = fwpath_buffer, |
| 233 | .maxlen = BUF_LEN, |
| 234 | }; |
| 235 | |
| 236 | static char *country_code; |
| 237 | static int enable_11d = -1; |
| 238 | static int enable_dfs_chan_scan = -1; |
| 239 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 240 | /* |
| 241 | * spinlock for synchronizing asynchronous request/response |
| 242 | * (full description of use in wlan_hdd_main.h) |
| 243 | */ |
| 244 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 245 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 246 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 247 | #define WLAN_NLINK_CESIUM 30 |
| 248 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 249 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 250 | |
| 251 | #define WOW_MAX_FILTER_LISTS 1 |
| 252 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 253 | #define WOW_MIN_PATTERN_SIZE 6 |
| 254 | #define WOW_MAX_PATTERN_SIZE 64 |
| 255 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 256 | /* max peer can be tdls peers + self peer + bss peer */ |
| 257 | #define HDD_MAX_VDEV_PEER_COUNT (HDD_MAX_NUM_TDLS_STA + 2) |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 258 | #define IS_IDLE_STOP (!cds_is_driver_unloading() && \ |
| 259 | !cds_is_driver_recovering() && !cds_is_driver_loading()) |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 260 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 261 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 262 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 263 | .flags = WIPHY_WOWLAN_ANY | |
| 264 | WIPHY_WOWLAN_MAGIC_PKT | |
| 265 | WIPHY_WOWLAN_DISCONNECT | |
| 266 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 267 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 268 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 269 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 270 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 271 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 272 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 273 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 274 | }; |
| 275 | #endif |
| 276 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 277 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 278 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 280 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 281 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 282 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 283 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 284 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 285 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 286 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 287 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 288 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 289 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 290 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 291 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 292 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 293 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 294 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 295 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 296 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 297 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 298 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 299 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 300 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 301 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 302 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 303 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 304 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 305 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 306 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 307 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 308 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 309 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 310 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 311 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 312 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 313 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 314 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 315 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 316 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 317 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 318 | [QDF_MODULE_ID_ACTION_OUI] = {QDF_TRACE_LEVEL_ALL}, |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 319 | [QDF_MODULE_ID_CONFIG] = {QDF_TRACE_LEVEL_ALL}, |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 320 | [QDF_MODULE_ID_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 8d039c8 | 2018-07-11 20:41:14 +0530 | [diff] [blame] | 321 | [QDF_MODULE_ID_TARGET] = {QDF_TRACE_LEVEL_ALL}, |
Kiran Kumar Lokere | 4ce4048 | 2018-08-30 16:31:00 -0700 | [diff] [blame] | 322 | [QDF_MODULE_ID_CRYPTO] = {QDF_TRACE_LEVEL_ALL}, |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 323 | [QDF_MODULE_ID_FWOL] = {QDF_TRACE_LEVEL_ALL}, |
Abhishek Singh | 0b0105f | 2018-09-25 10:44:16 +0530 | [diff] [blame] | 324 | [QDF_MODULE_ID_SM_ENGINE] = {QDF_TRACE_LEVEL_ALL}, |
| 325 | [QDF_MODULE_ID_CMN_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 326 | }; |
| 327 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 328 | struct notifier_block hdd_netdev_notifier; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 329 | struct notifier_block system_reboot_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 330 | |
| 331 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 332 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 333 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 334 | #endif |
| 335 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 336 | void hdd_start_complete(int ret) |
| 337 | { |
| 338 | wlan_start_ret_val = ret; |
| 339 | |
| 340 | complete(&wlan_start_comp); |
| 341 | } |
| 342 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 343 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 344 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 345 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 346 | * |
| 347 | * Return: none |
| 348 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 349 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 350 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 351 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 352 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 353 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 354 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 355 | } |
| 356 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 357 | #ifdef QCA_HL_NETDEV_FLOW_CONTROL |
| 358 | void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter, |
| 359 | enum netif_action_type action) |
| 360 | { |
| 361 | if (!adapter->tx_flow_timer_initialized) |
| 362 | return; |
| 363 | |
| 364 | if (action == WLAN_WAKE_NON_PRIORITY_QUEUE) { |
| 365 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 366 | } else if (action == WLAN_STOP_NON_PRIORITY_QUEUE) { |
| 367 | QDF_STATUS status = |
| 368 | qdf_mc_timer_start(&adapter->tx_flow_control_timer, |
| 369 | WLAN_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 370 | |
| 371 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 372 | hdd_err("Failed to start tx_flow_control_timer"); |
| 373 | else |
| 374 | adapter-> |
| 375 | hdd_stats.tx_rx_stats.txflow_timer_cnt++; |
| 376 | |
| 377 | adapter->hdd_stats.tx_rx_stats.txflow_pause_cnt++; |
| 378 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = true; |
| 379 | } |
| 380 | } |
| 381 | #endif /* QCA_HL_NETDEV_FLOW_CONTROL */ |
| 382 | |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 383 | #ifdef MSM_PLATFORM |
| 384 | void wlan_hdd_update_tcp_rx_param(struct hdd_context *hdd_ctx, void *data) |
| 385 | { |
| 386 | if (!hdd_ctx) { |
| 387 | hdd_err("HDD context is null"); |
| 388 | return; |
| 389 | } |
| 390 | |
| 391 | if (!data) { |
| 392 | hdd_err("Data is null"); |
| 393 | return; |
| 394 | } |
| 395 | if (hdd_ctx->config->enable_tcp_param_update) |
| 396 | wlan_hdd_send_tcp_param_update_event(hdd_ctx, data, 1); |
| 397 | else |
| 398 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 399 | WLAN_SVC_WLAN_TP_IND, |
| 400 | data, |
| 401 | sizeof(struct wlan_rx_tp_data)); |
| 402 | } |
| 403 | |
| 404 | void wlan_hdd_update_tcp_tx_param(struct hdd_context *hdd_ctx, void *data) |
| 405 | { |
| 406 | enum wlan_tp_level next_tx_level; |
| 407 | struct wlan_tx_tp_data *tx_tp_data; |
| 408 | |
| 409 | if (!hdd_ctx) { |
| 410 | hdd_err("HDD context is null"); |
| 411 | return; |
| 412 | } |
| 413 | |
| 414 | if (!data) { |
| 415 | hdd_err("Data is null"); |
| 416 | return; |
| 417 | } |
| 418 | |
| 419 | tx_tp_data = (struct wlan_tx_tp_data *)data; |
| 420 | next_tx_level = tx_tp_data->level; |
| 421 | |
| 422 | if (hdd_ctx->config->enable_tcp_param_update) |
| 423 | wlan_hdd_send_tcp_param_update_event(hdd_ctx, data, 0); |
| 424 | else |
| 425 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 426 | WLAN_SVC_WLAN_TP_TX_IND, |
| 427 | &next_tx_level, |
| 428 | sizeof(next_tx_level)); |
| 429 | } |
| 430 | |
| 431 | /** |
| 432 | * wlan_hdd_send_tcp_param_update_event() - Send vendor event to update |
| 433 | * TCP parameter through Wi-Fi HAL |
| 434 | * @hdd_ctx: Pointer to HDD context |
| 435 | * @data: Parameters to update |
| 436 | * @dir: Direction(tx/rx) to update |
| 437 | * |
| 438 | * Return: None |
| 439 | */ |
| 440 | void wlan_hdd_send_tcp_param_update_event(struct hdd_context *hdd_ctx, |
| 441 | void *data, |
| 442 | uint8_t dir) |
| 443 | { |
| 444 | struct sk_buff *vendor_event; |
| 445 | uint32_t event_len; |
| 446 | bool tcp_limit_output = false; |
| 447 | bool tcp_del_ack_ind_enabled = false; |
| 448 | bool tcp_adv_win_scl_enabled = false; |
| 449 | enum wlan_tp_level next_tp_level = WLAN_SVC_TP_NONE; |
| 450 | |
| 451 | event_len = sizeof(uint8_t) + sizeof(uint8_t) + NLMSG_HDRLEN; |
| 452 | |
| 453 | if (dir == 0) /*TX Flow */ { |
| 454 | struct wlan_tx_tp_data *tx_tp_data = |
| 455 | (struct wlan_tx_tp_data *)data; |
| 456 | |
| 457 | next_tp_level = tx_tp_data->level; |
| 458 | |
| 459 | if (tx_tp_data->tcp_limit_output) { |
| 460 | /* TCP_LIMIT_OUTPUT_BYTES */ |
| 461 | event_len += sizeof(uint32_t); |
| 462 | tcp_limit_output = true; |
| 463 | } |
| 464 | } else if (dir == 1) /* RX Flow */ { |
| 465 | struct wlan_rx_tp_data *rx_tp_data = |
| 466 | (struct wlan_rx_tp_data *)data; |
| 467 | |
| 468 | next_tp_level = rx_tp_data->level; |
| 469 | |
| 470 | if (rx_tp_data->rx_tp_flags & TCP_DEL_ACK_IND_MASK) { |
| 471 | event_len += sizeof(uint32_t); /* TCP_DELACK_SEG */ |
| 472 | tcp_del_ack_ind_enabled = true; |
| 473 | } |
| 474 | if (rx_tp_data->rx_tp_flags & TCP_ADV_WIN_SCL_MASK) { |
| 475 | event_len += sizeof(uint32_t); /* TCP_ADV_WIN_SCALE */ |
| 476 | tcp_adv_win_scl_enabled = true; |
| 477 | } |
| 478 | } else { |
| 479 | hdd_err("Invalid Direction [%d]", dir); |
| 480 | return; |
| 481 | } |
| 482 | |
| 483 | vendor_event = |
| 484 | cfg80211_vendor_event_alloc( |
| 485 | hdd_ctx->wiphy, |
| 486 | NULL, event_len, |
| 487 | QCA_NL80211_VENDOR_SUBCMD_THROUGHPUT_CHANGE_EVENT_INDEX, |
| 488 | GFP_KERNEL); |
| 489 | |
| 490 | if (!vendor_event) { |
| 491 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 492 | return; |
| 493 | } |
| 494 | |
| 495 | if (nla_put_u8( |
| 496 | vendor_event, |
| 497 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_DIRECTION, |
| 498 | dir)) |
| 499 | goto tcp_param_change_nla_failed; |
| 500 | |
| 501 | if (nla_put_u8( |
| 502 | vendor_event, |
| 503 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_THROUGHPUT_LEVEL, |
| 504 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 505 | QCA_WLAN_THROUGHPUT_LEVEL_LOW : |
| 506 | QCA_WLAN_THROUGHPUT_LEVEL_HIGH))) |
| 507 | goto tcp_param_change_nla_failed; |
| 508 | |
| 509 | if (tcp_limit_output && |
| 510 | nla_put_u32( |
| 511 | vendor_event, |
| 512 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_LIMIT_OUTPUT_BYTES, |
| 513 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 514 | TCP_LIMIT_OUTPUT_BYTES_LOW : |
| 515 | TCP_LIMIT_OUTPUT_BYTES_HI))) |
| 516 | goto tcp_param_change_nla_failed; |
| 517 | |
| 518 | if (tcp_del_ack_ind_enabled && |
| 519 | (nla_put_u32( |
| 520 | vendor_event, |
| 521 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_DELACK_SEG, |
| 522 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 523 | TCP_DEL_ACK_LOW : TCP_DEL_ACK_HI)))) |
| 524 | goto tcp_param_change_nla_failed; |
| 525 | |
| 526 | if (tcp_adv_win_scl_enabled && |
| 527 | (nla_put_u32( |
| 528 | vendor_event, |
| 529 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_ADV_WIN_SCALE, |
| 530 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 531 | WIN_SCALE_LOW : WIN_SCALE_HI)))) |
| 532 | goto tcp_param_change_nla_failed; |
| 533 | |
| 534 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 535 | return; |
| 536 | |
| 537 | tcp_param_change_nla_failed: |
| 538 | hdd_err("nla_put api failed"); |
| 539 | kfree_skb(vendor_event); |
| 540 | } |
| 541 | #endif /* MSM_PLATFORM */ |
| 542 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 543 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 544 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 545 | * @vdev_id: vdev_id |
| 546 | * @action: action type |
| 547 | * @reason: reason type |
| 548 | * |
| 549 | * Return: none |
| 550 | */ |
| 551 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 552 | enum netif_action_type action, enum netif_reason_type reason) |
| 553 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 554 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 555 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 556 | |
| 557 | if (!hdd_ctx) { |
| 558 | hdd_err("hdd ctx is NULL"); |
| 559 | return; |
| 560 | } |
| 561 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 562 | wlan_hdd_mod_fc_timer(adapter, action); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 563 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 567 | * Store WLAN driver version and timestamp info in global variables such that |
| 568 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 569 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 570 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 571 | #ifdef BUILD_TAG |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 572 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR "; " BUILD_TAG; |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 573 | #else |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 574 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 575 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 576 | |
| 577 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 578 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 579 | * @hdd_ctx: HDD context |
| 580 | * @chan_list: buf hold returned chan list |
| 581 | * @chan_num: input buf size and output returned chan num |
| 582 | * |
| 583 | * This function helps get current available chan list from regulatory |
| 584 | * module. It excludes the "disabled" and "invalid" channels. |
| 585 | * |
| 586 | * Return: 0 for success. |
| 587 | */ |
| 588 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 589 | uint8_t *chan_list, |
| 590 | uint32_t *chan_num) |
| 591 | { |
| 592 | int i = 0, j = 0; |
| 593 | struct regulatory_channel *cur_chan_list; |
| 594 | struct wlan_objmgr_pdev *pdev; |
| 595 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 596 | if (!hdd_ctx || !hdd_ctx->pdev || !chan_list || !chan_num) |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 597 | return -EINVAL; |
| 598 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 599 | pdev = hdd_ctx->pdev; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 600 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 601 | sizeof(struct regulatory_channel)); |
| 602 | if (!cur_chan_list) |
| 603 | return -ENOMEM; |
| 604 | |
| 605 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 606 | QDF_STATUS_SUCCESS) { |
| 607 | qdf_mem_free(cur_chan_list); |
| 608 | return -EINVAL; |
| 609 | } |
| 610 | |
| 611 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 612 | uint32_t ch = cur_chan_list[i].chan_num; |
| 613 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 614 | ch); |
| 615 | |
| 616 | if (state != CHANNEL_STATE_DISABLE && |
| 617 | state != CHANNEL_STATE_INVALID && |
| 618 | j < *chan_num) { |
| 619 | chan_list[j] = (uint8_t)ch; |
| 620 | j++; |
| 621 | } |
| 622 | } |
| 623 | *chan_num = j; |
| 624 | qdf_mem_free(cur_chan_list); |
| 625 | return 0; |
| 626 | } |
| 627 | |
| 628 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 629 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 630 | * @adapter: HDD adapter |
| 631 | * @chan_number: Channel number |
| 632 | * @chan_bw: Bandwidth |
| 633 | * |
| 634 | * Checks if the given bandwidth is valid for the given channel number. |
| 635 | * |
| 636 | * Return: 0 for success, non-zero for failure |
| 637 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 638 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 639 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 640 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 641 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 642 | uint8_t chan[NUM_CHANNELS]; |
| 643 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 644 | bool found = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 645 | mac_handle_t mac_handle; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 646 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 647 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 648 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 649 | if (!mac_handle) { |
| 650 | hdd_err("Invalid MAC handle"); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 651 | return -EINVAL; |
| 652 | } |
| 653 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 654 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 655 | &len); |
| 656 | if (ret) { |
| 657 | hdd_err("error %d in getting valid channel list", ret); |
| 658 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | for (i = 0; i < len; i++) { |
| 662 | if (chan[i] == chan_number) { |
| 663 | found = true; |
| 664 | break; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | if (found == false) { |
| 669 | hdd_err("Channel not in driver's valid channel list"); |
| 670 | return -EOPNOTSUPP; |
| 671 | } |
| 672 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 673 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 674 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 675 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 676 | return -EINVAL; |
| 677 | } |
| 678 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 679 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 680 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 681 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 682 | return -EINVAL; |
| 683 | } |
| 684 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 685 | (chan_bw != CH_WIDTH_MAX)) { |
| 686 | hdd_err("Only BW20 possible on channel 14"); |
| 687 | return -EINVAL; |
| 688 | } |
| 689 | } |
| 690 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 691 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 692 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 693 | (chan_bw != CH_WIDTH_MAX)) { |
| 694 | hdd_err("Only BW20 possible on channel 165"); |
| 695 | return -EINVAL; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | return 0; |
| 700 | } |
| 701 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 702 | /** |
| 703 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 704 | * |
| 705 | * Block the unloading of the driver (or) interface up until the |
| 706 | * cds recovery is completed |
| 707 | * |
| 708 | * Return: true for recovery completion else false |
| 709 | */ |
| 710 | static bool hdd_wait_for_recovery_completion(void) |
| 711 | { |
| 712 | int retry = 0; |
| 713 | |
| 714 | /* Wait for recovery to complete */ |
| 715 | while (cds_is_driver_recovering()) { |
| 716 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 717 | hdd_err("Recovery in progress; wait here!!!"); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 718 | |
| 719 | if (g_is_system_reboot_triggered) { |
| 720 | hdd_info("System Reboot happening ignore unload!!"); |
| 721 | return false; |
| 722 | } |
| 723 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 724 | msleep(1000); |
| 725 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 726 | hdd_err("SSR never completed, error"); |
| 727 | /* |
| 728 | * Trigger the bug_on in the internal builds, in the |
| 729 | * customer builds self-recovery will be enabled |
| 730 | * in those cases just return error. |
| 731 | */ |
| 732 | if (cds_is_self_recovery_enabled()) |
| 733 | return false; |
| 734 | QDF_BUG(0); |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | hdd_info("Recovery completed successfully!"); |
| 739 | return true; |
| 740 | } |
| 741 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 742 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 743 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 744 | unsigned long state, void *data) |
| 745 | { |
| 746 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 747 | struct netdev_notifier_info *dev_notif_info = data; |
| 748 | struct net_device *dev = dev_notif_info->dev; |
| 749 | #else |
| 750 | struct net_device *dev = data; |
| 751 | #endif |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 752 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 753 | struct hdd_context *hdd_ctx; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 754 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 755 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 756 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 757 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 758 | if (!dev->ieee80211_ptr) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 759 | hdd_debug("ieee80211_ptr is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 760 | return NOTIFY_DONE; |
| 761 | } |
| 762 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 763 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 764 | if (!hdd_ctx) { |
| 765 | hdd_err("HDD Context is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 766 | return NOTIFY_DONE; |
| 767 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 768 | |
| 769 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 770 | hdd_debug("%s: Driver module is closed", __func__); |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 771 | return NOTIFY_DONE; |
| 772 | } |
| 773 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 774 | /* Make sure that this callback corresponds to our device. */ |
| 775 | adapter = hdd_get_adapter_by_iface_name(hdd_ctx, dev->name); |
| 776 | if (!adapter) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 777 | hdd_debug("failed to look up adapter for '%s'", dev->name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 778 | return NOTIFY_DONE; |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 779 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 780 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 781 | if (adapter != WLAN_HDD_GET_PRIV_PTR(dev)) { |
| 782 | hdd_err("HDD adapter mismatch!"); |
| 783 | return NOTIFY_DONE; |
| 784 | } |
| 785 | |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 786 | if (cds_is_driver_recovering()) { |
| 787 | hdd_debug("Driver is recovering"); |
| 788 | return NOTIFY_DONE; |
| 789 | } |
| 790 | |
| 791 | if (cds_is_driver_in_bad_state()) { |
| 792 | hdd_debug("Driver is in failed recovery state"); |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 793 | return NOTIFY_DONE; |
| 794 | } |
| 795 | |
| 796 | hdd_debug("%s New Net Device State = %lu", dev->name, state); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 797 | |
| 798 | switch (state) { |
| 799 | case NETDEV_REGISTER: |
| 800 | break; |
| 801 | |
| 802 | case NETDEV_UNREGISTER: |
| 803 | break; |
| 804 | |
| 805 | case NETDEV_UP: |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 806 | sme_ch_avoid_update_req(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 807 | break; |
| 808 | |
| 809 | case NETDEV_DOWN: |
| 810 | break; |
| 811 | |
| 812 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 813 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 814 | complete(&adapter->linkup_event_var); |
| 815 | break; |
| 816 | |
| 817 | case NETDEV_GOING_DOWN: |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 818 | vdev = hdd_objmgr_get_vdev(adapter); |
| 819 | if (!vdev) |
| 820 | break; |
| 821 | if (ucfg_scan_get_vdev_status(vdev) != |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 822 | SCAN_NOT_IN_PROGRESS) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 823 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
| 824 | adapter->session_id, INVALID_SCAN_ID, |
| 825 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 826 | } |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 827 | hdd_objmgr_put_vdev(adapter); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 828 | cds_flush_work(&adapter->scan_block_work); |
| 829 | /* Need to clean up blocked scan request */ |
| 830 | wlan_hdd_cfg80211_scan_block_cb(&adapter->scan_block_work); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 831 | hdd_debug("Scan is not Pending from user"); |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 832 | /* |
| 833 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 834 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 835 | * flag after which driver does not send the cfg80211_scan_done. |
| 836 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 837 | */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 838 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 839 | break; |
| 840 | |
| 841 | default: |
| 842 | break; |
| 843 | } |
| 844 | |
| 845 | return NOTIFY_DONE; |
| 846 | } |
| 847 | |
| 848 | /** |
| 849 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 850 | * @nb: pointer to notifier block |
| 851 | * @state: state |
| 852 | * @ndev: ndev pointer |
| 853 | * |
| 854 | * Return: 0 on success, error number otherwise. |
| 855 | */ |
| 856 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 857 | unsigned long state, |
| 858 | void *ndev) |
| 859 | { |
| 860 | int ret; |
| 861 | |
| 862 | cds_ssr_protect(__func__); |
| 863 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 864 | cds_ssr_unprotect(__func__); |
| 865 | |
| 866 | return ret; |
| 867 | } |
| 868 | |
| 869 | struct notifier_block hdd_netdev_notifier = { |
| 870 | .notifier_call = hdd_netdev_notifier_call, |
| 871 | }; |
| 872 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 873 | static int system_reboot_notifier_call(struct notifier_block *nb, |
| 874 | unsigned long msg_type, void *_unused) |
| 875 | { |
| 876 | switch (msg_type) { |
| 877 | case SYS_DOWN: |
| 878 | case SYS_HALT: |
| 879 | case SYS_POWER_OFF: |
| 880 | g_is_system_reboot_triggered = true; |
| 881 | hdd_info("reboot, reason: %ld", msg_type); |
| 882 | break; |
| 883 | default: |
| 884 | break; |
| 885 | } |
| 886 | |
| 887 | return NOTIFY_OK; |
| 888 | } |
| 889 | |
| 890 | struct notifier_block system_reboot_notifier = { |
| 891 | .notifier_call = system_reboot_notifier_call, |
| 892 | }; |
| 893 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 894 | /* variable to hold the insmod parameters */ |
| 895 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 896 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 897 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 898 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 899 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 900 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 901 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 902 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 903 | /** |
| 904 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 905 | * @ch_width: NL channel width |
| 906 | * |
| 907 | * Converts the NL channel width to the driver's internal representation |
| 908 | * |
| 909 | * Return: Converted channel width. In case of non matching NL channel width, |
| 910 | * CH_WIDTH_MAX will be returned. |
| 911 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 912 | 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] | 913 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 914 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 915 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 916 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 917 | switch (ch_width) { |
| 918 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 919 | case NL80211_CHAN_WIDTH_20: |
| 920 | return CH_WIDTH_20MHZ; |
| 921 | case NL80211_CHAN_WIDTH_40: |
| 922 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 923 | case NL80211_CHAN_WIDTH_80: |
| 924 | return CH_WIDTH_80MHZ; |
| 925 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 926 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 927 | return CH_WIDTH_80P80MHZ; |
| 928 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 929 | return CH_WIDTH_160MHZ; |
| 930 | else |
| 931 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 932 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 933 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 934 | return CH_WIDTH_160MHZ; |
| 935 | else |
| 936 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 937 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 938 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 939 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 940 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 941 | default: |
| 942 | hdd_err("Invalid channel width %d, setting to default", |
| 943 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 944 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 945 | } |
| 946 | } |
| 947 | |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 948 | QDF_STATUS hdd_nl_to_qdf_iface_type(enum nl80211_iftype nl_type, |
| 949 | enum QDF_OPMODE *out_qdf_type) |
| 950 | { |
| 951 | switch (nl_type) { |
| 952 | case NL80211_IFTYPE_ADHOC: |
| 953 | *out_qdf_type = QDF_IBSS_MODE; |
| 954 | break; |
| 955 | case NL80211_IFTYPE_AP: |
| 956 | *out_qdf_type = QDF_SAP_MODE; |
| 957 | break; |
| 958 | case NL80211_IFTYPE_MONITOR: |
| 959 | *out_qdf_type = QDF_MONITOR_MODE; |
| 960 | break; |
| 961 | case NL80211_IFTYPE_OCB: |
| 962 | *out_qdf_type = QDF_OCB_MODE; |
| 963 | break; |
| 964 | case NL80211_IFTYPE_P2P_CLIENT: |
| 965 | *out_qdf_type = QDF_P2P_CLIENT_MODE; |
| 966 | break; |
| 967 | case NL80211_IFTYPE_P2P_DEVICE: |
| 968 | *out_qdf_type = QDF_P2P_DEVICE_MODE; |
| 969 | break; |
| 970 | case NL80211_IFTYPE_P2P_GO: |
| 971 | *out_qdf_type = QDF_P2P_GO_MODE; |
| 972 | break; |
| 973 | case NL80211_IFTYPE_STATION: |
| 974 | *out_qdf_type = QDF_STA_MODE; |
| 975 | break; |
| 976 | case NL80211_IFTYPE_WDS: |
| 977 | *out_qdf_type = QDF_WDS_MODE; |
| 978 | break; |
| 979 | default: |
| 980 | hdd_err("Invalid nl80211 interface type %d", nl_type); |
| 981 | return QDF_STATUS_E_INVAL; |
| 982 | } |
| 983 | |
| 984 | return QDF_STATUS_SUCCESS; |
| 985 | } |
| 986 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 987 | uint8_t wlan_hdd_find_opclass(mac_handle_t mac_handle, uint8_t channel, |
| 988 | uint8_t bw_offset) |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 989 | { |
| 990 | uint8_t opclass = 0; |
| 991 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 992 | sme_get_opclass(mac_handle, channel, bw_offset, &opclass); |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 993 | return opclass; |
| 994 | } |
| 995 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 996 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 997 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 998 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 999 | * @bitmask: Bitmask of log levels to be enabled |
| 1000 | * |
| 1001 | * Called immediately after the cfg.ini is read in order to configure |
| 1002 | * the desired trace levels. |
| 1003 | * |
| 1004 | * Return: None |
| 1005 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1006 | 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] | 1007 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1008 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1009 | int qdf_print_idx = -1; |
| 1010 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1011 | /* |
| 1012 | * if the bitmask is the default value, then a bitmask was not |
| 1013 | * specified in cfg.ini, so leave the logging level alone (it |
| 1014 | * will remain at the "compiled in" default value) |
| 1015 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1016 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1017 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1018 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1019 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1020 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1021 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1022 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1023 | QDF_TRACE_LEVEL_NONE, 0); |
| 1024 | |
| 1025 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1026 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1027 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 1028 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1029 | while (0 != bitmask) { |
| 1030 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1031 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1032 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1033 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1034 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1035 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1036 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1037 | level++; |
| 1038 | bitmask >>= 1; |
| 1039 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1040 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1041 | } |
| 1042 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1043 | 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] | 1044 | { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1045 | if (!hdd_ctx) { |
| 1046 | hdd_err("HDD context is null (via %s)", func); |
| 1047 | return -ENODEV; |
| 1048 | } |
| 1049 | |
| 1050 | if (!hdd_ctx->config) { |
| 1051 | hdd_err("HDD config is null (via %s)", func); |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 1052 | return -ENODEV; |
| 1053 | } |
| 1054 | |
| 1055 | if (cds_is_driver_recovering()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1056 | hdd_debug("Recovery in progress (via %s); state:0x%x", |
| 1057 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1058 | return -EAGAIN; |
| 1059 | } |
| 1060 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 1061 | if (cds_is_load_or_unload_in_progress()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1062 | hdd_debug("Load/unload in progress (via %s); state:0x%x", |
| 1063 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1064 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 1065 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1066 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1067 | if (hdd_ctx->start_modules_in_progress) { |
| 1068 | hdd_debug("Start modules in progress (via %s)", func); |
| 1069 | return -EAGAIN; |
| 1070 | } |
| 1071 | |
| 1072 | if (hdd_ctx->stop_modules_in_progress) { |
| 1073 | hdd_debug("Stop modules in progress (via %s)", func); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1074 | return -EAGAIN; |
| 1075 | } |
| 1076 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1077 | if (cds_is_driver_in_bad_state()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1078 | hdd_debug("Driver in bad state (via %s); state:0x%x", |
| 1079 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 1080 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1081 | } |
| 1082 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 1083 | if (cds_is_fw_down()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1084 | hdd_debug("FW is down (via %s); state:0x%x", |
| 1085 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 1086 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 1087 | } |
| 1088 | |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 1089 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1090 | hdd_debug("Driver mode change in progress (via %s)", func); |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 1091 | return -EAGAIN; |
| 1092 | } |
| 1093 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1094 | return 0; |
| 1095 | } |
| 1096 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1097 | int __hdd_validate_adapter(struct hdd_adapter *adapter, const char *func) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1098 | { |
| 1099 | if (!adapter) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1100 | hdd_err("adapter is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1101 | return -EINVAL; |
| 1102 | } |
| 1103 | |
| 1104 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1105 | hdd_err("bad adapter magic (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1106 | return -EINVAL; |
| 1107 | } |
| 1108 | |
| 1109 | if (!adapter->dev) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1110 | hdd_err("adapter net_device is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1111 | return -EINVAL; |
| 1112 | } |
| 1113 | |
| 1114 | if (!(adapter->dev->flags & IFF_UP)) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1115 | hdd_debug_rl("adapter '%s' is not up (via %s)", |
| 1116 | adapter->dev->name, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1117 | return -EAGAIN; |
| 1118 | } |
| 1119 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1120 | return __wlan_hdd_validate_session_id(adapter->session_id, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1121 | } |
| 1122 | |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 1123 | int __wlan_hdd_validate_session_id(uint8_t session_id, const char *func) |
| 1124 | { |
| 1125 | if (session_id == CSR_SESSION_ID_INVALID) { |
| 1126 | hdd_debug_rl("adapter is not up (via %s)", func); |
| 1127 | return -EINVAL; |
| 1128 | } |
| 1129 | |
| 1130 | if (session_id >= CSR_ROAM_SESSION_MAX) { |
| 1131 | hdd_err("bad session Id:%u (via %s)", session_id, func); |
| 1132 | return -EINVAL; |
| 1133 | } |
| 1134 | |
| 1135 | return 0; |
| 1136 | } |
| 1137 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 1138 | QDF_STATUS __wlan_hdd_validate_mac_address(struct qdf_mac_addr *mac_addr, |
| 1139 | const char *func) |
| 1140 | { |
| 1141 | if (!mac_addr) { |
| 1142 | hdd_err("Received NULL mac address (via %s)", func); |
| 1143 | return QDF_STATUS_E_INVAL; |
| 1144 | } |
| 1145 | |
| 1146 | if (qdf_is_macaddr_zero(mac_addr)) { |
| 1147 | hdd_err("MAC is all zero (via %s)", func); |
| 1148 | return QDF_STATUS_E_INVAL; |
| 1149 | } |
| 1150 | |
| 1151 | if (qdf_is_macaddr_broadcast(mac_addr)) { |
| 1152 | hdd_err("MAC is Broadcast (via %s)", func); |
| 1153 | return QDF_STATUS_E_INVAL; |
| 1154 | } |
| 1155 | |
| 1156 | if (QDF_NET_IS_MAC_MULTICAST(mac_addr->bytes)) { |
| 1157 | hdd_err("MAC is Multicast (via %s)", func); |
| 1158 | return QDF_STATUS_E_INVAL; |
| 1159 | } |
| 1160 | |
| 1161 | return QDF_STATUS_SUCCESS; |
| 1162 | } |
| 1163 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1164 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1165 | * wlan_hdd_validate_modules_state() - Check modules status |
| 1166 | * @hdd_ctx: HDD context pointer |
| 1167 | * |
| 1168 | * Check's the driver module's state and returns true if the |
| 1169 | * modules are enabled returns false if modules are closed. |
| 1170 | * |
| 1171 | * Return: True if modules are enabled or false. |
| 1172 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1173 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1174 | { |
| 1175 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 1176 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 1177 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 1178 | hdd_info("Modules not enabled, Present status: %d", |
| 1179 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1180 | return false; |
| 1181 | } |
| 1182 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 1183 | return true; |
| 1184 | } |
| 1185 | |
| 1186 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1187 | * 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] | 1188 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1189 | * |
| 1190 | * This function sets the IBSS power save config parameters to WMA |
| 1191 | * which will send it to firmware if FW supports IBSS power save |
| 1192 | * before vdev start. |
| 1193 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1194 | * 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] | 1195 | * on failure. |
| 1196 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1197 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1198 | { |
| 1199 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1200 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1201 | |
| 1202 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1203 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1204 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1205 | } |
| 1206 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1207 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1208 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 1209 | hdd_ctx->config->ibssATIMWinSize, |
| 1210 | VDEV_CMD); |
| 1211 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1212 | hdd_err("atim window set failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1213 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1214 | } |
| 1215 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1216 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1217 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 1218 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 1219 | VDEV_CMD); |
| 1220 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1221 | hdd_err("power save allow failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1222 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1223 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1224 | } |
| 1225 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1226 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1227 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 1228 | hdd_ctx->config-> |
| 1229 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 1230 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1231 | hdd_err("power collapse allow failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1232 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1233 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1234 | } |
| 1235 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1236 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1237 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 1238 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 1239 | VDEV_CMD); |
| 1240 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1241 | hdd_err("set awake on tx/rx failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1242 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1243 | } |
| 1244 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1245 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1246 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 1247 | hdd_ctx->config->ibssInactivityCount, |
| 1248 | VDEV_CMD); |
| 1249 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1250 | hdd_err("set inactivity time failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1251 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1252 | } |
| 1253 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1254 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1255 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 1256 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 1257 | VDEV_CMD); |
| 1258 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1259 | hdd_err("set txsp end failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1260 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1261 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1262 | } |
| 1263 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1264 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1265 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 1266 | hdd_ctx->config->ibssPsWarmupTime, |
| 1267 | VDEV_CMD); |
| 1268 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1269 | hdd_err("set ps warmup failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1270 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1271 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1272 | } |
| 1273 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1274 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1275 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 1276 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 1277 | VDEV_CMD); |
| 1278 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1279 | hdd_err("set 1rx chain atim failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1280 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1281 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1282 | } |
| 1283 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1284 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1285 | } |
| 1286 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1287 | #ifdef FEATURE_RUNTIME_PM |
| 1288 | /** |
| 1289 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1290 | * @hdd_ctx: HDD context |
| 1291 | * |
| 1292 | * Return: None |
| 1293 | */ |
| 1294 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1295 | { |
| 1296 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1297 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1298 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1299 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1300 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1301 | wlan_scan_runtime_pm_init(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1302 | } |
| 1303 | |
| 1304 | /** |
| 1305 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1306 | * @hdd_ctx: HDD Context |
| 1307 | * |
| 1308 | * Return: None |
| 1309 | */ |
| 1310 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1311 | { |
| 1312 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1313 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1314 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1315 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1316 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1317 | wlan_scan_runtime_pm_deinit(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1318 | } |
| 1319 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1320 | #else /* FEATURE_RUNTIME_PM */ |
| 1321 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1322 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1323 | #endif /* FEATURE_RUNTIME_PM */ |
| 1324 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1325 | #define INTF_MACADDR_MASK 0x7 |
| 1326 | |
| 1327 | /** |
| 1328 | * hdd_update_macaddr() - update mac address |
| 1329 | * @config: hdd configuration |
| 1330 | * @hw_macaddr: mac address |
| 1331 | * |
| 1332 | * Mac address for multiple virtual interface is found as following |
| 1333 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1334 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1335 | * define the mac address for the remaining interfaces and locally |
| 1336 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1337 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1338 | * interface). |
| 1339 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1340 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1341 | * |
| 1342 | * Return: None |
| 1343 | */ |
| 1344 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1345 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1346 | { |
| 1347 | int8_t i; |
| 1348 | uint8_t macaddr_b3, tmp_br3; |
| 1349 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1350 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1351 | QDF_MAC_ADDR_SIZE); |
| 1352 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1353 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1354 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1355 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1356 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1357 | INTF_MACADDR_MASK; |
| 1358 | macaddr_b3 += tmp_br3; |
| 1359 | |
| 1360 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1361 | * mac address range before collision |
| 1362 | */ |
| 1363 | macaddr_b3 ^= (1 << 7); |
| 1364 | |
| 1365 | /* Set locally administered bit */ |
| 1366 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1367 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1368 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1369 | MAC_ADDRESS_STR, i, |
| 1370 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1371 | } |
| 1372 | } |
| 1373 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1374 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1375 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1376 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1377 | struct tdls_start_params tdls_cfg; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1378 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1379 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 1380 | |
| 1381 | /* Populate the nss chain params from ini for this vdev type */ |
| 1382 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 1383 | QDF_TDLS_MODE, |
| 1384 | hdd_ctx->num_rf_chains); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1385 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1386 | cfg_tdls_set_vdev_nss_2g(hdd_ctx->psoc, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1387 | vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1388 | cfg_tdls_set_vdev_nss_5g(hdd_ctx->psoc, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1389 | vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]); |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1390 | hdd_init_tdls_config(&tdls_cfg); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1391 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1392 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1393 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1394 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1395 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1396 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1397 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1398 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1399 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1400 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1401 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1402 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1403 | |
| 1404 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1405 | if (status != QDF_STATUS_SUCCESS) { |
| 1406 | hdd_err("failed pmo psoc configuration"); |
| 1407 | return -EINVAL; |
| 1408 | } |
| 1409 | |
| 1410 | hdd_ctx->tdls_umac_comp_active = true; |
| 1411 | /* enable napier specific tdls data path */ |
| 1412 | hdd_ctx->tdls_nap_active = true; |
| 1413 | |
| 1414 | return 0; |
| 1415 | } |
| 1416 | |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1417 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1418 | static void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1419 | struct wma_tgt_services *cfg) |
| 1420 | { |
| 1421 | bool roam_offload_enable; |
| 1422 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1423 | ucfg_mlme_get_roaming_offload(hdd_ctx->psoc, &roam_offload_enable); |
| 1424 | ucfg_mlme_set_roaming_offload(hdd_ctx->psoc, |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1425 | roam_offload_enable & |
| 1426 | cfg->en_roam_offload); |
| 1427 | } |
| 1428 | #else |
| 1429 | static inline void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1430 | struct wma_tgt_services *cfg) |
| 1431 | { |
| 1432 | } |
| 1433 | #endif |
| 1434 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1435 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1436 | struct wma_tgt_services *cfg) |
| 1437 | { |
| 1438 | struct hdd_config *config = hdd_ctx->config; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1439 | bool arp_offload_enable; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1440 | bool mawc_enabled; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1441 | #ifdef FEATURE_WLAN_TDLS |
| 1442 | bool tdls_support; |
| 1443 | bool tdls_off_channel; |
| 1444 | bool tdls_buffer_sta; |
| 1445 | uint32_t tdls_uapsd_mask; |
| 1446 | #endif |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1447 | bool value; |
| 1448 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1449 | /* Set up UAPSD */ |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 1450 | ucfg_mlme_set_sap_uapsd_flag(hdd_ctx->psoc, cfg->uapsd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1451 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1452 | /* 11AX mode support */ |
| 1453 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1454 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1455 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1456 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1457 | /* 11AC mode support */ |
| 1458 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1459 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1460 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1461 | |
| 1462 | /* ARP offload: override user setting if invalid */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1463 | arp_offload_enable = |
| 1464 | ucfg_pmo_is_arp_offload_enabled(hdd_ctx->psoc); |
| 1465 | ucfg_pmo_set_arp_offload_enabled(hdd_ctx->psoc, |
| 1466 | arp_offload_enable & cfg->arp_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1467 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1468 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1469 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1470 | if (cfg->pno_offload) |
| 1471 | config->PnoOffload = true; |
| 1472 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1473 | #ifdef FEATURE_WLAN_TDLS |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1474 | cfg_tdls_get_support_enable(hdd_ctx->psoc, &tdls_support); |
| 1475 | cfg_tdls_set_support_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1476 | tdls_support & cfg->en_tdls); |
| 1477 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1478 | cfg_tdls_get_off_channel_enable(hdd_ctx->psoc, &tdls_off_channel); |
| 1479 | cfg_tdls_set_off_channel_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1480 | tdls_off_channel && |
| 1481 | cfg->en_tdls_offchan); |
| 1482 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1483 | cfg_tdls_get_buffer_sta_enable(hdd_ctx->psoc, &tdls_buffer_sta); |
| 1484 | cfg_tdls_set_buffer_sta_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1485 | tdls_buffer_sta && |
| 1486 | cfg->en_tdls_uapsd_buf_sta); |
| 1487 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1488 | cfg_tdls_get_uapsd_mask(hdd_ctx->psoc, &tdls_uapsd_mask); |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1489 | if (tdls_uapsd_mask && cfg->en_tdls_uapsd_sleep_sta) |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1490 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, true); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1491 | else |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1492 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1493 | #endif |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1494 | hdd_update_roam_offload(hdd_ctx, cfg); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1495 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 1496 | if (ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value) == |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1497 | QDF_STATUS_SUCCESS) |
| 1498 | value &= cfg->get_peer_info_enabled; |
| 1499 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1500 | ucfg_mlme_is_mawc_enabled(hdd_ctx->psoc, &mawc_enabled); |
| 1501 | ucfg_mlme_set_mawc_enabled(hdd_ctx->psoc, |
| 1502 | mawc_enabled & cfg->is_fw_mawc_capable); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1503 | hdd_update_tdls_config(hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1504 | sme_update_tgt_services(hdd_ctx->mac_handle, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1505 | } |
| 1506 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1507 | /** |
| 1508 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1509 | * @hdd_ctx: HDD context |
| 1510 | * |
| 1511 | * Sets the Nss per vdev type based on INI |
| 1512 | * |
| 1513 | * Return: None |
| 1514 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1515 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1516 | { |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1517 | uint8_t max_supp_nss = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1518 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1519 | QDF_STATUS status; |
| 1520 | bool bval; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1521 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1522 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1523 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1524 | hdd_err("unable to get vht_enable2x2"); |
| 1525 | |
| 1526 | if (bval && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1527 | max_supp_nss = 2; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1528 | |
| 1529 | hdd_debug("max nss %d", max_supp_nss); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1530 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1531 | mac_handle = hdd_ctx->mac_handle; |
| 1532 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1533 | NSS_CHAINS_BAND_2GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1534 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1535 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1536 | NSS_CHAINS_BAND_5GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1537 | } |
| 1538 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1539 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1540 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1541 | * @hdd_ctx: HDD context |
| 1542 | * |
| 1543 | * Updates wiphy vhtcap fields |
| 1544 | * |
| 1545 | * Return: None |
| 1546 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1547 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1548 | { |
| 1549 | struct ieee80211_supported_band *band_5g = |
| 1550 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1551 | QDF_STATUS status; |
| 1552 | uint8_t value = 0, value1 = 0; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1553 | |
| 1554 | if (!band_5g) { |
| 1555 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1556 | return; |
| 1557 | } |
| 1558 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1559 | status = ucfg_mlme_cfg_get_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 1560 | &value); |
| 1561 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1562 | hdd_err("unable to get tx_bfee_ant_supp"); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1563 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1564 | band_5g->vht_cap.cap |= |
| 1565 | (value << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1566 | |
| 1567 | value1 = NUM_OF_SOUNDING_DIMENSIONS; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1568 | band_5g->vht_cap.cap |= |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1569 | (value1 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1570 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 1571 | hdd_debug("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1572 | band_5g->vht_cap.cap, value, value1); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1573 | } |
| 1574 | |
| 1575 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1576 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1577 | * @hdd_ctx: HDD context |
| 1578 | * |
| 1579 | * Sets the DBS capability as per INI and firmware capability |
| 1580 | * |
| 1581 | * Return: None |
| 1582 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1583 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1584 | { |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1585 | uint8_t hw_dbs_capable = 0; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 1586 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
| 1587 | QDF_STATUS status; |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1588 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 1589 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 1590 | &dual_mac_feature); |
| 1591 | if (status != QDF_STATUS_SUCCESS) |
| 1592 | hdd_err("can't get dual_mac_feature value"); |
| 1593 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc)) { |
| 1594 | switch (dual_mac_feature) { |
| 1595 | case ENABLE_DBS_CXN_AND_SCAN: |
| 1596 | case ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF: |
| 1597 | case ENABLE_DBS_CXN_AND_DISABLE_SIMULTANEOUS_SCAN: |
| 1598 | hw_dbs_capable = 1; |
| 1599 | break; |
| 1600 | default: |
| 1601 | hw_dbs_capable = 0; |
| 1602 | break; |
| 1603 | } |
| 1604 | } |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1605 | sme_update_hw_dbs_capable(hdd_ctx->mac_handle, hw_dbs_capable); |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1606 | } |
| 1607 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1608 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1609 | struct wma_tgt_ht_cap *cfg) |
| 1610 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1611 | QDF_STATUS status; |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1612 | qdf_size_t value_len; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1613 | uint32_t value; |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1614 | uint8_t mpdu_density; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1615 | struct mlme_ht_capabilities_info ht_cap_info; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1616 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1617 | bool b_enable1x1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1618 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1619 | /* get the MPDU density */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1620 | status = ucfg_mlme_get_ht_mpdu_density(hdd_ctx->psoc, &mpdu_density); |
| 1621 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1622 | hdd_err("could not get HT MPDU Density"); |
| 1623 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1624 | } |
| 1625 | |
| 1626 | /* |
| 1627 | * MPDU density: |
| 1628 | * override user's setting if value is larger |
| 1629 | * than the one supported by target |
| 1630 | */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1631 | if (mpdu_density > cfg->mpdu_density) { |
| 1632 | status = ucfg_mlme_set_ht_mpdu_density(hdd_ctx->psoc, |
| 1633 | cfg->mpdu_density); |
| 1634 | if (QDF_IS_STATUS_ERROR(status)) |
| 1635 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1636 | } |
| 1637 | |
| 1638 | /* get the HT capability info */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1639 | 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] | 1640 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1641 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1642 | return; |
| 1643 | } |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1644 | |
| 1645 | /* check and update RX STBC */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1646 | if (ht_cap_info.rx_stbc && !cfg->ht_rx_stbc) |
| 1647 | ht_cap_info.rx_stbc = cfg->ht_rx_stbc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1648 | |
| 1649 | /* Set the LDPC capability */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1650 | ht_cap_info.adv_coding_cap = cfg->ht_rx_ldpc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1651 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1652 | if (ht_cap_info.short_gi_20_mhz && !cfg->ht_sgi_20) |
| 1653 | ht_cap_info.short_gi_20_mhz = cfg->ht_sgi_20; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1654 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1655 | if (ht_cap_info.short_gi_40_mhz && !cfg->ht_sgi_40) |
| 1656 | ht_cap_info.short_gi_40_mhz = cfg->ht_sgi_40; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1657 | |
| 1658 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1659 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1660 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1661 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &b_enable1x1); |
| 1662 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1663 | hdd_err("unable to get vht_enable2x2"); |
| 1664 | |
| 1665 | b_enable1x1 = b_enable1x1 && (cfg->num_rf_chains == 2); |
| 1666 | |
| 1667 | status = ucfg_mlme_set_vht_enable2x2(hdd_ctx->psoc, b_enable1x1); |
| 1668 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1669 | hdd_err("unable to set vht_enable2x2"); |
| 1670 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1671 | if (!b_enable1x1) { |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1672 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1673 | |
| 1674 | /* 1x1 */ |
| 1675 | /* Update Rx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1676 | status = ucfg_mlme_cfg_set_vht_rx_supp_data_rate( |
| 1677 | hdd_ctx->psoc, |
| 1678 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1679 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1680 | hdd_err("Failed to set rx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1681 | /* Update Tx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1682 | status = ucfg_mlme_cfg_set_vht_tx_supp_data_rate( |
| 1683 | hdd_ctx->psoc, |
| 1684 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1685 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1686 | hdd_err("Failed to set tx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1687 | } |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1688 | if (!(cfg->ht_tx_stbc && b_enable1x1)) |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1689 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1690 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1691 | 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] | 1692 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1693 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1694 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1695 | value_len = SIZE_OF_SUPPORTED_MCS_SET; |
| 1696 | if (ucfg_mlme_get_supported_mcs_set( |
| 1697 | hdd_ctx->psoc, mcs_set, |
| 1698 | &value_len) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1699 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1700 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1701 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1702 | |
| 1703 | if (b_enable1x1) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1704 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1705 | mcs_set[value] = |
| 1706 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1707 | |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1708 | status = ucfg_mlme_set_supported_mcs_set( |
| 1709 | hdd_ctx->psoc, |
| 1710 | mcs_set, |
| 1711 | (qdf_size_t)SIZE_OF_SUPPORTED_MCS_SET); |
| 1712 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1713 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1714 | } |
| 1715 | } |
| 1716 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1717 | } |
| 1718 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1719 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1720 | struct wma_tgt_vht_cap *cfg) |
| 1721 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1722 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1723 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1724 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1725 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1726 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1727 | struct wma_caps_per_phy caps_per_phy; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1728 | uint8_t val = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1729 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1730 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1731 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1732 | return; |
| 1733 | } |
| 1734 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1735 | status = ucfg_mlme_update_vht_cap(hdd_ctx->psoc, cfg); |
| 1736 | if (QDF_IS_STATUS_ERROR(status)) |
| 1737 | hdd_err("could not update vht capabilities"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1738 | |
| 1739 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1740 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1741 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1742 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1743 | else |
| 1744 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1745 | |
| 1746 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1747 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1748 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1749 | VHT_CAP_160_AND_80P80_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1750 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1751 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1752 | band_5g->vht_cap.cap |= |
| 1753 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1754 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1755 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1756 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1757 | VHT_CAP_160_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1758 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1759 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1760 | band_5g->vht_cap.cap |= |
| 1761 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1762 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1763 | } |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1764 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1765 | status = |
| 1766 | ucfg_mlme_cfg_get_vht_chan_width(hdd_ctx->psoc, &val); |
| 1767 | if (QDF_IS_STATUS_ERROR(status)) |
| 1768 | hdd_err("could not get channel_width"); |
| 1769 | |
| 1770 | val = QDF_MIN(val, ch_width); |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1771 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, val); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1772 | if (QDF_IS_STATUS_ERROR(status)) |
| 1773 | hdd_err("could not set the channel width"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1774 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1775 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1776 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1777 | hdd_debug("VHT RxLDPC capability is set"); |
| 1778 | } else { |
| 1779 | /* |
| 1780 | * Get the RX LDPC capability for the NON DBS |
| 1781 | * hardware mode for 5G band |
| 1782 | */ |
| 1783 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1784 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1785 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1786 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1787 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1788 | hdd_debug("VHT RX LDPC capability is set"); |
| 1789 | } |
| 1790 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1791 | |
| 1792 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1793 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1794 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1795 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1796 | |
| 1797 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1798 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1799 | |
| 1800 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1801 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1802 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1803 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1804 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1805 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1806 | |
| 1807 | band_5g->vht_cap.cap |= |
| 1808 | (cfg->vht_max_ampdu_len_exp << |
| 1809 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1810 | |
| 1811 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1812 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1813 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1814 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1815 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1816 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1817 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1818 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1819 | |
| 1820 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1821 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1822 | |
| 1823 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1824 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1825 | /** |
| 1826 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1827 | * @hdd_ctx: Pointer to the HDD context |
| 1828 | * |
| 1829 | * Auto-generate mac address using device serial number. |
| 1830 | * Keep the first 3 bytes of OUI as before and replace |
| 1831 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1832 | * |
| 1833 | * Return: 0 for success |
| 1834 | * Non zero failure code for errors |
| 1835 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1836 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1837 | { |
| 1838 | unsigned int serialno = 0; |
| 1839 | struct qdf_mac_addr mac_addr = { |
| 1840 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1841 | }; |
| 1842 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1843 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1844 | if (serialno == 0) |
| 1845 | return -EINVAL; |
| 1846 | |
| 1847 | serialno &= 0x00ffffff; |
| 1848 | |
| 1849 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1850 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1851 | mac_addr.bytes[5] = serialno & 0xff; |
| 1852 | |
| 1853 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1854 | return 0; |
| 1855 | } |
| 1856 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1857 | /** |
| 1858 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1859 | * configuration to cfg_ini in HDD |
| 1860 | * @hdd_ctx: Pointer to hdd_ctx |
| 1861 | * @cfg: target configuration |
| 1862 | * |
| 1863 | * Return: None |
| 1864 | */ |
| 1865 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1866 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1867 | struct wma_tgt_cfg *cfg) |
| 1868 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 1869 | ucfg_fwol_set_is_rate_limit_enabled(hdd_ctx->psoc, |
| 1870 | cfg->is_ra_rate_limit_enabled); |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1871 | } |
| 1872 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1873 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1874 | struct wma_tgt_cfg *cfg) |
| 1875 | { |
| 1876 | } |
| 1877 | #endif |
| 1878 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1879 | static void hdd_sar_target_config(struct hdd_context *hdd_ctx, |
| 1880 | struct wma_tgt_cfg *cfg) |
| 1881 | { |
| 1882 | hdd_ctx->sar_version = cfg->sar_version; |
| 1883 | } |
| 1884 | |
Jeff Johnson | 8abc593 | 2018-06-02 22:51:37 -0700 | [diff] [blame] | 1885 | 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] | 1886 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1887 | int ret; |
Jeff Johnson | ea70b94 | 2018-07-02 09:42:31 -0700 | [diff] [blame] | 1888 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1889 | uint8_t temp_band_cap, band_capability; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1890 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1891 | uint8_t antenna_mode; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1892 | uint8_t sub_20_chan_width; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1893 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1894 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1895 | bool bval = false; |
| 1896 | uint8_t value = 0; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1897 | uint32_t fine_time_meas_cap = 0; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1898 | |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1899 | if (!hdd_ctx) { |
| 1900 | hdd_err("HDD context is NULL"); |
| 1901 | return; |
| 1902 | } |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1903 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1904 | if (ret) { |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1905 | QDF_DEBUG_PANIC("Failed to create pdev; errno:%d", ret); |
| 1906 | return; |
| 1907 | } |
| 1908 | |
| 1909 | hdd_debug("New pdev has been created with pdev_id = %u", |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1910 | hdd_ctx->pdev->pdev_objmgr.wlan_pdev_id); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1911 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1912 | status = dispatcher_pdev_open(hdd_ctx->pdev); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1913 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1914 | QDF_DEBUG_PANIC("dispatcher pdev open failed; status:%d", |
| 1915 | status); |
| 1916 | return; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1917 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1918 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 1919 | status = hdd_component_pdev_open(hdd_ctx->pdev); |
| 1920 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1921 | QDF_DEBUG_PANIC("hdd component pdev open failed; status:%d", |
| 1922 | status); |
| 1923 | return; |
| 1924 | } |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1925 | cdp_pdev_set_ctrl_pdev(cds_get_context(QDF_MODULE_ID_SOC), |
| 1926 | cds_get_context(QDF_MODULE_ID_TXRX), |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1927 | (struct cdp_ctrl_objmgr_pdev *)hdd_ctx->pdev); |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1928 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1929 | wlan_pdev_set_dp_handle(hdd_ctx->pdev, |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1930 | cds_get_context(QDF_MODULE_ID_TXRX)); |
| 1931 | |
Will Huang | 0724417 | 2018-05-14 14:23:30 +0800 | [diff] [blame] | 1932 | hdd_objmgr_update_tgt_max_vdev_psoc(hdd_ctx, cfg->max_intf_count); |
| 1933 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1934 | ucfg_ipa_set_dp_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1935 | cds_get_context(QDF_MODULE_ID_SOC)); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1936 | ucfg_ipa_set_txrx_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1937 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1938 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1939 | hdd_softap_hard_start_xmit); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1940 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1941 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1942 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1943 | status = ucfg_mlme_get_sub_20_chan_width(hdd_ctx->psoc, |
| 1944 | &sub_20_chan_width); |
| 1945 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1946 | hdd_err("Failed to get sub_20_chan_width config"); |
| 1947 | return; |
| 1948 | } |
| 1949 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1950 | if (cds_cfg) { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1951 | if (sub_20_chan_width != |
| 1952 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1953 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1954 | cds_cfg->sub_20_channel_width = |
| 1955 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1956 | } else { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1957 | cds_cfg->sub_20_channel_width = sub_20_chan_width; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1958 | } |
| 1959 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1960 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1961 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 1962 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1963 | hdd_err("Failed to get MLME band capability"); |
| 1964 | return; |
| 1965 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1966 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1967 | /* first store the INI band capability */ |
| 1968 | temp_band_cap = band_capability; |
| 1969 | |
| 1970 | band_capability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1971 | hdd_ctx->is_fils_roaming_supported = |
| 1972 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1973 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1974 | hdd_ctx->config->is_11k_offload_supported = |
| 1975 | cfg->services.is_11k_offload_supported; |
| 1976 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1977 | /* |
| 1978 | * now overwrite the target band capability with INI |
| 1979 | * setting if INI setting is a subset |
| 1980 | */ |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1981 | if ((band_capability == BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1982 | (temp_band_cap != BAND_ALL)) |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1983 | band_capability = temp_band_cap; |
| 1984 | else if ((band_capability != BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1985 | (temp_band_cap != BAND_ALL) && |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1986 | (band_capability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1987 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1988 | } |
| 1989 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1990 | status = ucfg_mlme_set_band_capability(hdd_ctx->psoc, band_capability); |
| 1991 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1992 | hdd_err("Failed to set MLME Band Capability"); |
| 1993 | return; |
| 1994 | } |
| 1995 | |
| 1996 | hdd_ctx->curr_band = band_capability; |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1997 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1998 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1999 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 2000 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 2001 | } |
| 2002 | |
| 2003 | /* This can be extended to other configurations like ht, vht cap... */ |
| 2004 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 2005 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2006 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 2007 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2008 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 2009 | static struct qdf_mac_addr default_mac_addr = { |
| 2010 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 2011 | }; |
| 2012 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 2013 | &default_mac_addr)) { |
| 2014 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 2015 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 2016 | MAC_ADDRESS_STR, |
| 2017 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 2018 | intfMacAddr[0].bytes)); |
| 2019 | } else { |
| 2020 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 2021 | MAC_ADDRESS_STR, |
| 2022 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 2023 | intfMacAddr[0].bytes)); |
| 2024 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 2025 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2026 | } |
| 2027 | |
| 2028 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 2029 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2030 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2031 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 2032 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 2033 | sizeof(cfg->hw_bd_info)); |
| 2034 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 2035 | if (cfg->max_intf_count > CSR_ROAM_SESSION_MAX) { |
| 2036 | hdd_err("fw max vdevs (%u) > host max vdevs (%u); using %u", |
| 2037 | cfg->max_intf_count, CSR_ROAM_SESSION_MAX, |
| 2038 | CSR_ROAM_SESSION_MAX); |
| 2039 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 2040 | } else { |
| 2041 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 2042 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2043 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 2044 | hdd_sar_target_config(hdd_ctx, cfg); |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 2045 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 2046 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2047 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 2048 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 2049 | |
| 2050 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 2051 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2052 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 2053 | if (cfg->services.en_11ax) { |
| 2054 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 2055 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 2056 | } |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 2057 | hdd_update_tgt_twt_cap(hdd_ctx, cfg); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 2058 | |
| 2059 | hdd_update_vdev_nss(hdd_ctx); |
| 2060 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 2061 | hdd_update_hw_dbs_capable(hdd_ctx); |
gaurank kathpalia | 5fcefa9 | 2018-10-24 15:03:15 +0530 | [diff] [blame] | 2062 | hdd_ctx->dynamic_nss_chains_support = |
| 2063 | cfg->dynamic_nss_chains_support; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 2064 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, &fine_time_meas_cap); |
| 2065 | fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
| 2066 | status = ucfg_mlme_set_fine_time_meas_cap(hdd_ctx->psoc, |
| 2067 | fine_time_meas_cap); |
| 2068 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2069 | hdd_err("failed to set fine_time_meas_cap, 0x%x, ox%x", |
| 2070 | fine_time_meas_cap, cfg->fine_time_measurement_cap); |
| 2071 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 2072 | &fine_time_meas_cap); |
| 2073 | } |
| 2074 | |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 2075 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 2076 | hdd_debug("fine_time_meas_cap: 0x%x", fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2077 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2078 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 2079 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 2080 | hdd_err("unable to get vht_enable2x2"); |
| 2081 | |
| 2082 | antenna_mode = (bval == 0x01) ? |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 2083 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 2084 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2085 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2086 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2087 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 2088 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 2089 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 2090 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2091 | 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] | 2092 | &value); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2093 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2094 | status = false; |
| 2095 | hdd_err("set tx_bfee_ant_supp failed"); |
| 2096 | } |
| 2097 | |
| 2098 | if ((value > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2099 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2100 | !cfg->tx_bfee_8ss_enabled) { |
| 2101 | status = |
| 2102 | ucfg_mlme_cfg_set_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 2103 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF); |
| 2104 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2105 | status = false; |
| 2106 | hdd_err("set tx_bfee_ant_supp failed"); |
| 2107 | } |
| 2108 | } |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2109 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2110 | mac_handle = hdd_ctx->mac_handle; |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2111 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2112 | hdd_debug("txBFCsnValue %d", value); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2113 | |
| 2114 | /* |
| 2115 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2116 | */ |
| 2117 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2118 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2119 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2120 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 2121 | /* |
| 2122 | * This needs to be done after HDD pdev is created and stored since |
| 2123 | * it will access the HDD pdev object lock. |
| 2124 | */ |
| 2125 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2126 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2127 | /* Configure NAN datapath features */ |
| 2128 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2129 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2130 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 2131 | hdd_ctx->obss_scan_offload = cfg->services.obss_scan_offload; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2132 | status = sme_cfg_set_int(mac_handle, WNI_CFG_OBSS_DETECTION_OFFLOAD, |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2133 | cfg->obss_detection_offloaded); |
| 2134 | if (QDF_IS_STATUS_ERROR(status)) |
| 2135 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2136 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2137 | status = sme_cfg_set_int(mac_handle, |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2138 | WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD, |
| 2139 | cfg->obss_color_collision_offloaded); |
| 2140 | if (QDF_IS_STATUS_ERROR(status)) |
| 2141 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2142 | } |
| 2143 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2144 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2145 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2146 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2147 | struct hdd_ap_ctx *ap_ctx; |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2148 | bool dfs_disable_channel_switch = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2149 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2150 | if (!hdd_ctx) { |
| 2151 | hdd_info("Couldn't get hdd_ctx"); |
| 2152 | return true; |
| 2153 | } |
| 2154 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2155 | ucfg_mlme_get_dfs_disable_channel_switch(hdd_ctx->psoc, |
| 2156 | &dfs_disable_channel_switch); |
| 2157 | if (dfs_disable_channel_switch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2158 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2159 | hdd_ctx, dfs_disable_channel_switch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2160 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2161 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2162 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2163 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2164 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2165 | |
| 2166 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2167 | QDF_P2P_GO_MODE == adapter->device_mode) && |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2168 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2169 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2170 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2171 | true; |
| 2172 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2173 | adapter->session_id); |
bings | 6fb9bf6 | 2018-07-05 14:01:53 +0800 | [diff] [blame] | 2174 | if (adapter->txrx_vdev) |
| 2175 | cdp_fc_vdev_flush( |
| 2176 | cds_get_context(QDF_MODULE_ID_SOC), |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2177 | adapter->txrx_vdev); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2178 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2179 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2180 | |
| 2181 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2182 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2183 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2184 | bool hdd_is_valid_mac_address(const uint8_t *mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2185 | { |
| 2186 | int xdigit = 0; |
| 2187 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2188 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2189 | while (*mac_addr) { |
| 2190 | if (isxdigit(*mac_addr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2191 | xdigit++; |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2192 | } else if (':' == *mac_addr) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2193 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2194 | break; |
| 2195 | |
| 2196 | ++separator; |
| 2197 | } else { |
| 2198 | /* Invalid MAC found */ |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2199 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2200 | } |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2201 | ++mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2202 | } |
| 2203 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2204 | } |
| 2205 | |
| 2206 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2207 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2208 | * @dev: Handle to struct net_device to be updated. |
| 2209 | * |
| 2210 | * Return: None |
| 2211 | */ |
| 2212 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2213 | { |
| 2214 | dev->header_ops = NULL; |
| 2215 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2216 | dev->hard_header_len = ETH_HLEN; |
| 2217 | dev->mtu = ETH_DATA_LEN; |
| 2218 | dev->addr_len = ETH_ALEN; |
| 2219 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2220 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2221 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2222 | |
| 2223 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2224 | } |
| 2225 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2226 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2227 | /** |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2228 | * hdd_mon_turn_off_ps_and_wow() - Update monitor mode struct net_device. |
| 2229 | * @hdd_ctx: Pointer to HDD context. |
| 2230 | * |
| 2231 | * Return: None |
| 2232 | */ |
| 2233 | static void hdd_mon_turn_off_ps_and_wow(struct hdd_context *hdd_ctx) |
| 2234 | { |
| 2235 | ucfg_pmo_set_power_save_mode(hdd_ctx->psoc, PS_NOT_SUPPORTED); |
| 2236 | ucfg_pmo_set_wow_enable(hdd_ctx->psoc, PMO_WOW_DISABLE_BOTH); |
| 2237 | } |
| 2238 | |
| 2239 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2240 | * __hdd__mon_open() - HDD Open function |
| 2241 | * @dev: Pointer to net_device structure |
| 2242 | * |
| 2243 | * This is called in response to ifconfig up |
| 2244 | * |
| 2245 | * Return: 0 for success; non-zero for failure |
| 2246 | */ |
| 2247 | static int __hdd_mon_open(struct net_device *dev) |
| 2248 | { |
| 2249 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2250 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2251 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2252 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2253 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2254 | |
| 2255 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2256 | if (ret) |
| 2257 | return ret; |
| 2258 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2259 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2260 | |
| 2261 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 2262 | ret = hdd_psoc_idle_restart(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2263 | if (ret) { |
| 2264 | hdd_err("Failed to start WLAN modules return"); |
| 2265 | return ret; |
| 2266 | } |
| 2267 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2268 | |
| 2269 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2270 | ret = hdd_start_adapter(adapter); |
| 2271 | if (ret) { |
| 2272 | hdd_err("Failed to start adapter :%d", |
| 2273 | adapter->device_mode); |
| 2274 | return ret; |
| 2275 | } |
| 2276 | hdd_err("hdd_start_adapters() successful !"); |
| 2277 | } |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2278 | hdd_mon_turn_off_ps_and_wow(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2279 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2280 | } |
| 2281 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2282 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2283 | |
| 2284 | if (!ret) |
| 2285 | ret = hdd_enable_monitor_mode(dev); |
| 2286 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2287 | return ret; |
| 2288 | } |
| 2289 | |
| 2290 | /** |
| 2291 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2292 | * @dev: Pointer to net_device structure |
| 2293 | * |
| 2294 | * This is called in response to ifconfig up |
| 2295 | * |
| 2296 | * Return: 0 for success; non-zero for failure |
| 2297 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2298 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2299 | { |
| 2300 | int ret; |
| 2301 | |
| 2302 | cds_ssr_protect(__func__); |
| 2303 | ret = __hdd_mon_open(dev); |
| 2304 | cds_ssr_unprotect(__func__); |
| 2305 | |
| 2306 | return ret; |
| 2307 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2308 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2309 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2310 | static QDF_STATUS |
| 2311 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2312 | { |
| 2313 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2314 | QDF_STATUS status; |
Krunal Soni | 13b50f8 | 2018-09-27 12:37:03 -0700 | [diff] [blame] | 2315 | uint32_t channel_select_logic_conc = 0; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2316 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2317 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2318 | |
| 2319 | if (!hdd_ctx) { |
| 2320 | hdd_err("HDD context is NULL"); |
| 2321 | return QDF_STATUS_E_FAILURE; |
| 2322 | } |
| 2323 | |
| 2324 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2325 | if (!policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc)) |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2326 | return QDF_STATUS_SUCCESS; |
| 2327 | |
| 2328 | cfg.scan_config = 0; |
| 2329 | cfg.fw_mode_config = 0; |
| 2330 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2331 | status = |
Krunal Soni | 13b50f8 | 2018-09-27 12:37:03 -0700 | [diff] [blame] | 2332 | ucfg_policy_mgr_get_chnl_select_plcy(hdd_ctx->psoc, |
| 2333 | &channel_select_logic_conc); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2334 | if (status != QDF_STATUS_SUCCESS) { |
| 2335 | hdd_err("ucfg_policy_mgr_get_chnl_select_plcy failed, use def"); |
| 2336 | return status; |
| 2337 | } |
| 2338 | status = |
| 2339 | ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 2340 | &dual_mac_feature); |
| 2341 | if (status != QDF_STATUS_SUCCESS) { |
| 2342 | hdd_err("ucfg_policy_mgr_get_dual_mac_feature failed, use def"); |
| 2343 | return status; |
| 2344 | } |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2345 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2346 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2347 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2348 | hdd_ctx->psoc, &cfg.scan_config, |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2349 | &cfg.fw_mode_config, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2350 | dual_mac_feature, |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2351 | channel_select_logic_conc); |
| 2352 | |
| 2353 | if (status != QDF_STATUS_SUCCESS) { |
| 2354 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2355 | status); |
| 2356 | return status; |
| 2357 | } |
| 2358 | } |
| 2359 | |
| 2360 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2361 | cfg.scan_config, cfg.fw_mode_config); |
| 2362 | |
| 2363 | status = sme_soc_set_dual_mac_config(cfg); |
| 2364 | if (status != QDF_STATUS_SUCCESS) { |
| 2365 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2366 | return status; |
| 2367 | } |
| 2368 | |
| 2369 | return QDF_STATUS_SUCCESS; |
| 2370 | } |
| 2371 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2372 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2373 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2374 | * @adapter: pointer to HDD adapter |
| 2375 | * |
| 2376 | * This function is called to start the device specific adapter for |
| 2377 | * the mode passed in the adapter's device_mode. |
| 2378 | * |
| 2379 | * Return: 0 for success; non-zero for failure |
| 2380 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2381 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2382 | { |
| 2383 | |
| 2384 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2385 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2386 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2387 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2388 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2389 | |
| 2390 | switch (device_mode) { |
| 2391 | case QDF_P2P_CLIENT_MODE: |
| 2392 | case QDF_P2P_DEVICE_MODE: |
| 2393 | case QDF_OCB_MODE: |
| 2394 | case QDF_STA_MODE: |
| 2395 | case QDF_MONITOR_MODE: |
| 2396 | ret = hdd_start_station_adapter(adapter); |
| 2397 | if (ret) |
| 2398 | goto err_start_adapter; |
Alok Kumar | 81e1d73 | 2018-09-04 11:10:36 +0530 | [diff] [blame] | 2399 | |
| 2400 | hdd_nud_ignore_tracking(adapter, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2401 | break; |
| 2402 | case QDF_P2P_GO_MODE: |
| 2403 | case QDF_SAP_MODE: |
| 2404 | ret = hdd_start_ap_adapter(adapter); |
| 2405 | if (ret) |
| 2406 | goto err_start_adapter; |
| 2407 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2408 | case QDF_IBSS_MODE: |
| 2409 | /* |
| 2410 | * For IBSS interface is initialized as part of |
| 2411 | * hdd_init_station_mode() |
| 2412 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2413 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2414 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2415 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2416 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2417 | default: |
| 2418 | hdd_err("Invalid session type %d", device_mode); |
| 2419 | QDF_ASSERT(0); |
| 2420 | goto err_start_adapter; |
| 2421 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2422 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2423 | if (hdd_set_fw_params(adapter)) |
| 2424 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2425 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2426 | if (adapter->session_id != HDD_SESSION_ID_INVALID) { |
| 2427 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2428 | if (ret < 0) { |
| 2429 | hdd_err("Failed to register frames - ret %d", ret); |
| 2430 | goto err_start_adapter; |
| 2431 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2432 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2433 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2434 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2435 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2436 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2437 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2438 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2439 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2440 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2441 | err_start_adapter: |
| 2442 | return -EINVAL; |
| 2443 | } |
| 2444 | |
| 2445 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2446 | * hdd_enable_power_management() - API to Enable Power Management |
| 2447 | * |
| 2448 | * API invokes Bus Interface Layer power management functionality |
| 2449 | * |
| 2450 | * Return: None |
| 2451 | */ |
| 2452 | static void hdd_enable_power_management(void) |
| 2453 | { |
| 2454 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2455 | |
| 2456 | if (!hif_ctx) { |
| 2457 | hdd_err("Bus Interface Context is Invalid"); |
| 2458 | return; |
| 2459 | } |
| 2460 | |
| 2461 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2462 | } |
| 2463 | |
| 2464 | /** |
| 2465 | * hdd_disable_power_management() - API to disable Power Management |
| 2466 | * |
| 2467 | * API disable Bus Interface Layer Power management functionality |
| 2468 | * |
| 2469 | * Return: None |
| 2470 | */ |
| 2471 | static void hdd_disable_power_management(void) |
| 2472 | { |
| 2473 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2474 | |
| 2475 | if (!hif_ctx) { |
| 2476 | hdd_err("Bus Interface Context is Invalid"); |
| 2477 | return; |
| 2478 | } |
| 2479 | |
| 2480 | hif_disable_power_management(hif_ctx); |
| 2481 | } |
| 2482 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2483 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2484 | { |
| 2485 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2486 | size_t target_hw_name_len; |
| 2487 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2488 | uint8_t *buf; |
| 2489 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2490 | |
| 2491 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2492 | if (!hif_sc) { |
| 2493 | hdd_err("HIF context is NULL"); |
| 2494 | return; |
| 2495 | } |
| 2496 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2497 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2498 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2499 | &target_hw_name); |
| 2500 | |
| 2501 | if (hdd_ctx->target_hw_name) |
| 2502 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2503 | |
| 2504 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2505 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2506 | if (hdd_ctx->target_hw_name) |
| 2507 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2508 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2509 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2510 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2511 | if (buf) { |
| 2512 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2513 | hdd_info("%s", buf); |
| 2514 | qdf_mem_free(buf); |
| 2515 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2516 | } |
| 2517 | |
| 2518 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2519 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2520 | * @hdd_ctx: Pointer to hdd context |
| 2521 | * |
| 2522 | * Return: none |
| 2523 | */ |
| 2524 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2525 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2526 | { |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2527 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM] = {0}; |
| 2528 | qdf_size_t out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2529 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2530 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2531 | |
| 2532 | if (NULL == hdd_ctx) |
| 2533 | return; |
| 2534 | |
| 2535 | if (NULL == hdd_ctx->config) { |
| 2536 | /* Do nothing if hdd_ctx is invalid */ |
| 2537 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2538 | return; |
| 2539 | } |
| 2540 | |
| 2541 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2542 | |
| 2543 | if (!cds_ctx) { |
| 2544 | hdd_err("Invalid CDS Context"); |
| 2545 | return; |
| 2546 | } |
| 2547 | |
| 2548 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2549 | switch (i) { |
| 2550 | case OL_TX_WMM_AC_BE: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2551 | qdf_uint8_array_parse( |
| 2552 | cfg_get(hdd_ctx->psoc, |
| 2553 | CFG_DP_ENABLE_TX_SCHED_WRR_BE), |
| 2554 | tx_sched_wrr_param, |
| 2555 | sizeof(tx_sched_wrr_param), |
| 2556 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2557 | break; |
| 2558 | case OL_TX_WMM_AC_BK: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2559 | qdf_uint8_array_parse( |
| 2560 | cfg_get(hdd_ctx->psoc, |
| 2561 | CFG_DP_ENABLE_TX_SCHED_WRR_BK), |
| 2562 | tx_sched_wrr_param, |
| 2563 | sizeof(tx_sched_wrr_param), |
| 2564 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2565 | break; |
| 2566 | case OL_TX_WMM_AC_VI: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2567 | qdf_uint8_array_parse( |
| 2568 | cfg_get(hdd_ctx->psoc, |
| 2569 | CFG_DP_ENABLE_TX_SCHED_WRR_VI), |
| 2570 | tx_sched_wrr_param, |
| 2571 | sizeof(tx_sched_wrr_param), |
| 2572 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2573 | break; |
| 2574 | case OL_TX_WMM_AC_VO: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2575 | qdf_uint8_array_parse( |
| 2576 | cfg_get(hdd_ctx->psoc, |
| 2577 | CFG_DP_ENABLE_TX_SCHED_WRR_VO), |
| 2578 | tx_sched_wrr_param, |
| 2579 | sizeof(tx_sched_wrr_param), |
| 2580 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2581 | break; |
| 2582 | default: |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2583 | break; |
| 2584 | } |
| 2585 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2586 | if (out_size == TX_SCHED_WRR_PARAMS_NUM) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2587 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2588 | tx_sched_wrr_param[0]; |
| 2589 | cds_ctx->ac_specs[i].credit_threshold = |
| 2590 | tx_sched_wrr_param[1]; |
| 2591 | cds_ctx->ac_specs[i].send_limit = |
| 2592 | tx_sched_wrr_param[2]; |
| 2593 | cds_ctx->ac_specs[i].credit_reserve = |
| 2594 | tx_sched_wrr_param[3]; |
| 2595 | cds_ctx->ac_specs[i].discard_weight = |
| 2596 | tx_sched_wrr_param[4]; |
| 2597 | } |
| 2598 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2599 | out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2600 | } |
| 2601 | } |
| 2602 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2603 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2604 | const size_t version_len, uint8_t *version) |
| 2605 | { |
| 2606 | uint32_t size; |
| 2607 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2608 | |
| 2609 | if (!hdd_ctx) { |
| 2610 | hdd_err("Invalid context, HDD context is null"); |
| 2611 | return 0; |
| 2612 | } |
| 2613 | |
Ashish Kumar Dhanotiya | 7353f88 | 2018-05-15 12:50:19 +0530 | [diff] [blame] | 2614 | if (!version || version_len == 0) { |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2615 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2616 | return 0; |
| 2617 | } |
| 2618 | |
| 2619 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2620 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2621 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2622 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2623 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2624 | |
| 2625 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2626 | "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] | 2627 | QWLAN_VERSIONSTR, |
| 2628 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2629 | hdd_ctx->target_hw_name, |
| 2630 | hdd_ctx->hw_bd_info.bdf_version, |
| 2631 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2632 | hdd_ctx->hw_bd_info.customer_id, |
| 2633 | hdd_ctx->hw_bd_info.project_id, |
| 2634 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2635 | |
| 2636 | return size; |
| 2637 | } |
| 2638 | |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2639 | int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, |
| 2640 | struct sap_config *sap_config) |
| 2641 | { |
| 2642 | uint8_t preamble = 0, nss = 0, rix = 0; |
| 2643 | int ret; |
| 2644 | mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle; |
| 2645 | |
| 2646 | if (!sap_config) { |
| 2647 | if (!sme_is_feature_supported_by_fw(DOT11AX)) { |
| 2648 | hdd_err("Target does not support 11ax"); |
| 2649 | return -EIO; |
| 2650 | } |
| 2651 | } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax && |
| 2652 | sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) { |
| 2653 | hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d", |
| 2654 | sap_config->SapHw_mode, sap_config->channel); |
| 2655 | return -EIO; |
| 2656 | } |
| 2657 | |
| 2658 | if (set_value != 0xff) { |
| 2659 | rix = RC_2_RATE_IDX_11AX(set_value); |
| 2660 | preamble = WMI_RATE_PREAMBLE_HE; |
| 2661 | nss = HT_RC_2_STREAMS_11AX(set_value); |
| 2662 | |
| 2663 | set_value = hdd_assemble_rate_code(preamble, nss, rix); |
| 2664 | } else { |
| 2665 | ret = sme_set_auto_rate_he_ltf(mac_handle, adapter->session_id, |
| 2666 | QCA_WLAN_HE_LTF_AUTO); |
| 2667 | } |
| 2668 | |
| 2669 | hdd_info("SET_11AX_RATE val %d rix %d preamble %x nss %d", |
| 2670 | set_value, rix, preamble, nss); |
| 2671 | |
| 2672 | ret = wma_cli_set_command(adapter->session_id, |
| 2673 | WMI_VDEV_PARAM_FIXED_RATE, |
| 2674 | set_value, VDEV_CMD); |
| 2675 | |
| 2676 | return ret; |
| 2677 | } |
| 2678 | |
| 2679 | int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate) |
| 2680 | { |
| 2681 | int set_value; |
| 2682 | |
| 2683 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 2684 | set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble); |
| 2685 | else |
| 2686 | set_value = (preamble << 6) | (nss << 4) | rate; |
| 2687 | |
| 2688 | return set_value; |
| 2689 | } |
| 2690 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2691 | #ifdef FEATURE_WLAN_WAPI |
| 2692 | /** |
| 2693 | * hdd_wapi_security_sta_exist() - return wapi security sta exist or not |
| 2694 | * |
| 2695 | * This API returns the wapi security station exist or not |
| 2696 | * |
| 2697 | * Return: true - wapi security station exist |
| 2698 | */ |
| 2699 | static bool hdd_wapi_security_sta_exist(void) |
| 2700 | { |
| 2701 | struct hdd_adapter *adapter = NULL; |
| 2702 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2703 | |
| 2704 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2705 | if ((adapter->device_mode == QDF_STA_MODE) && |
| 2706 | adapter->wapi_info.wapi_mode && |
| 2707 | (adapter->wapi_info.wapi_auth_mode != WAPI_AUTH_MODE_OPEN)) |
| 2708 | return true; |
| 2709 | } |
| 2710 | return false; |
| 2711 | } |
| 2712 | #else |
| 2713 | static bool hdd_wapi_security_sta_exist(void) |
| 2714 | { |
| 2715 | return false; |
| 2716 | } |
| 2717 | #endif |
| 2718 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2719 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2720 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2721 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2722 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2723 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2724 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2725 | |
| 2726 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2727 | if (!adapter) { |
| 2728 | hdd_err("Adapter is NULL"); |
| 2729 | return PM_MAX_NUM_OF_MODE; |
| 2730 | } |
| 2731 | |
| 2732 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2733 | adapter->device_mode); |
| 2734 | } |
| 2735 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2736 | static void hdd_register_policy_manager_callback( |
| 2737 | struct wlan_objmgr_psoc *psoc) |
| 2738 | { |
| 2739 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2740 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2741 | qdf_mem_zero(&hdd_cbacks, sizeof(hdd_cbacks)); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2742 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2743 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2744 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2745 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2746 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2747 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2748 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2749 | hdd_cbacks.hdd_wapi_security_sta_exist = |
| 2750 | hdd_wapi_security_sta_exist; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2751 | if (QDF_STATUS_SUCCESS != |
| 2752 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2753 | hdd_err("HDD callback registration with policy manager failed"); |
| 2754 | } |
| 2755 | } |
| 2756 | #else |
| 2757 | static void hdd_register_policy_manager_callback( |
| 2758 | struct wlan_objmgr_psoc *psoc) |
| 2759 | { |
| 2760 | } |
| 2761 | #endif |
| 2762 | |
jiad | ff1ac13 | 2018-11-26 16:27:48 +0800 | [diff] [blame] | 2763 | #ifdef WLAN_FEATURE_NAN_DATAPATH |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2764 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2765 | { |
| 2766 | struct nan_callbacks cb_obj = {0}; |
| 2767 | |
| 2768 | cb_obj.ndi_open = hdd_ndi_open; |
| 2769 | cb_obj.ndi_close = hdd_ndi_close; |
| 2770 | cb_obj.ndi_start = hdd_ndi_start; |
| 2771 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2772 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2773 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2774 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2775 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2776 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2777 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2778 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2779 | os_if_nan_register_hdd_callbacks(hdd_ctx->psoc, &cb_obj); |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2780 | } |
jiad | ff1ac13 | 2018-11-26 16:27:48 +0800 | [diff] [blame] | 2781 | #else |
| 2782 | static inline void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
| 2783 | { |
| 2784 | } |
| 2785 | #endif |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2786 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2787 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2788 | /** |
| 2789 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2790 | * @hdd_ctx: the global HDD context |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2791 | * @is_ssr: true if SSR is in progress |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2792 | * |
| 2793 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2794 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2795 | * |
| 2796 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2797 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2798 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2799 | * fixed. |
| 2800 | * |
| 2801 | * Return: None |
| 2802 | */ |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2803 | 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] | 2804 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2805 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2806 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2807 | wlan_objmgr_psoc_check_for_peer_leaks(hdd_ctx->psoc); |
| 2808 | wlan_objmgr_psoc_check_for_vdev_leaks(hdd_ctx->psoc); |
| 2809 | wlan_objmgr_psoc_check_for_pdev_leaks(hdd_ctx->psoc); |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2810 | |
| 2811 | /* many adapter resources are not freed by design during SSR */ |
| 2812 | if (is_ssr) |
| 2813 | return; |
| 2814 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2815 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2816 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2817 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2818 | } |
| 2819 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2820 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2821 | #else |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2822 | static inline void hdd_check_for_leaks(struct hdd_context *hdd_ctx, bool is_ssr) |
| 2823 | { } |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2824 | |
| 2825 | #define hdd_debug_domain_set(domain) |
| 2826 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2827 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2828 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2829 | * hdd_update_country_code - Update country code |
| 2830 | * @hdd_ctx: HDD context |
| 2831 | * |
| 2832 | * Update country code based on module parameter country_code |
| 2833 | * |
| 2834 | * Return: 0 on success and errno on failure |
| 2835 | */ |
| 2836 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2837 | { |
| 2838 | if (!country_code) |
| 2839 | return 0; |
| 2840 | |
| 2841 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2842 | } |
| 2843 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2844 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2845 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2846 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2847 | qdf_device_t qdf_dev; |
| 2848 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2849 | bool unint = false; |
| 2850 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2851 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2852 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2853 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2854 | if (!qdf_dev) { |
| 2855 | hdd_err("QDF Device Context is Invalid return"); |
| 2856 | return -EINVAL; |
| 2857 | } |
| 2858 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 2859 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2860 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2861 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2862 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2863 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2864 | hdd_debug("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2865 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2866 | return 0; |
| 2867 | } |
| 2868 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2869 | hdd_ctx->start_modules_in_progress = true; |
| 2870 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2871 | switch (hdd_ctx->driver_status) { |
| 2872 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2873 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2874 | unint = true; |
| 2875 | /* Fall through dont add break here */ |
| 2876 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2877 | hdd_info("Wlan transitioning (CLOSED -> ENABLED)"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2878 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2879 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2880 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2881 | if (!reinit && !unint) { |
| 2882 | ret = pld_power_on(qdf_dev->dev); |
| 2883 | if (ret) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2884 | hdd_err("Failed to power up device; errno:%d", |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2885 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2886 | goto release_lock; |
| 2887 | } |
| 2888 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2889 | |
| 2890 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2891 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2892 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2893 | qdf_dev->bus_type, |
| 2894 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2895 | HIF_ENABLE_TYPE_PROBE); |
| 2896 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2897 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2898 | goto power_down; |
| 2899 | } |
| 2900 | |
| 2901 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2902 | if (!hif_ctx) { |
| 2903 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2904 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2905 | goto power_down; |
| 2906 | } |
| 2907 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2908 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2909 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2910 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2911 | status); |
| 2912 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2913 | goto hif_close; |
| 2914 | } |
| 2915 | |
jitiphil | 4c256a3 | 2018-09-07 08:51:52 +0530 | [diff] [blame] | 2916 | ucfg_ipa_component_config_update(hdd_ctx->psoc); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2917 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2918 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2919 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2920 | status = hdd_component_psoc_open(hdd_ctx->psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2921 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2922 | hdd_err("Failed to Open legacy components; status: %d", |
| 2923 | status); |
| 2924 | ret = qdf_status_to_os_return(status); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 2925 | goto cds_free; |
| 2926 | } |
| 2927 | |
| 2928 | ret = hdd_update_config(hdd_ctx); |
| 2929 | if (ret) { |
| 2930 | hdd_err("Failed to update configuration; errno: %d", |
| 2931 | ret); |
| 2932 | goto cds_free; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2933 | } |
| 2934 | |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 2935 | status = wbuff_module_init(); |
| 2936 | if (QDF_IS_STATUS_ERROR(status)) |
| 2937 | hdd_err("WBUFF init unsuccessful; status: %d", status); |
| 2938 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2939 | status = cds_open(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2940 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2941 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2942 | ret = qdf_status_to_os_return(status); |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 2943 | goto psoc_close; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2944 | } |
| 2945 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 2946 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 2947 | |
Manjunathappa Prakash | b6b4ff1 | 2018-06-04 12:32:33 -0700 | [diff] [blame] | 2948 | if (hdd_ctx->config->rx_thread_affinity_mask) |
| 2949 | cds_set_rx_thread_cpu_mask( |
| 2950 | hdd_ctx->config->rx_thread_affinity_mask); |
| 2951 | |
| 2952 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2953 | ret = hdd_update_components_config(hdd_ctx); |
| 2954 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2955 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2956 | ret); |
| 2957 | goto close; |
| 2958 | } |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2959 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2960 | status = cds_dp_open(hdd_ctx->psoc); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2961 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2962 | hdd_err("Failed to Open cds post open; status: %d", |
| 2963 | status); |
| 2964 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2965 | goto close; |
| 2966 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2967 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2968 | ret = hdd_register_cb(hdd_ctx); |
| 2969 | if (ret) { |
| 2970 | hdd_err("Failed to register HDD callbacks!"); |
| 2971 | goto cds_txrx_free; |
| 2972 | } |
| 2973 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2974 | /* |
| 2975 | * NAN compoenet requires certian operations like, open adapter, |
| 2976 | * close adapter, etc. to be initiated by HDD, for those |
| 2977 | * register HDD callbacks with UMAC's NAN componenet. |
| 2978 | */ |
| 2979 | hdd_nan_register_callbacks(hdd_ctx); |
| 2980 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2981 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2982 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2983 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2984 | ret = qdf_status_to_os_return(status); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2985 | goto deregister_cb; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2986 | } |
| 2987 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2988 | hdd_register_policy_manager_callback( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2989 | hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2990 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2991 | hdd_sysfs_create_driver_root_obj(); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2992 | hdd_sysfs_create_version_interface(hdd_ctx->psoc); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2993 | hdd_sysfs_create_powerstats_interface(); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2994 | hdd_update_hw_sw_info(hdd_ctx); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2995 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2996 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2997 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2998 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2999 | break; |
| 3000 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 3001 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 3002 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 3003 | if (ret) { |
| 3004 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 3005 | goto destroy_driver_sysfs; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3006 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 3007 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 3008 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3009 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3010 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3011 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3012 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 3013 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3014 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 3015 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3016 | goto release_lock; |
| 3017 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3018 | |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 3019 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 3020 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 3021 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 3022 | hdd_ctx->start_modules_in_progress = false; |
Dustin Brown | ad698ae | 2018-09-05 17:19:30 -0700 | [diff] [blame] | 3023 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3024 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3025 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3026 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3027 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3028 | return 0; |
| 3029 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 3030 | destroy_driver_sysfs: |
| 3031 | hdd_sysfs_destroy_powerstats_interface(); |
| 3032 | hdd_sysfs_destroy_version_interface(); |
| 3033 | hdd_sysfs_destroy_driver_root_obj(); |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 3034 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3035 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 3036 | deregister_cb: |
| 3037 | hdd_deregister_cb(hdd_ctx); |
| 3038 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 3039 | cds_txrx_free: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3040 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 3041 | |
| 3042 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 3043 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 3044 | dispatcher_pdev_close(hdd_ctx->pdev); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 3045 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 3046 | } |
| 3047 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3048 | cds_dp_close(hdd_ctx->psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3049 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3050 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3051 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3052 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 3053 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3054 | cds_close(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3055 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 3056 | psoc_close: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3057 | hdd_component_psoc_close(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 3058 | cds_deinit_ini_config(); |
| 3059 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 3060 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3061 | ol_cds_free(); |
| 3062 | |
| 3063 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 3064 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 3065 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3066 | power_down: |
| 3067 | if (!reinit && !unint) |
| 3068 | pld_power_off(qdf_dev->dev); |
| 3069 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 3070 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3071 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Abhinav Kumar | 7ae9b7b | 2017-12-19 15:11:54 +0530 | [diff] [blame] | 3072 | if (hdd_ctx->target_hw_name) { |
| 3073 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 3074 | hdd_ctx->target_hw_name = NULL; |
| 3075 | } |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 3076 | |
| 3077 | hdd_check_for_leaks(hdd_ctx, reinit); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 3078 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 3079 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3080 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3081 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 3082 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3083 | } |
| 3084 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3085 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3086 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3087 | { |
| 3088 | int ret = os_if_wifi_pos_register_nl(); |
| 3089 | |
| 3090 | if (ret) |
| 3091 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 3092 | |
| 3093 | return ret; |
| 3094 | } |
| 3095 | |
| 3096 | static int hdd_deactivate_wifi_pos(void) |
| 3097 | { |
| 3098 | int ret = os_if_wifi_pos_deregister_nl(); |
| 3099 | |
| 3100 | if (ret) |
| 3101 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 3102 | |
| 3103 | return ret; |
| 3104 | } |
| 3105 | |
| 3106 | /** |
| 3107 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 3108 | * @hdd_ctx: hdd context |
| 3109 | * |
| 3110 | * Return: status of operation |
| 3111 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3112 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3113 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3114 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3115 | uint16_t neighbor_scan_max_chan_time; |
| 3116 | uint16_t neighbor_scan_min_chan_time; |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3117 | |
| 3118 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 3119 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 3120 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 3121 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 3122 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 3123 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3124 | ucfg_mlme_get_neighbor_scan_max_chan_time(psoc, |
| 3125 | &neighbor_scan_max_chan_time); |
| 3126 | ucfg_mlme_get_neighbor_scan_min_chan_time(psoc, |
| 3127 | &neighbor_scan_min_chan_time); |
| 3128 | wifi_pos_set_dwell_time_min(psoc, neighbor_scan_min_chan_time); |
| 3129 | wifi_pos_set_dwell_time_max(psoc, neighbor_scan_max_chan_time); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3130 | } |
| 3131 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3132 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3133 | { |
| 3134 | return oem_activate_service(hdd_ctx); |
| 3135 | } |
| 3136 | |
| 3137 | static int hdd_deactivate_wifi_pos(void) |
| 3138 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 3139 | return oem_deactivate_service(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3140 | } |
| 3141 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3142 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3143 | { |
| 3144 | } |
| 3145 | #endif |
| 3146 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3147 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3148 | * __hdd_open() - HDD Open function |
| 3149 | * @dev: Pointer to net_device structure |
| 3150 | * |
| 3151 | * This is called in response to ifconfig up |
| 3152 | * |
| 3153 | * Return: 0 for success; non-zero for failure |
| 3154 | */ |
| 3155 | static int __hdd_open(struct net_device *dev) |
| 3156 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3157 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3158 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3159 | int ret; |
| 3160 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3161 | hdd_enter_dev(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3162 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3163 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3164 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 3165 | /* Nothing to be done if device is unloading */ |
| 3166 | if (cds_is_driver_unloading()) { |
| 3167 | hdd_err("Driver is unloading can not open the hdd"); |
| 3168 | return -EBUSY; |
| 3169 | } |
| 3170 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 3171 | if (cds_is_driver_recovering()) { |
| 3172 | hdd_err("WLAN is currently recovering; Please try again."); |
| 3173 | return -EBUSY; |
| 3174 | } |
| 3175 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3176 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 3177 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 3178 | return -EBUSY; |
| 3179 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3180 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3181 | mutex_lock(&hdd_init_deinit_lock); |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 3182 | hdd_start_driver_ops_timer(HDD_DRV_OP_IFF_UP); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3183 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3184 | /* |
| 3185 | * This scenario can be hit in cases where in the wlan driver after |
| 3186 | * registering the netdevices and there is a failure in driver |
| 3187 | * initialization. So return error gracefully because the netdevices |
| 3188 | * will be de-registered as part of the load failure. |
| 3189 | */ |
| 3190 | |
| 3191 | if (!cds_is_driver_loaded()) { |
| 3192 | hdd_err("Failed to start the wlan driver!!"); |
| 3193 | ret = -EIO; |
| 3194 | goto err_hdd_hdd_init_deinit_lock; |
| 3195 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3196 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 3197 | ret = hdd_psoc_idle_restart(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3198 | if (ret) { |
| 3199 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3200 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3201 | } |
| 3202 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3203 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3204 | ret = hdd_start_adapter(adapter); |
| 3205 | if (ret) { |
| 3206 | hdd_err("Failed to start adapter :%d", |
| 3207 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3208 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3209 | } |
| 3210 | } |
| 3211 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3212 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3213 | 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] | 3214 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3215 | /* Enable TX queues only when we are connected */ |
| 3216 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3217 | WLAN_START_ALL_NETIF_QUEUE, |
| 3218 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3219 | } |
| 3220 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3221 | /* Enable carrier and transmit queues for NDI */ |
| 3222 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3223 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3224 | wlan_hdd_netif_queue_control(adapter, |
| 3225 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3226 | WLAN_CONTROL_PATH); |
| 3227 | } |
| 3228 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3229 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3230 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3231 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3232 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3233 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3234 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3235 | return ret; |
| 3236 | } |
| 3237 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3238 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3239 | /** |
| 3240 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 3241 | * @dev: Pointer to net_device structure |
| 3242 | * |
| 3243 | * This is called in response to ifconfig up |
| 3244 | * |
| 3245 | * Return: 0 for success; non-zero for failure |
| 3246 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3247 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3248 | { |
| 3249 | int ret; |
| 3250 | |
| 3251 | cds_ssr_protect(__func__); |
| 3252 | ret = __hdd_open(dev); |
| 3253 | cds_ssr_unprotect(__func__); |
| 3254 | |
| 3255 | return ret; |
| 3256 | } |
| 3257 | |
| 3258 | /** |
| 3259 | * __hdd_stop() - HDD stop function |
| 3260 | * @dev: Pointer to net_device structure |
| 3261 | * |
| 3262 | * This is called in response to ifconfig down |
| 3263 | * |
| 3264 | * Return: 0 for success; non-zero for failure |
| 3265 | */ |
| 3266 | static int __hdd_stop(struct net_device *dev) |
| 3267 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3268 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3269 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3270 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3271 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3272 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3273 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3274 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3275 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3276 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3277 | |
| 3278 | ret = wlan_hdd_validate_context(hdd_ctx); |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3279 | if (ret) { |
| 3280 | set_bit(DOWN_DURING_SSR, &adapter->event_flags); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3281 | return ret; |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3282 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3283 | |
| 3284 | /* Nothing to be done if the interface is not opened */ |
| 3285 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3286 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3287 | return -ENODEV; |
| 3288 | } |
| 3289 | |
| 3290 | /* Make sure the interface is marked as closed */ |
| 3291 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3292 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3293 | mac_handle = hdd_ctx->mac_handle; |
| 3294 | |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3295 | hdd_debug("Disabling Auto Power save timer"); |
| 3296 | sme_ps_disable_auto_ps_timer( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3297 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3298 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3299 | |
| 3300 | /* |
| 3301 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3302 | * be called on that interface |
| 3303 | */ |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 3304 | hdd_debug("Disabling queues, adapter device mode: %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 3305 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3306 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3307 | wlan_hdd_netif_queue_control(adapter, |
| 3308 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3309 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3310 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3311 | if (adapter->device_mode == QDF_STA_MODE) |
| 3312 | hdd_lpass_notify_stop(hdd_ctx); |
| 3313 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3314 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3315 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3316 | * bursty in nature and depends on the need to transfer. The service |
| 3317 | * layer may down the interface after the usage and up again when |
| 3318 | * required. In some sense, the NDI is expected to be available |
| 3319 | * (like SAP) iface until NDI delete request is issued by the service |
| 3320 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3321 | * interface (NDI). |
| 3322 | */ |
| 3323 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3324 | return 0; |
| 3325 | |
| 3326 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3327 | * The interface is marked as down for outside world (aka kernel) |
| 3328 | * But the driver is pretty much alive inside. The driver needs to |
| 3329 | * tear down the existing connection on the netdev (session) |
| 3330 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3331 | * for this interface. The call also needs to wait until the above |
| 3332 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3333 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3334 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3335 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3336 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3337 | |
| 3338 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3339 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3340 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3341 | if (!hdd_is_any_interface_open(hdd_ctx)) |
| 3342 | hdd_psoc_idle_timer_start(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3343 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3344 | hdd_exit(); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3345 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3346 | return 0; |
| 3347 | } |
| 3348 | |
| 3349 | /** |
| 3350 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3351 | * @dev: pointer to net_device structure |
| 3352 | * |
| 3353 | * This is called in response to ifconfig down |
| 3354 | * |
| 3355 | * Return: 0 for success and error number for failure |
| 3356 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3357 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3358 | { |
| 3359 | int ret; |
| 3360 | |
| 3361 | cds_ssr_protect(__func__); |
| 3362 | ret = __hdd_stop(dev); |
| 3363 | cds_ssr_unprotect(__func__); |
| 3364 | |
| 3365 | return ret; |
| 3366 | } |
| 3367 | |
| 3368 | /** |
| 3369 | * __hdd_uninit() - HDD uninit function |
| 3370 | * @dev: Pointer to net_device structure |
| 3371 | * |
| 3372 | * This is called during the netdev unregister to uninitialize all data |
| 3373 | * associated with the device |
| 3374 | * |
| 3375 | * Return: None |
| 3376 | */ |
| 3377 | static void __hdd_uninit(struct net_device *dev) |
| 3378 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3379 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3380 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3381 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3382 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3383 | |
| 3384 | do { |
| 3385 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3386 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3387 | break; |
| 3388 | } |
| 3389 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3390 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3391 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3392 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3393 | break; |
| 3394 | } |
| 3395 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3396 | if (dev != adapter->dev) |
| 3397 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3398 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3399 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3400 | |
| 3401 | /* after uninit our adapter structure will no longer be valid */ |
| 3402 | adapter->dev = NULL; |
| 3403 | adapter->magic = 0; |
| 3404 | } while (0); |
| 3405 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3406 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3407 | } |
| 3408 | |
| 3409 | /** |
| 3410 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3411 | * @dev: pointer to net_device structure |
| 3412 | * |
| 3413 | * This is called during the netdev unregister to uninitialize all data |
| 3414 | * associated with the device |
| 3415 | * |
| 3416 | * Return: none |
| 3417 | */ |
| 3418 | static void hdd_uninit(struct net_device *dev) |
| 3419 | { |
| 3420 | cds_ssr_protect(__func__); |
| 3421 | __hdd_uninit(dev); |
| 3422 | cds_ssr_unprotect(__func__); |
| 3423 | } |
| 3424 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3425 | static int hdd_open_cesium_nl_sock(void) |
| 3426 | { |
| 3427 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3428 | struct netlink_kernel_cfg cfg = { |
| 3429 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3430 | .input = NULL |
| 3431 | }; |
| 3432 | #endif |
| 3433 | int ret = 0; |
| 3434 | |
| 3435 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3436 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3437 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3438 | THIS_MODULE, |
| 3439 | #endif |
| 3440 | &cfg); |
| 3441 | #else |
| 3442 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3443 | WLAN_NLINK_MCAST_GRP_ID, |
| 3444 | NULL, NULL, THIS_MODULE); |
| 3445 | #endif |
| 3446 | |
| 3447 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3448 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3449 | ret = -ECONNREFUSED; |
| 3450 | } |
| 3451 | |
| 3452 | return ret; |
| 3453 | } |
| 3454 | |
| 3455 | static void hdd_close_cesium_nl_sock(void) |
| 3456 | { |
| 3457 | if (NULL != cesium_nl_srv_sock) { |
| 3458 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3459 | cesium_nl_srv_sock = NULL; |
| 3460 | } |
| 3461 | } |
| 3462 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3463 | void hdd_update_dynamic_mac(struct hdd_context *hdd_ctx, |
| 3464 | struct qdf_mac_addr *curr_mac_addr, |
| 3465 | struct qdf_mac_addr *new_mac_addr) |
| 3466 | { |
| 3467 | uint8_t i; |
| 3468 | |
| 3469 | hdd_enter(); |
| 3470 | |
| 3471 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
| 3472 | if (!qdf_mem_cmp(curr_mac_addr->bytes, |
| 3473 | &hdd_ctx->dynamic_mac_list[i].bytes[0], |
| 3474 | sizeof(struct qdf_mac_addr))) { |
| 3475 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[i], |
| 3476 | new_mac_addr->bytes, |
| 3477 | sizeof(struct qdf_mac_addr)); |
| 3478 | break; |
| 3479 | } |
| 3480 | } |
| 3481 | |
| 3482 | hdd_exit(); |
| 3483 | } |
| 3484 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3485 | /** |
| 3486 | * __hdd_set_mac_address() - set the user specified mac address |
| 3487 | * @dev: Pointer to the net device. |
| 3488 | * @addr: Pointer to the sockaddr. |
| 3489 | * |
| 3490 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3491 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3492 | * |
| 3493 | * Return: 0 for success, non zero for failure |
| 3494 | */ |
| 3495 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3496 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3497 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3498 | struct hdd_adapter *adapter_temp; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3499 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3500 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3501 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3502 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3503 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3504 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3505 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3506 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3507 | if (netif_running(dev)) { |
| 3508 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3509 | return -EBUSY; |
| 3510 | } |
| 3511 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3512 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3513 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3514 | if (0 != ret) |
| 3515 | return ret; |
| 3516 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3517 | 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] | 3518 | adapter_temp = hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes); |
| 3519 | if (adapter_temp) { |
| 3520 | if (!qdf_str_cmp(adapter_temp->dev->name, dev->name)) |
| 3521 | return 0; |
| 3522 | hdd_err("%s adapter exist with same address " MAC_ADDRESS_STR, |
| 3523 | adapter_temp->dev->name, |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3524 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 3525 | return -EINVAL; |
| 3526 | } |
| 3527 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 3528 | qdf_ret_status = wlan_hdd_validate_mac_address(&mac_addr); |
| 3529 | if (QDF_IS_STATUS_ERROR(qdf_ret_status)) |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3530 | return -EINVAL; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3531 | |
Ashish Kumar Dhanotiya | 8bfef12 | 2018-04-18 16:48:27 +0530 | [diff] [blame] | 3532 | hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ", |
| 3533 | MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3534 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3535 | hdd_update_dynamic_mac(hdd_ctx, &adapter->mac_addr, &mac_addr); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3536 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3537 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3538 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3539 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3540 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3541 | } |
| 3542 | |
| 3543 | /** |
| 3544 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3545 | * function from SSR |
| 3546 | * @dev: pointer to net_device structure |
| 3547 | * @addr: Pointer to the sockaddr |
| 3548 | * |
| 3549 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3550 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3551 | * |
| 3552 | * Return: 0 for success. |
| 3553 | */ |
| 3554 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3555 | { |
| 3556 | int ret; |
| 3557 | |
| 3558 | cds_ssr_protect(__func__); |
| 3559 | ret = __hdd_set_mac_address(dev, addr); |
| 3560 | cds_ssr_unprotect(__func__); |
| 3561 | |
| 3562 | return ret; |
| 3563 | } |
| 3564 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3565 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3566 | { |
| 3567 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3568 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 3569 | i = qdf_ffz(hdd_ctx->config->intfAddrMask); |
| 3570 | if (i < 0 || i >= QDF_MAX_CONCURRENCY_PERSONA) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3571 | return NULL; |
| 3572 | |
| 3573 | hdd_ctx->config->intfAddrMask |= (1 << i); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 3574 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3575 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[i].bytes, |
| 3576 | &hdd_ctx->config->intfMacAddr[i].bytes, |
| 3577 | sizeof(struct qdf_mac_addr)); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 3578 | return hdd_ctx->config->intfMacAddr[i].bytes; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3579 | } |
| 3580 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3581 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3582 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3583 | { |
| 3584 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3585 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3586 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3587 | if (!memcmp(releaseAddr, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3588 | hdd_ctx->dynamic_mac_list[i].bytes, |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 3589 | QDF_MAC_ADDR_SIZE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3590 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3591 | break; |
| 3592 | } |
| 3593 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3594 | } |
| 3595 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3596 | /** |
| 3597 | * __hdd_set_multicast_list() - set the multicast address list |
| 3598 | * @dev: Pointer to the WLAN device. |
| 3599 | * @skb: Pointer to OS packet (sk_buff). |
| 3600 | * |
| 3601 | * This funciton sets the multicast address list. |
| 3602 | * |
| 3603 | * Return: None |
| 3604 | */ |
| 3605 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3606 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3607 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3608 | int i = 0, errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3609 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3610 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3611 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3612 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3613 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3614 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3615 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3616 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3617 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3618 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3619 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 3620 | if (errno) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3621 | goto out; |
| 3622 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3623 | errno = hdd_validate_adapter(adapter); |
| 3624 | if (errno) |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3625 | goto out; |
| 3626 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3627 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3628 | hdd_err("%s: Driver module is closed", __func__); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3629 | goto out; |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3630 | } |
| 3631 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3632 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 3633 | if (!mc_list_request) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3634 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3635 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3636 | /* Delete already configured multicast address list */ |
| 3637 | if (adapter->mc_addr_list.mc_cnt > 0) { |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3638 | hdd_debug("clear previously configured MC address list"); |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3639 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3640 | pmo_mc_list_change_notify); |
| 3641 | } |
| 3642 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3643 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3644 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3645 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3646 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3647 | } else { |
| 3648 | mc_count = netdev_mc_count(dev); |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 3649 | if (mc_count > ucfg_pmo_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3650 | 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] | 3651 | ucfg_pmo_max_mc_addr_supported(psoc)); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3652 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3653 | pmo_mc_list_change_notify); |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3654 | adapter->mc_addr_list.mc_cnt = 0; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3655 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3656 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3657 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3658 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3659 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3660 | if (i == mc_count) |
| 3661 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3662 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3663 | 0, ETH_ALEN); |
| 3664 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3665 | ha->addr, ETH_ALEN); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3666 | hdd_debug("mlist[%d] = %pM", i, |
| 3667 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3668 | i++; |
| 3669 | } |
| 3670 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3671 | |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3672 | adapter->mc_addr_list.mc_cnt = mc_count; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3673 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3674 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3675 | mc_list_request->count = mc_count; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3676 | |
| 3677 | errno = hdd_cache_mc_addr_list(mc_list_request); |
| 3678 | if (errno) { |
| 3679 | hdd_err("Failed to cache MC address list for vdev %u; errno:%d", |
| 3680 | adapter->session_id, errno); |
| 3681 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3682 | } |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3683 | |
| 3684 | hdd_enable_mc_addr_filtering(adapter, pmo_mc_list_change_notify); |
| 3685 | |
| 3686 | free_req: |
| 3687 | qdf_mem_free(mc_list_request); |
| 3688 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3689 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3690 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3691 | } |
| 3692 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3693 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3694 | /** |
| 3695 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3696 | * @dev: pointer to net_device |
| 3697 | * |
| 3698 | * Return: none |
| 3699 | */ |
| 3700 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3701 | { |
| 3702 | cds_ssr_protect(__func__); |
| 3703 | __hdd_set_multicast_list(dev); |
| 3704 | cds_ssr_unprotect(__func__); |
| 3705 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3706 | |
| 3707 | /** |
| 3708 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3709 | * @dev: Pointer to the WLAN device. |
| 3710 | * @skb: Pointer to OS packet (sk_buff). |
| 3711 | * |
| 3712 | * This function is registered with the Linux OS for network |
| 3713 | * core to decide which queue to use first. |
| 3714 | * |
| 3715 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3716 | */ |
| 3717 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3718 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3719 | , void *accel_priv |
| 3720 | #endif |
| 3721 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3722 | , select_queue_fallback_t fallback |
| 3723 | #endif |
| 3724 | ) |
| 3725 | { |
| 3726 | return hdd_wmm_select_queue(dev, skb); |
| 3727 | } |
| 3728 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3729 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3730 | .ndo_open = hdd_open, |
| 3731 | .ndo_stop = hdd_stop, |
| 3732 | .ndo_uninit = hdd_uninit, |
| 3733 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3734 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3735 | .ndo_get_stats = hdd_get_stats, |
| 3736 | .ndo_do_ioctl = hdd_ioctl, |
| 3737 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3738 | .ndo_select_queue = hdd_select_queue, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3739 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3740 | }; |
| 3741 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3742 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3743 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3744 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3745 | .ndo_open = hdd_mon_open, |
| 3746 | .ndo_stop = hdd_stop, |
| 3747 | .ndo_get_stats = hdd_get_stats, |
| 3748 | }; |
| 3749 | |
| 3750 | /** |
| 3751 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3752 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3753 | * Return: None |
| 3754 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3755 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3756 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3757 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3758 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3759 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3760 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3761 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3762 | #else |
| 3763 | void hdd_set_station_ops(struct net_device *dev) |
| 3764 | { |
| 3765 | dev->netdev_ops = &wlan_drv_ops; |
| 3766 | } |
| 3767 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3768 | |
| 3769 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3770 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3771 | * @hdd_ctx: global hdd context |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3772 | * @mac_addr: mac address to assign to the interface |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3773 | * @name: User-visible name of the interface |
| 3774 | * |
| 3775 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3776 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3777 | * |
| 3778 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3779 | */ |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3780 | static struct hdd_adapter * |
| 3781 | hdd_alloc_station_adapter(struct hdd_context *hdd_ctx, tSirMacAddr mac_addr, |
| 3782 | unsigned char name_assign_type, const char *name) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3783 | { |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3784 | struct net_device *dev; |
| 3785 | struct hdd_adapter *adapter; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3786 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3787 | QDF_STATUS qdf_status; |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 3788 | void *soc; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3789 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 3790 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3791 | /* cfg80211 initialization and registration */ |
| 3792 | dev = alloc_netdev_mq(sizeof(*adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3793 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3794 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3795 | #endif |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3796 | (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE ? |
| 3797 | hdd_mon_mode_ether_setup : ether_setup), |
| 3798 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3799 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3800 | if (!dev) { |
| 3801 | hdd_err("Failed to allocate new net_device '%s'", name); |
| 3802 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3803 | } |
| 3804 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3805 | adapter = netdev_priv(dev); |
| 3806 | |
| 3807 | qdf_mem_zero(adapter, sizeof(*adapter)); |
| 3808 | sta_ctx = &adapter->session.station; |
| 3809 | qdf_mem_set(sta_ctx->conn_info.staId, sizeof(sta_ctx->conn_info.staId), |
| 3810 | HDD_WLAN_INVALID_STA_ID); |
| 3811 | adapter->dev = dev; |
| 3812 | adapter->hdd_ctx = hdd_ctx; |
| 3813 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
| 3814 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3815 | |
| 3816 | qdf_status = qdf_event_create(&adapter->qdf_session_open_event); |
| 3817 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3818 | goto free_net_dev; |
| 3819 | |
| 3820 | qdf_status = qdf_event_create(&adapter->qdf_session_close_event); |
| 3821 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3822 | goto free_net_dev; |
| 3823 | |
| 3824 | adapter->offloads_configured = false; |
| 3825 | adapter->is_link_up_service_needed = false; |
| 3826 | adapter->disconnection_in_progress = false; |
| 3827 | adapter->send_mode_change = true; |
| 3828 | |
| 3829 | /* Init the net_device structure */ |
| 3830 | strlcpy(dev->name, name, IFNAMSIZ); |
| 3831 | |
| 3832 | qdf_mem_copy(dev->dev_addr, mac_addr, sizeof(tSirMacAddr)); |
| 3833 | qdf_mem_copy(adapter->mac_addr.bytes, mac_addr, sizeof(tSirMacAddr)); |
| 3834 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 3835 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 3836 | if (cdp_cfg_get(soc, |
| 3837 | cfg_dp_enable_ip_tcp_udp_checksum_offload)) |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3838 | dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 3839 | dev->features |= NETIF_F_RXCSUM; |
| 3840 | |
| 3841 | hdd_set_tso_flags(hdd_ctx, dev); |
| 3842 | hdd_set_station_ops(adapter->dev); |
| 3843 | |
| 3844 | hdd_dev_setup_destructor(dev); |
| 3845 | dev->ieee80211_ptr = &adapter->wdev; |
| 3846 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
| 3847 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 3848 | adapter->wdev.netdev = dev; |
| 3849 | |
| 3850 | /* set dev's parent to underlying device */ |
| 3851 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
| 3852 | hdd_wmm_init(adapter); |
| 3853 | spin_lock_init(&adapter->pause_map_lock); |
| 3854 | adapter->start_time = qdf_system_ticks(); |
| 3855 | adapter->last_time = adapter->start_time; |
| 3856 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3857 | return adapter; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3858 | |
| 3859 | free_net_dev: |
| 3860 | free_netdev(adapter->dev); |
| 3861 | |
| 3862 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3863 | } |
| 3864 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3865 | 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] | 3866 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3867 | struct net_device *dev = adapter->dev; |
| 3868 | int ret; |
| 3869 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3870 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3871 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3872 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3873 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3874 | |
| 3875 | ret = dev_alloc_name(dev, dev->name); |
| 3876 | if (ret < 0) { |
| 3877 | hdd_err( |
| 3878 | "unable to get dev name: %s, err = 0x%x", |
| 3879 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3880 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3881 | } |
| 3882 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3883 | |
| 3884 | ret = register_netdevice(dev); |
| 3885 | if (ret) { |
| 3886 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3887 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3888 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3889 | } |
| 3890 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3891 | ret = register_netdev(dev); |
| 3892 | if (ret) { |
| 3893 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3894 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3895 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3896 | } |
| 3897 | } |
| 3898 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3899 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3900 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3901 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3902 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3903 | } |
| 3904 | |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3905 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id, |
| 3906 | QDF_STATUS qdf_status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3907 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3908 | struct hdd_adapter *adapter; |
| 3909 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3910 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3911 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3912 | if (!hdd_ctx) { |
| 3913 | hdd_err("Invalid HDD_CTX"); |
| 3914 | return QDF_STATUS_E_FAILURE; |
| 3915 | } |
| 3916 | |
| 3917 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3918 | if (NULL == adapter) { |
Naveen Rawat | 23a3b91 | 2018-05-30 17:45:52 -0700 | [diff] [blame] | 3919 | hdd_err("NULL adapter for %d", session_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3920 | return QDF_STATUS_E_INVAL; |
| 3921 | } |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3922 | |
| 3923 | if (qdf_status == QDF_STATUS_SUCCESS) |
| 3924 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3925 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3926 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3927 | hdd_debug("session %d opened", adapter->session_id); |
| 3928 | |
| 3929 | return QDF_STATUS_SUCCESS; |
| 3930 | } |
| 3931 | |
| 3932 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3933 | { |
| 3934 | struct hdd_adapter *adapter; |
| 3935 | struct hdd_context *hdd_ctx; |
| 3936 | |
| 3937 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3938 | if (!hdd_ctx) { |
| 3939 | hdd_err("Invalid HDD_CTX"); |
| 3940 | return QDF_STATUS_E_FAILURE; |
| 3941 | } |
| 3942 | |
| 3943 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3944 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3945 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3946 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3947 | } |
| 3948 | |
| 3949 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3950 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3951 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3952 | } |
| 3953 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3954 | /* |
| 3955 | * For NAN Data interface, the close session results in the final |
| 3956 | * indication to the userspace |
| 3957 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3958 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3959 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3960 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3961 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3962 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3963 | /* |
| 3964 | * We can be blocked while waiting for scheduled work to be |
| 3965 | * flushed, and the adapter structure can potentially be freed, in |
| 3966 | * which case the magic will have been reset. So make sure the |
| 3967 | * magic is still good, and hence the adapter structure is still |
| 3968 | * valid, before signaling completion |
| 3969 | */ |
| 3970 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3971 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3972 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3973 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3974 | } |
| 3975 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3976 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3977 | { |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3978 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3979 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3980 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3981 | vdev = hdd_objmgr_get_vdev(adapter); |
| 3982 | if (!vdev) |
| 3983 | return -EINVAL; |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3984 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3985 | status = pmo_vdev_ready(vdev); |
| 3986 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3987 | hdd_objmgr_put_vdev(adapter); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3988 | return qdf_status_to_os_return(status); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3989 | } |
| 3990 | |
| 3991 | status = ucfg_reg_11d_vdev_created_update(vdev); |
| 3992 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3993 | hdd_objmgr_put_vdev(adapter); |
| 3994 | return qdf_status_to_os_return(status); |
| 3995 | } |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3996 | |
| 3997 | if (wma_capability_enhanced_mcast_filter()) |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 3998 | status = ucfg_pmo_enhanced_mc_filter_enable(vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3999 | else |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4000 | status = ucfg_pmo_enhanced_mc_filter_disable(vdev); |
| 4001 | |
| 4002 | hdd_objmgr_put_vdev(adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4003 | |
| 4004 | return qdf_status_to_os_return(status); |
| 4005 | } |
| 4006 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4007 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4008 | { |
| 4009 | QDF_STATUS status; |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4010 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4011 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4012 | uint8_t vdev_id; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4013 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4014 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4015 | vdev_id = adapter->session_id; |
| 4016 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4017 | |
| 4018 | /* vdev created sanity check */ |
| 4019 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4020 | hdd_err("vdev %u does not exist", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4021 | return -EINVAL; |
| 4022 | } |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4023 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4024 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4025 | if (!vdev) |
| 4026 | return -EINVAL; |
Ashish Kumar Dhanotiya | 68ee2e4 | 2018-11-19 21:15:14 +0530 | [diff] [blame] | 4027 | |
| 4028 | ucfg_pmo_del_wow_pattern(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4029 | status = ucfg_reg_11d_vdev_delete_update(vdev); |
Abhishek Singh | 935e477 | 2018-11-21 14:14:10 +0530 | [diff] [blame] | 4030 | ucfg_scan_vdev_set_disable(vdev, REASON_VDEV_DOWN); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4031 | hdd_objmgr_put_vdev(adapter); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4032 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4033 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4034 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4035 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4036 | status = sme_close_session(hdd_ctx->mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4037 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4038 | hdd_err("failed to close sme session; status:%d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4039 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4040 | } |
| 4041 | |
| 4042 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4043 | status = qdf_wait_for_event_completion( |
| 4044 | &adapter->qdf_session_close_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4045 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4046 | |
| 4047 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4048 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4049 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4050 | if (adapter->device_mode == QDF_NDI_MODE) |
| 4051 | hdd_ndp_session_end_handler(adapter); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4052 | |
| 4053 | if (status == QDF_STATUS_E_TIMEOUT) |
| 4054 | hdd_err("timed out waiting for sme close session"); |
| 4055 | else if (adapter->qdf_session_close_event.force_set) |
| 4056 | hdd_info("SSR occurred during sme close session"); |
| 4057 | else |
| 4058 | hdd_err("failed to wait for sme close session; status:%u", |
| 4059 | status); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4060 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4061 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4062 | release_vdev: |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4063 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4064 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4065 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4066 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4067 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4068 | return errno; |
| 4069 | } |
| 4070 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4071 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4072 | |
| 4073 | return 0; |
| 4074 | } |
| 4075 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4076 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 4077 | struct sme_session_params *session_param, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4078 | csr_roam_complete_cb callback, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4079 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4080 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4081 | uint32_t type; |
| 4082 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4083 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4084 | |
| 4085 | /* determine vdev (sub)type */ |
| 4086 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4087 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4088 | hdd_err("failed to get vdev type: %d", status); |
| 4089 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4090 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4091 | session_param->sme_session_id = adapter->session_id; |
| 4092 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 4093 | session_param->type_of_persona = type; |
| 4094 | session_param->subtype_of_persona = sub_type; |
| 4095 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 4096 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 4097 | session_param->callback = callback; |
| 4098 | session_param->callback_ctx = callback_ctx; |
| 4099 | |
| 4100 | return 0; |
| 4101 | } |
| 4102 | |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4103 | static void |
| 4104 | hdd_store_nss_chains_cfg_in_vdev(struct hdd_adapter *adapter) |
| 4105 | { |
| 4106 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 4107 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4108 | |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4109 | /* Populate the nss chain params from ini for this vdev type */ |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4110 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 4111 | adapter->device_mode, |
| 4112 | hdd_ctx->num_rf_chains); |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4113 | |
| 4114 | /* Store the nss chain config into the vdev */ |
| 4115 | sme_store_nss_chains_cfg_in_vdev(adapter->vdev, &vdev_ini_cfg); |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4116 | } |
gaurank kathpalia | 6982d47 | 2018-10-31 21:54:15 +0530 | [diff] [blame] | 4117 | |
| 4118 | bool hdd_is_vdev_in_conn_state(struct hdd_adapter *adapter) |
| 4119 | { |
| 4120 | switch (adapter->device_mode) { |
| 4121 | case QDF_STA_MODE: |
| 4122 | case QDF_P2P_CLIENT_MODE: |
| 4123 | case QDF_P2P_DEVICE_MODE: |
| 4124 | return hdd_conn_is_connected( |
| 4125 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)); |
| 4126 | case QDF_SAP_MODE: |
| 4127 | case QDF_P2P_GO_MODE: |
| 4128 | return (test_bit(SOFTAP_BSS_STARTED, |
| 4129 | &adapter->event_flags)); |
| 4130 | default: |
| 4131 | hdd_err("Device mode %d invalid", adapter->device_mode); |
| 4132 | return 0; |
| 4133 | } |
| 4134 | |
| 4135 | return 0; |
| 4136 | } |
| 4137 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4138 | int hdd_vdev_create(struct hdd_adapter *adapter, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4139 | csr_roam_complete_cb callback, void *ctx) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4140 | { |
| 4141 | QDF_STATUS status; |
| 4142 | int errno; |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4143 | bool bval; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4144 | struct hdd_context *hdd_ctx; |
| 4145 | struct sme_session_params sme_session_params = {0}; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4146 | struct wlan_objmgr_vdev *vdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4147 | |
| 4148 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4149 | |
| 4150 | /* do vdev create via objmgr */ |
| 4151 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 4152 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4153 | if (errno) { |
| 4154 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 4155 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4156 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4157 | |
| 4158 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4159 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 4160 | if (QDF_STATUS_SUCCESS != status) { |
| 4161 | hdd_err("failed to reinit session open event"); |
| 4162 | return -EINVAL; |
| 4163 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4164 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 4165 | callback, ctx); |
| 4166 | if (errno) { |
| 4167 | hdd_err("failed to populating SME params"); |
| 4168 | goto objmgr_vdev_destroy_procedure; |
| 4169 | } |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4170 | status = sme_open_session(hdd_ctx->mac_handle, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4171 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4172 | hdd_err("failed to open sme session: %d", status); |
| 4173 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4174 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4175 | } |
| 4176 | |
| 4177 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4178 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4179 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4180 | if (QDF_STATUS_SUCCESS != status) { |
| 4181 | if (adapter->qdf_session_open_event.force_set) { |
| 4182 | /* |
| 4183 | * SSR/PDR has caused shutdown, which has forcefully |
| 4184 | * set the event. Return without the closing session. |
| 4185 | */ |
| 4186 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 4187 | hdd_err("Session open event forcefully set"); |
| 4188 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4189 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 4190 | |
| 4191 | if (QDF_STATUS_E_TIMEOUT == status) |
| 4192 | hdd_err("Session failed to open within timeout period"); |
| 4193 | else |
| 4194 | hdd_err("Failed to wait for session open event(status-%d)", |
| 4195 | status); |
| 4196 | errno = -ETIMEDOUT; |
| 4197 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4198 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4199 | } |
| 4200 | |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 4201 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 4202 | hdd_err("Session failed to open due to vdev create failure"); |
| 4203 | errno = -EINVAL; |
| 4204 | goto objmgr_vdev_destroy_procedure; |
| 4205 | } |
| 4206 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4207 | /* firmware ready for component communication, raise vdev_ready event */ |
| 4208 | errno = hdd_vdev_ready(adapter); |
| 4209 | if (errno) { |
| 4210 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4211 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4212 | } |
| 4213 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4214 | if (adapter->device_mode == QDF_STA_MODE) { |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4215 | bval = false; |
| 4216 | status = ucfg_mlme_get_rtt_mac_randomization(hdd_ctx->psoc, |
| 4217 | &bval); |
| 4218 | if (QDF_IS_STATUS_ERROR(status)) |
| 4219 | hdd_err("unable to get RTT MAC randomization value"); |
| 4220 | |
| 4221 | hdd_debug("setting RTT mac randomization param: %d", bval); |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4222 | errno = sme_cli_set_command(adapter->session_id, |
| 4223 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4224 | bval, |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4225 | VDEV_CMD); |
| 4226 | if (0 != errno) |
| 4227 | hdd_err("RTT mac randomization param set failed %d", |
| 4228 | errno); |
| 4229 | } |
| 4230 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4231 | if (adapter->device_mode == QDF_STA_MODE || |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4232 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
| 4233 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4234 | if (!vdev) |
| 4235 | goto hdd_vdev_destroy_procedure; |
| 4236 | wlan_vdev_set_max_peer_count(vdev, HDD_MAX_VDEV_PEER_COUNT); |
| 4237 | hdd_objmgr_put_vdev(adapter); |
| 4238 | } |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4239 | |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4240 | hdd_store_nss_chains_cfg_in_vdev(adapter); |
| 4241 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4242 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4243 | |
| 4244 | return 0; |
| 4245 | |
| 4246 | /* |
| 4247 | * Due to legacy constraints, we need to destroy in the same order as |
| 4248 | * create. So, split error handling into 2 cases to accommodate. |
| 4249 | */ |
| 4250 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4251 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4252 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4253 | |
| 4254 | return errno; |
| 4255 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4256 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4257 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 4258 | |
| 4259 | return errno; |
| 4260 | } |
| 4261 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4262 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4263 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4264 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4265 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4266 | QDF_STATUS status; |
| 4267 | int ret_val; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4268 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4269 | bool bval = false; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4270 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4271 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4272 | mac_handle = hdd_ctx->mac_handle; |
| 4273 | sme_set_curr_device_mode(mac_handle, adapter->device_mode); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4274 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4275 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4276 | hdd_err("unable to get vht_enable2x2"); |
| 4277 | sme_set_pdev_ht_vht_ies(mac_handle, bval); |
| 4278 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4279 | sme_set_vdev_ies_per_band(mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4280 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 4281 | hdd_roam_profile_init(adapter); |
| 4282 | hdd_register_wext(adapter->dev); |
| 4283 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4284 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4285 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4286 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 4287 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4288 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4289 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4290 | status = sme_config_fast_roaming(mac_handle, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4291 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4292 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4293 | sta_ctx->conn_info.operationChannel = |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 4294 | hdd_ctx->config->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4295 | |
| 4296 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4297 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4298 | |
| 4299 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4300 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4301 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4302 | status, status); |
| 4303 | goto error_init_txrx; |
| 4304 | } |
| 4305 | |
| 4306 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4307 | |
| 4308 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4309 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4310 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4311 | status, status); |
| 4312 | goto error_wmm_init; |
| 4313 | } |
| 4314 | |
| 4315 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4316 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4317 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4318 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4319 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4320 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4321 | if (ret_val) |
| 4322 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4323 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4324 | /* |
| 4325 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4326 | * during that time, then as part of SSR init, do not enable |
| 4327 | * the LRO again. Keep the LRO state same as before SSR. |
| 4328 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 4329 | if (cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 4330 | cfg_dp_lro_enable) && |
| 4331 | !(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4332 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4333 | |
| 4334 | /* rcpi info initialization */ |
| 4335 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4336 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4337 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4338 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4339 | error_wmm_init: |
| 4340 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4341 | hdd_deinit_tx_rx(adapter); |
| 4342 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4343 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4344 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4345 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4346 | return status; |
| 4347 | } |
| 4348 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4349 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4350 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4351 | * @hdd_ctx: global hdd context |
| 4352 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4353 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4354 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4355 | * |
| 4356 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4357 | * |
| 4358 | * Return: None. |
| 4359 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4360 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4361 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4362 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4363 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4364 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4365 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4366 | if (adapter->dev) { |
| 4367 | if (rtnl_held) |
| 4368 | adapter->dev->wireless_handlers = NULL; |
| 4369 | else { |
| 4370 | rtnl_lock(); |
| 4371 | adapter->dev->wireless_handlers = NULL; |
| 4372 | rtnl_unlock(); |
| 4373 | } |
| 4374 | } |
| 4375 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4376 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4377 | hdd_deinit_tx_rx(adapter); |
| 4378 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4379 | } |
| 4380 | |
| 4381 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4382 | hdd_wmm_adapter_close(adapter); |
| 4383 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4384 | } |
| 4385 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4386 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4387 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4388 | } |
| 4389 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4390 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4391 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4392 | bool rtnl_held) |
| 4393 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4394 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4395 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4396 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4397 | case QDF_STA_MODE: |
| 4398 | case QDF_P2P_CLIENT_MODE: |
| 4399 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4400 | case QDF_IBSS_MODE: |
| 4401 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4402 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4403 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4404 | break; |
| 4405 | } |
| 4406 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4407 | case QDF_SAP_MODE: |
| 4408 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4409 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4410 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4411 | break; |
| 4412 | } |
| 4413 | |
| 4414 | default: |
| 4415 | break; |
| 4416 | } |
| 4417 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4418 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4419 | } |
| 4420 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4421 | static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx, |
| 4422 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4423 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4424 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4425 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4426 | |
| 4427 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4428 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4429 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4430 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4431 | return; |
| 4432 | } |
| 4433 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4434 | hdd_nud_deinit_tracking(adapter); |
| 4435 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4436 | hdd_apf_context_destroy(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4437 | qdf_spinlock_destroy(&adapter->vdev_lock); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4438 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4439 | wlan_hdd_debugfs_csr_deinit(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 4440 | if (adapter->device_mode == QDF_STA_MODE) |
| 4441 | hdd_sysfs_destroy_adapter_root_obj(adapter); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4442 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4443 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4444 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4445 | /* |
| 4446 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4447 | * the driver is almost closed and cannot handle either control |
| 4448 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4449 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4450 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4451 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4452 | * the interface is closed and restricts any operations on that |
| 4453 | */ |
| 4454 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4455 | |
| 4456 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4457 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4458 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4459 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4460 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4461 | /* |
| 4462 | * Note that the adapter is no longer valid at this point |
| 4463 | * since the memory has been reclaimed |
| 4464 | */ |
| 4465 | } |
| 4466 | } |
| 4467 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4468 | 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] | 4469 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4470 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4471 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4472 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4473 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4474 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4475 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4476 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4477 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4478 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4479 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4480 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4481 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4482 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4483 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4484 | /** |
| 4485 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4486 | * @hdd_ctx: HDD Context |
| 4487 | * @adapter: HDD Adapter |
| 4488 | * |
| 4489 | * This function set the FW Debug log level based on the INI. |
| 4490 | * |
| 4491 | * Return: None |
| 4492 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4493 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4494 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4495 | { |
| 4496 | uint8_t count = 0, numentries = 0, |
| 4497 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 4498 | uint32_t value = 0; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4499 | QDF_STATUS status; |
| 4500 | uint16_t enable_fw_log_level, enable_fw_log_type; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4501 | int ret; |
| 4502 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4503 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4504 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4505 | 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] | 4506 | return; |
| 4507 | } |
| 4508 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4509 | /* Enable FW logs based on INI configuration */ |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4510 | status = ucfg_fwol_get_enable_fw_log_type(hdd_ctx->psoc, |
| 4511 | &enable_fw_log_type); |
| 4512 | if (QDF_IS_STATUS_ERROR(status)) |
| 4513 | return; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4514 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4515 | WMI_DBGLOG_TYPE, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4516 | enable_fw_log_type, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4517 | DBG_CMD); |
| 4518 | if (ret != 0) |
| 4519 | hdd_err("Failed to enable FW log type ret %d", |
| 4520 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4521 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4522 | status = ucfg_fwol_get_enable_fw_log_level(hdd_ctx->psoc, |
| 4523 | &enable_fw_log_level); |
| 4524 | if (QDF_IS_STATUS_ERROR(status)) |
| 4525 | return; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4526 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4527 | WMI_DBGLOG_LOG_LEVEL, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4528 | enable_fw_log_level, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4529 | DBG_CMD); |
| 4530 | if (ret != 0) |
| 4531 | hdd_err("Failed to enable FW log level ret %d", |
| 4532 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4533 | |
| 4534 | hdd_string_to_u8_array( |
| 4535 | hdd_ctx->config->enableFwModuleLogLevel, |
| 4536 | moduleloglevel, |
| 4537 | &numentries, |
| 4538 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 4539 | |
| 4540 | while (count < numentries) { |
| 4541 | /* |
| 4542 | * FW module log level input string looks like |
| 4543 | * below: |
| 4544 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 4545 | * <Log Level>,... |
| 4546 | * For example: |
| 4547 | * gFwDebugModuleLoglevel= |
| 4548 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 4549 | * Above input string means : |
| 4550 | * For FW module ID 1 enable log level 0 |
| 4551 | * For FW module ID 2 enable log level 1 |
| 4552 | * For FW module ID 3 enable log level 2 |
| 4553 | * For FW module ID 4 enable log level 3 |
| 4554 | * For FW module ID 5 enable log level 4 |
| 4555 | * For FW module ID 6 enable log level 5 |
| 4556 | * For FW module ID 7 enable log level 6 |
| 4557 | */ |
| 4558 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4559 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4560 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4561 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4562 | moduleloglevel[count], |
| 4563 | moduleloglevel[count + 1]); |
| 4564 | return; |
| 4565 | } |
| 4566 | |
| 4567 | value = moduleloglevel[count] << 16; |
| 4568 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4569 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4570 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4571 | value, DBG_CMD); |
| 4572 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4573 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4574 | value, ret); |
| 4575 | |
| 4576 | count += 2; |
| 4577 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4578 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4579 | } |
| 4580 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4581 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4582 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4583 | { |
| 4584 | } |
| 4585 | |
| 4586 | #endif |
| 4587 | |
| 4588 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4589 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4590 | * @adapter: HDD adapter |
| 4591 | * |
| 4592 | * Return: 0 on success or errno on failure |
| 4593 | */ |
| 4594 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4595 | { |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4596 | QDF_STATUS status; |
| 4597 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4598 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4599 | bool enable2x2 = false, enable_bt_chain_sep = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4600 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
| 4601 | |
| 4602 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 4603 | &dual_mac_feature); |
| 4604 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4605 | hdd_err("unable to get dual mac feature"); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4606 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4607 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &enable2x2); |
| 4608 | if (QDF_IS_STATUS_ERROR(status)) |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4609 | hdd_err("unable to get vht_enable2x2"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4610 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4611 | status = ucfg_mlme_get_bt_chain_separation_flag(hdd_ctx->psoc, |
| 4612 | &enable_bt_chain_sep); |
| 4613 | if (QDF_IS_STATUS_ERROR(status)) |
| 4614 | hdd_debug("unable to get BT chain separation. using default"); |
| 4615 | |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4616 | hdd_debug("enable2x2: %d, lte_coex: %d, disable_DBS: %d", |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4617 | enable2x2, hdd_ctx->lte_coex_ant_share, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4618 | dual_mac_feature); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4619 | hdd_debug("enable_bt_chain_separation %d", enable_bt_chain_sep); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4620 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4621 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4622 | HW_MODE_DBS_NONE, |
| 4623 | CDS_BAND_ALL); |
| 4624 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4625 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4626 | return qdf_status_to_os_return(status); |
| 4627 | } |
| 4628 | |
| 4629 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4630 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4631 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4632 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4633 | hdd_debug("firmware not capable. skip chain mask programming"); |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4634 | return 0; |
| 4635 | } |
| 4636 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4637 | if (enable2x2 && !enable_bt_chain_sep) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4638 | hdd_debug("2x2 enabled. skip chain mask programming"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4639 | return 0; |
| 4640 | } |
| 4641 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4642 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4643 | hdd_debug("DBS enabled(%d). skip chain mask programming", |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4644 | dual_mac_feature); |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4645 | return 0; |
| 4646 | } |
| 4647 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4648 | if (hdd_ctx->lte_coex_ant_share) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4649 | hdd_debug("lte ant sharing enabled. skip chainmask programming"); |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4650 | return 0; |
| 4651 | } |
| 4652 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4653 | status = ucfg_mlme_configure_chain_mask(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4654 | adapter->session_id); |
| 4655 | if (status != QDF_STATUS_SUCCESS) |
| 4656 | goto error; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4657 | |
| 4658 | return 0; |
| 4659 | |
| 4660 | error: |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4661 | hdd_err("WMI PDEV set param failed"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4662 | return -EINVAL; |
| 4663 | } |
| 4664 | |
| 4665 | /** |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4666 | * hdd_send_coex_config_params() - Send coex config params to FW |
| 4667 | * @hdd_ctx: HDD context |
| 4668 | * @adapter: Primary adapter context |
| 4669 | * |
| 4670 | * This function is used to send all coex config related params to FW |
| 4671 | * |
| 4672 | * Return: 0 on success and -EINVAL on failure |
| 4673 | */ |
| 4674 | static int hdd_send_coex_config_params(struct hdd_context *hdd_ctx, |
| 4675 | struct hdd_adapter *adapter) |
| 4676 | { |
| 4677 | struct coex_config_params coex_cfg_params = {0}; |
| 4678 | struct wlan_fwol_coex_config config = {0}; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 4679 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4680 | QDF_STATUS status; |
| 4681 | |
| 4682 | if (!hdd_ctx) { |
| 4683 | hdd_err("hdd_ctx is invalid"); |
| 4684 | goto err; |
| 4685 | } |
| 4686 | |
| 4687 | if (!adapter) { |
| 4688 | hdd_err("adapter is invalid"); |
| 4689 | goto err; |
| 4690 | } |
| 4691 | |
| 4692 | if (!psoc) { |
| 4693 | hdd_err("HDD psoc is invalid"); |
| 4694 | goto err; |
| 4695 | } |
| 4696 | |
| 4697 | status = ucfg_fwol_get_coex_config_params(psoc, &config); |
| 4698 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4699 | hdd_err("Unable to get coex config params"); |
| 4700 | goto err; |
| 4701 | } |
| 4702 | |
| 4703 | coex_cfg_params.vdev_id = adapter->session_id; |
| 4704 | coex_cfg_params.config_type = WMI_COEX_CONFIG_TX_POWER; |
| 4705 | coex_cfg_params.config_arg1 = config.max_tx_power_for_btc; |
| 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 Tx power"); |
| 4710 | goto err; |
| 4711 | } |
| 4712 | |
| 4713 | coex_cfg_params.config_type = WMI_COEX_CONFIG_HANDOVER_RSSI; |
| 4714 | coex_cfg_params.config_arg1 = config.wlan_low_rssi_threshold; |
| 4715 | |
| 4716 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4717 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4718 | hdd_err("Failed to send coex handover RSSI"); |
| 4719 | goto err; |
| 4720 | } |
| 4721 | |
| 4722 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BTC_MODE; |
| 4723 | coex_cfg_params.config_arg1 = config.btc_mode; |
| 4724 | |
| 4725 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4726 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4727 | hdd_err("Failed to send coex BTC mode"); |
| 4728 | goto err; |
| 4729 | } |
| 4730 | |
| 4731 | coex_cfg_params.config_type = WMI_COEX_CONFIG_ANTENNA_ISOLATION; |
| 4732 | coex_cfg_params.config_arg1 = config.antenna_isolation; |
| 4733 | |
| 4734 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4735 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4736 | hdd_err("Failed to send coex antenna isolation"); |
| 4737 | goto err; |
| 4738 | } |
| 4739 | |
| 4740 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_LOW_RSSI_THRESHOLD; |
| 4741 | coex_cfg_params.config_arg1 = config.bt_low_rssi_threshold; |
| 4742 | |
| 4743 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4744 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4745 | hdd_err("Failed to send coex BT low RSSI threshold"); |
| 4746 | goto err; |
| 4747 | } |
| 4748 | |
| 4749 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_INTERFERENCE_LEVEL; |
| 4750 | coex_cfg_params.config_arg1 = config.bt_interference_low_ll; |
| 4751 | coex_cfg_params.config_arg2 = config.bt_interference_low_ul; |
| 4752 | coex_cfg_params.config_arg3 = config.bt_interference_medium_ll; |
| 4753 | coex_cfg_params.config_arg4 = config.bt_interference_medium_ul; |
| 4754 | coex_cfg_params.config_arg5 = config.bt_interference_high_ll; |
| 4755 | coex_cfg_params.config_arg6 = config.bt_interference_high_ul; |
| 4756 | |
| 4757 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4758 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4759 | hdd_err("Failed to send coex BT interference level"); |
| 4760 | goto err; |
| 4761 | } |
| 4762 | return 0; |
| 4763 | err: |
| 4764 | return -EINVAL; |
| 4765 | } |
| 4766 | |
| 4767 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4768 | * hdd_set_fw_params() - Set parameters to firmware |
| 4769 | * @adapter: HDD adapter |
| 4770 | * |
| 4771 | * This function Sets various parameters to fw once the |
| 4772 | * adapter is started. |
| 4773 | * |
| 4774 | * Return: 0 on success or errno on failure |
| 4775 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4776 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4777 | { |
| 4778 | int ret; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4779 | uint16_t upper_brssi_thresh, lower_brssi_thresh, rts_profile; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4780 | bool enable_dtim_1chrx; |
| 4781 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4782 | struct hdd_context *hdd_ctx; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4783 | bool bval = false; |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4784 | uint8_t max_amsdu_len; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4785 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4786 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4787 | |
| 4788 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4789 | if (!hdd_ctx) |
| 4790 | return -EINVAL; |
| 4791 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4792 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4793 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4794 | return 0; |
| 4795 | } |
| 4796 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4797 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4798 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4799 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4800 | if (ret) { |
| 4801 | hdd_err("Failed to set LPRx"); |
| 4802 | goto error; |
| 4803 | } |
| 4804 | |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4805 | |
| 4806 | ret = sme_cli_set_command( |
| 4807 | adapter->session_id, |
| 4808 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
| 4809 | hdd_ctx->config->enable_dtim_selection_diversity, |
| 4810 | PDEV_CMD); |
| 4811 | if (ret) { |
| 4812 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4813 | goto error; |
| 4814 | } |
| 4815 | |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4816 | ret = sme_cli_set_command( |
| 4817 | adapter->session_id, |
| 4818 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4819 | hdd_ctx->config->enable_tx_sch_delay, |
| 4820 | PDEV_CMD); |
| 4821 | if (ret) { |
| 4822 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4823 | goto error; |
| 4824 | } |
| 4825 | |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4826 | ret = sme_cli_set_command( |
| 4827 | adapter->session_id, |
| 4828 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4829 | hdd_ctx->config->enable_secondary_rate, |
| 4830 | PDEV_CMD); |
| 4831 | if (ret) { |
| 4832 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4833 | goto error; |
| 4834 | } |
| 4835 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4836 | if (adapter->device_mode == QDF_STA_MODE) { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4837 | status = ucfg_get_upper_brssi_thresh(hdd_ctx->psoc, |
| 4838 | &upper_brssi_thresh); |
| 4839 | if (QDF_IS_STATUS_ERROR(status)) |
| 4840 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4841 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4842 | sme_set_smps_cfg(adapter->session_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4843 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4844 | upper_brssi_thresh); |
| 4845 | |
| 4846 | status = ucfg_get_lower_brssi_thresh(hdd_ctx->psoc, |
| 4847 | &lower_brssi_thresh); |
| 4848 | if (QDF_IS_STATUS_ERROR(status)) |
| 4849 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4850 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4851 | sme_set_smps_cfg(adapter->session_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4852 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4853 | lower_brssi_thresh); |
| 4854 | |
| 4855 | status = ucfg_get_enable_dtim_1chrx(hdd_ctx->psoc, |
| 4856 | &enable_dtim_1chrx); |
| 4857 | if (QDF_IS_STATUS_ERROR(status)) |
| 4858 | return -EINVAL; |
| 4859 | |
| 4860 | sme_set_smps_cfg(adapter->session_id, |
| 4861 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4862 | enable_dtim_1chrx); |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4863 | } |
| 4864 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4865 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4866 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4867 | hdd_err("unable to get vht_enable2x2"); |
| 4868 | |
| 4869 | if (bval) { |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4870 | hdd_debug("configuring 2x2 mode fw params"); |
| 4871 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4872 | ret = sme_set_cck_tx_fir_override(hdd_ctx->mac_handle, |
| 4873 | adapter->session_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4874 | if (ret) { |
| 4875 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4876 | ret); |
| 4877 | goto error; |
| 4878 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4879 | |
| 4880 | if (hdd_configure_chain_mask(adapter)) |
| 4881 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4882 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4883 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4884 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4885 | hdd_debug("configuring 1x1 mode fw params"); |
| 4886 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4887 | /* |
| 4888 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4889 | * we are passing two value |
| 4890 | * as param_id << 29 | param_value. |
| 4891 | * Below param_value = 0(disable) |
| 4892 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4893 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4894 | WMI_STA_SMPS_PARAM_CMDID, |
| 4895 | HDD_DTIM_1CHAIN_RX_ID << |
| 4896 | HDD_SMPS_PARAM_VALUE_S, |
| 4897 | VDEV_CMD); |
| 4898 | if (ret) { |
| 4899 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4900 | goto error; |
| 4901 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4902 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4903 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4904 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4905 | |
| 4906 | if (hdd_configure_chain_mask(adapter)) |
| 4907 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4908 | } |
| 4909 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4910 | ret = sme_set_enable_mem_deep_sleep(hdd_ctx->mac_handle, |
| 4911 | adapter->session_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4912 | if (ret) { |
| 4913 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4914 | goto error; |
| 4915 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4916 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4917 | status = ucfg_fwol_get_rts_profile(hdd_ctx->psoc, &rts_profile); |
| 4918 | if (QDF_IS_STATUS_ERROR(status)) |
| 4919 | return -EINVAL; |
| 4920 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4921 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4922 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4923 | rts_profile, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4924 | VDEV_CMD); |
| 4925 | if (ret) { |
| 4926 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4927 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4928 | } |
| 4929 | |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4930 | status = ucfg_mlme_get_max_amsdu_num(hdd_ctx->psoc, &max_amsdu_len); |
| 4931 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4932 | hdd_err("Failed to get Max AMSDU Num"); |
| 4933 | goto error; |
| 4934 | } |
| 4935 | |
| 4936 | hdd_debug("SET AMSDU num %d", max_amsdu_len); |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4937 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4938 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4939 | GEN_VDEV_PARAM_AMSDU, |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4940 | max_amsdu_len, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4941 | GEN_CMD); |
| 4942 | if (ret != 0) { |
| 4943 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4944 | goto error; |
| 4945 | } |
| 4946 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4947 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4948 | |
| 4949 | ret = hdd_send_coex_config_params(hdd_ctx, adapter); |
| 4950 | if (ret) { |
| 4951 | hdd_warn("Error initializing coex config params"); |
| 4952 | goto error; |
| 4953 | } |
| 4954 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4955 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4956 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4957 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4958 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4959 | error: |
| 4960 | return -EINVAL; |
| 4961 | } |
| 4962 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4963 | /** |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4964 | * hdd_init_completion() - Initialize Completion Variables |
| 4965 | * @adapter: HDD adapter |
| 4966 | * |
| 4967 | * This function Initialize the completion variables for |
| 4968 | * a particular adapter |
| 4969 | * |
| 4970 | * Return: None |
| 4971 | */ |
| 4972 | static void hdd_init_completion(struct hdd_adapter *adapter) |
| 4973 | { |
| 4974 | init_completion(&adapter->disconnect_comp_var); |
| 4975 | init_completion(&adapter->roaming_comp_var); |
| 4976 | init_completion(&adapter->linkup_event_var); |
| 4977 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 4978 | init_completion(&adapter->rem_on_chan_ready_event); |
| 4979 | init_completion(&adapter->sta_authorized_event); |
| 4980 | init_completion(&adapter->offchannel_tx_event); |
| 4981 | init_completion(&adapter->tx_action_cnf_event); |
| 4982 | init_completion(&adapter->ibss_peer_info_comp); |
| 4983 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
| 4984 | } |
| 4985 | |
| 4986 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4987 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4988 | * @hdd_ctx: global hdd context |
| 4989 | * @session_type: type of the interface to be created |
| 4990 | * @iface_name: User-visible name of the interface |
| 4991 | * @macAddr: MAC address to assign to the interface |
| 4992 | * @name_assign_type: the name of assign type of the netdev |
| 4993 | * @rtnl_held: the rtnl lock hold flag |
| 4994 | * |
| 4995 | * This function open and setup the hdd adpater according to the device |
| 4996 | * type request, assign the name, the mac address assigned, and then prepared |
| 4997 | * the hdd related parameters, queue, lock and ready to start. |
| 4998 | * |
| 4999 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 5000 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5001 | 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] | 5002 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5003 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5004 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5005 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5006 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5007 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 5008 | uint8_t i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5009 | |
| 5010 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 5011 | /* |
| 5012 | * Max limit reached on the number of vdevs configured by the |
| 5013 | * host. Return error |
| 5014 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5015 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 5016 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5017 | return NULL; |
| 5018 | } |
| 5019 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5020 | status = wlan_hdd_validate_mac_address((struct qdf_mac_addr *)macAddr); |
| 5021 | if (QDF_IS_STATUS_ERROR(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5022 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5023 | 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] | 5024 | return NULL; |
| 5025 | } |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5026 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5027 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5028 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5029 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 5030 | " already exists", |
| 5031 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5032 | return NULL; |
| 5033 | } |
| 5034 | |
| 5035 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5036 | case QDF_STA_MODE: |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 5037 | /* |
| 5038 | * Reset locally administered bit for dynamic_mac_list |
| 5039 | * also as while releasing the MAC address for any interface |
| 5040 | * mac will be compared with dynamic mac list |
| 5041 | */ |
| 5042 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
| 5043 | if (!qdf_mem_cmp( |
| 5044 | macAddr, |
| 5045 | &hdd_ctx->dynamic_mac_list[i].bytes[0], |
| 5046 | sizeof(struct qdf_mac_addr))) { |
| 5047 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT( |
| 5048 | hdd_ctx->dynamic_mac_list[i].bytes); |
| 5049 | break; |
| 5050 | } |
| 5051 | } |
| 5052 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5053 | /* Reset locally administered bit if the device mode is STA */ |
| 5054 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 5055 | hdd_debug("locally administered bit reset in sta mode: " |
| 5056 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5057 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5058 | case QDF_P2P_CLIENT_MODE: |
| 5059 | case QDF_P2P_DEVICE_MODE: |
| 5060 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 5061 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5062 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5063 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 5064 | name_assign_type, |
| 5065 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5066 | |
| 5067 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5068 | hdd_err("failed to allocate adapter for session %d", |
| 5069 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5070 | return NULL; |
| 5071 | } |
| 5072 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5073 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5074 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5075 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5076 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5077 | else if (QDF_MONITOR_MODE == session_type) |
| 5078 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5079 | else |
| 5080 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5081 | |
| 5082 | adapter->device_mode = session_type; |
| 5083 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5084 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5085 | /* |
| 5086 | * Workqueue which gets scheduled in IPv4 notification |
| 5087 | * callback |
| 5088 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5089 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5090 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5091 | |
| 5092 | #ifdef WLAN_NS_OFFLOAD |
| 5093 | /* |
| 5094 | * Workqueue which gets scheduled in IPv6 |
| 5095 | * notification callback. |
| 5096 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5097 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5098 | hdd_ipv6_notifier_work_queue); |
| 5099 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5100 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5101 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5102 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5103 | |
| 5104 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5105 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5106 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5107 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5108 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5109 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5110 | hdd_nud_init_tracking(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 5111 | if (adapter->device_mode == QDF_STA_MODE || |
| 5112 | adapter->device_mode == QDF_P2P_DEVICE_MODE) |
| 5113 | hdd_sysfs_create_adapter_root_obj(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5114 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 5115 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 5116 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5117 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5118 | case QDF_P2P_GO_MODE: |
| 5119 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5120 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 5121 | name_assign_type, |
| 5122 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5123 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5124 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5125 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5126 | return NULL; |
| 5127 | } |
| 5128 | |
| 5129 | adapter->wdev.iftype = |
| 5130 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5131 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5132 | NL80211_IFTYPE_P2P_GO; |
| 5133 | adapter->device_mode = session_type; |
| 5134 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 5135 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5136 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5137 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5138 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5139 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5140 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5141 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5142 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5143 | |
| 5144 | /* |
| 5145 | * Workqueue which gets scheduled in IPv4 notification |
| 5146 | * callback |
| 5147 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5148 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5149 | hdd_ipv4_notifier_work_queue); |
| 5150 | |
| 5151 | #ifdef WLAN_NS_OFFLOAD |
| 5152 | /* |
| 5153 | * Workqueue which gets scheduled in IPv6 |
| 5154 | * notification callback. |
| 5155 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5156 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5157 | hdd_ipv6_notifier_work_queue); |
| 5158 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5159 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5160 | case QDF_FTM_MODE: |
| 5161 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 5162 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 5163 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5164 | if (NULL == adapter) { |
| 5165 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 5166 | return NULL; |
| 5167 | } |
| 5168 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5169 | adapter->device_mode = session_type; |
| 5170 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5171 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5172 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5173 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5174 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5175 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5176 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5177 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5178 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5179 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5180 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5181 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5182 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5183 | return NULL; |
| 5184 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5185 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5186 | qdf_spinlock_create(&adapter->vdev_lock); |
| 5187 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5188 | hdd_init_completion(adapter); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5189 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 5190 | qdf_list_create(&adapter->blocked_scan_request_q, WLAN_MAX_SCAN_COUNT); |
| 5191 | qdf_mutex_create(&adapter->blocked_scan_request_q_lock); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5192 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5193 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5194 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5195 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5196 | } |
| 5197 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5198 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5199 | if (NULL != adapter) { |
| 5200 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5201 | adapter = NULL; |
| 5202 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5203 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5204 | return NULL; |
| 5205 | } |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 5206 | hdd_apf_context_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5207 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5208 | if (QDF_STATUS_SUCCESS == status) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5209 | policy_mgr_set_concurrency_mode(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5210 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5211 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5212 | /* Adapter successfully added. Increment the vdev count */ |
| 5213 | hdd_ctx->current_intf_count++; |
| 5214 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5215 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5216 | hdd_ctx->current_intf_count); |
| 5217 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 5218 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5219 | } |
| 5220 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 5221 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 5222 | hdd_err("Interface %s wow debug_fs init failed", |
| 5223 | netdev_name(adapter->dev)); |
| 5224 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 5225 | hdd_register_hl_netdev_fc_timer(adapter, |
| 5226 | hdd_tx_resume_timer_expired_handler); |
| 5227 | |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 5228 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 5229 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5230 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 5231 | if (adapter->device_mode == QDF_STA_MODE) |
| 5232 | wlan_hdd_debugfs_csr_init(adapter); |
| 5233 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5234 | return adapter; |
| 5235 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5236 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5237 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 5238 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5239 | |
| 5240 | return NULL; |
| 5241 | } |
| 5242 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5243 | static void __hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5244 | struct hdd_adapter *adapter, |
| 5245 | bool rtnl_held) |
| 5246 | { |
| 5247 | qdf_list_destroy(&adapter->blocked_scan_request_q); |
| 5248 | qdf_mutex_destroy(&adapter->blocked_scan_request_q_lock); |
| 5249 | policy_mgr_clear_concurrency_mode(hdd_ctx->psoc, adapter->device_mode); |
| 5250 | |
| 5251 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5252 | |
| 5253 | if (hdd_ctx->current_intf_count != 0) |
| 5254 | hdd_ctx->current_intf_count--; |
| 5255 | } |
| 5256 | |
| 5257 | void hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5258 | struct hdd_adapter *adapter, |
| 5259 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5260 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5261 | /* |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5262 | * Stop the global bus bandwidth timer while touching the adapter list |
| 5263 | * to avoid bad memory access by the timer handler. |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5264 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5265 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5266 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5267 | hdd_remove_adapter(hdd_ctx, adapter); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5268 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5269 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5270 | /* conditionally restart the bw timer */ |
| 5271 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5272 | } |
| 5273 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5274 | 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] | 5275 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5276 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5277 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5278 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5279 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5280 | while (QDF_IS_STATUS_SUCCESS(hdd_remove_front_adapter(hdd_ctx, |
| 5281 | &adapter))) { |
| 5282 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
| 5283 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
| 5284 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5285 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5286 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5287 | } |
| 5288 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5289 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5290 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5291 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5292 | tSirUpdateIE updateIE; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5293 | mac_handle_t mac_handle; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5294 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5295 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5296 | case QDF_STA_MODE: |
| 5297 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5298 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5299 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5300 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5301 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5302 | break; |
| 5303 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5304 | case QDF_SAP_MODE: |
| 5305 | case QDF_P2P_GO_MODE: |
| 5306 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5307 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5308 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5309 | break; |
| 5310 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5311 | case QDF_FTM_MODE: |
| 5312 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5313 | default: |
| 5314 | /* |
| 5315 | * wlan_hdd_reset_prob_rspies should not have been called |
| 5316 | * for these kind of devices |
| 5317 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5318 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5319 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5320 | return; |
| 5321 | } |
| 5322 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5323 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5324 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5325 | updateIE.ieBufferlength = 0; |
| 5326 | updateIE.pAdditionIEBuffer = NULL; |
| 5327 | updateIE.append = true; |
| 5328 | updateIE.notify = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5329 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 5330 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5331 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5332 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5333 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5334 | } |
| 5335 | } |
| 5336 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5337 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 5338 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5339 | { |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5340 | return hdd_stop_adapter_ext(hdd_ctx, adapter, 0); |
| 5341 | } |
| 5342 | |
| 5343 | QDF_STATUS hdd_stop_adapter_ext(struct hdd_context *hdd_ctx, |
| 5344 | struct hdd_adapter *adapter, |
| 5345 | enum hdd_adapter_stop_flag_t flag) |
| 5346 | { |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5347 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 5348 | struct hdd_station_ctx *sta_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 |
| 5425 | (WLAN_WAIT_TIME_DISCONNECT)); |
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 | |
| 5462 | if (wlan_hdd_try_disconnect(adapter)) { |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5463 | hdd_err("Can't disconnect adapter"); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5464 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 5465 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5466 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5467 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5468 | break; |
| 5469 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5470 | case QDF_MONITOR_MODE: |
| 5471 | wlan_hdd_scan_abort(adapter); |
| 5472 | hdd_deregister_tx_flow_control(adapter); |
| 5473 | hdd_vdev_destroy(adapter); |
| 5474 | break; |
| 5475 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5476 | case QDF_SAP_MODE: |
Will Huang | 7049bae | 2018-08-13 17:25:02 +0800 | [diff] [blame] | 5477 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5478 | cds_flush_delayed_work(&adapter->acs_pending_work); |
| 5479 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5480 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5481 | |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5482 | wlan_hdd_scan_abort(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5483 | |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5484 | sap_config = &adapter->session.ap.sap_config; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5485 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 5486 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 5487 | ucfg_ipa_flush(hdd_ctx->pdev); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5488 | |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5489 | if (!(flag & HDD_IN_CAC_WORK_TH_CONTEXT)) |
| 5490 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5491 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5492 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5493 | case QDF_P2P_GO_MODE: |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5494 | cds_flush_work(&adapter->sap_stop_bss_work); |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5495 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5496 | wlan_hdd_undo_acs(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5497 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5498 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5499 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5500 | |
| 5501 | hdd_deregister_tx_flow_control(adapter); |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5502 | hdd_destroy_acs_timer(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5503 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5504 | mutex_lock(&hdd_ctx->sap_lock); |
| 5505 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5506 | status = wlansap_stop_bss( |
| 5507 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5508 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5509 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5510 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5511 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5512 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5513 | qdf_stop_bss_event); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5514 | status = qdf_wait_for_event_completion( |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5515 | &hostapd_state->qdf_stop_bss_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 5516 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5517 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5518 | hdd_err("failure waiting for wlansap_stop_bss %d", |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5519 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5520 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5521 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5522 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5523 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5524 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5525 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5526 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5527 | adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5528 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5529 | adapter->device_mode, |
| 5530 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5531 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5532 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5533 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5534 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5535 | updateIE.ieBufferlength = 0; |
| 5536 | updateIE.pAdditionIEBuffer = NULL; |
| 5537 | updateIE.append = false; |
| 5538 | updateIE.notify = false; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5539 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5540 | /* Probe bcn reset */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5541 | status = sme_update_add_ie(mac_handle, &updateIE, |
| 5542 | eUPDATE_IE_PROBE_BCN); |
| 5543 | if (status == QDF_STATUS_E_FAILURE) |
| 5544 | hdd_err("Could not pass PROBE_RSP_BCN to PE"); |
| 5545 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5546 | /* Assoc resp reset */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5547 | status = sme_update_add_ie(mac_handle, &updateIE, |
| 5548 | eUPDATE_IE_ASSOC_RESP); |
| 5549 | if (status == QDF_STATUS_E_FAILURE) |
| 5550 | hdd_err("Could not pass ASSOC_RSP to PE"); |
| 5551 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5552 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5553 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5554 | } |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5555 | clear_bit(SOFTAP_INIT_DONE, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5556 | qdf_mem_free(adapter->session.ap.beacon); |
| 5557 | adapter->session.ap.beacon = NULL; |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5558 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5559 | /* |
| 5560 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5561 | */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5562 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5563 | if (vdev) { |
| 5564 | if (policy_mgr_is_dnsc_set(vdev)) |
| 5565 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5566 | hdd_objmgr_put_vdev(adapter); |
| 5567 | } |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5568 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5569 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5570 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5571 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5572 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5573 | #endif |
| 5574 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5575 | |
| 5576 | hdd_vdev_destroy(adapter); |
| 5577 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5578 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5579 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5580 | case QDF_OCB_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5581 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5582 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5583 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 5584 | sta_ctx->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5585 | hdd_deregister_tx_flow_control(adapter); |
| 5586 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5587 | break; |
| 5588 | default: |
| 5589 | break; |
| 5590 | } |
| 5591 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 5592 | hdd_deregister_hl_netdev_fc_timer(adapter); |
| 5593 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5594 | if (adapter->scan_info.default_scan_ies) { |
| 5595 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5596 | adapter->scan_info.default_scan_ies = NULL; |
| 5597 | } |
| 5598 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5599 | hdd_exit(); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5600 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5601 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5602 | } |
| 5603 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5604 | /** |
| 5605 | * hdd_deinit_all_adapters - deinit all adapters |
| 5606 | * @hdd_ctx: HDD context |
| 5607 | * @rtnl_held: True if RTNL lock held |
| 5608 | * |
| 5609 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5610 | 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] | 5611 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5612 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5613 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5614 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5615 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5616 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5617 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5618 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5619 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5620 | } |
| 5621 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5622 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5623 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5624 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5625 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5626 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5627 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5628 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5629 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5630 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5631 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5632 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5633 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5634 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5635 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5636 | } |
| 5637 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5638 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5639 | struct hdd_adapter *adapter) |
| 5640 | { |
| 5641 | switch (adapter->device_mode) { |
| 5642 | case QDF_STA_MODE: |
| 5643 | case QDF_P2P_CLIENT_MODE: |
| 5644 | case QDF_IBSS_MODE: |
| 5645 | case QDF_P2P_DEVICE_MODE: |
| 5646 | case QDF_NDI_MODE: |
| 5647 | wlan_hdd_scan_abort(adapter); |
| 5648 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5649 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5650 | struct wlan_objmgr_vdev *vdev; |
| 5651 | |
| 5652 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5653 | if (vdev) { |
| 5654 | wlan_cfg80211_sched_scan_stop(vdev); |
| 5655 | hdd_objmgr_put_vdev(adapter); |
| 5656 | } |
| 5657 | } |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5658 | break; |
| 5659 | case QDF_P2P_GO_MODE: |
| 5660 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5661 | break; |
| 5662 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5663 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5664 | wlan_hdd_undo_acs(adapter); |
| 5665 | break; |
| 5666 | default: |
| 5667 | break; |
| 5668 | } |
| 5669 | } |
| 5670 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5671 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5672 | /** |
| 5673 | * hdd_adapter_abort_tx_flow() - Abort the tx flow control |
| 5674 | * @pAdapter: pointer to hdd_adapter_t |
| 5675 | * |
| 5676 | * Resume tx and stop the tx flow control timer if the tx is paused |
| 5677 | * and the flow control timer is running. This function is called by |
| 5678 | * SSR to avoid the inconsistency of tx status before and after SSR. |
| 5679 | * |
| 5680 | * Return: void |
| 5681 | */ |
| 5682 | static void hdd_adapter_abort_tx_flow(struct hdd_adapter *adapter) |
| 5683 | { |
| 5684 | if (adapter->hdd_stats.tx_rx_stats.is_txflow_paused && |
| 5685 | QDF_TIMER_STATE_RUNNING == |
| 5686 | qdf_mc_timer_get_current_state( |
| 5687 | &adapter->tx_flow_control_timer)) { |
| 5688 | hdd_tx_resume_timer_expired_handler(adapter); |
| 5689 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 5690 | } |
| 5691 | } |
| 5692 | #endif |
| 5693 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5694 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5695 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5696 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5697 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5698 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5699 | int sta_id; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5700 | bool value; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5701 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5702 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5703 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5704 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5705 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5706 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5707 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5708 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5709 | qdf_opmode_str(adapter->device_mode), |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5710 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5711 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5712 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5713 | hdd_adapter_abort_tx_flow(adapter); |
| 5714 | #endif |
| 5715 | |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5716 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5717 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5718 | /* Stop tdls timers */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5719 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5720 | if (vdev) { |
| 5721 | hdd_notify_tdls_reset_adapter(vdev); |
| 5722 | hdd_objmgr_put_vdev(adapter); |
| 5723 | } |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5724 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5725 | } |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 5726 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5727 | if (value && |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5728 | adapter->device_mode == QDF_SAP_MODE) { |
| 5729 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5730 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5731 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5732 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5733 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5734 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5735 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5736 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5737 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5738 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5739 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5740 | } |
Nijun Gong | 104ccc7 | 2018-08-07 10:43:56 +0800 | [diff] [blame] | 5741 | /* |
| 5742 | * Clear fc flag if it was set before SSR to avoid TX queues |
| 5743 | * permanently stopped after SSR. |
| 5744 | * Here WLAN_START_ALL_NETIF_QUEUE will actually not start any |
| 5745 | * queue since it's blocked by reason WLAN_CONTROL_PATH. |
| 5746 | */ |
| 5747 | if (adapter->pause_map & (1 << WLAN_DATA_FLOW_CONTROL)) |
| 5748 | wlan_hdd_netif_queue_control(adapter, |
| 5749 | WLAN_START_ALL_NETIF_QUEUE, |
| 5750 | WLAN_DATA_FLOW_CONTROL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5751 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5752 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5753 | |
| 5754 | hdd_deinit_tx_rx(adapter); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5755 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5756 | adapter->device_mode, adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5757 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5758 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5759 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5760 | hdd_wmm_adapter_close(adapter); |
| 5761 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5762 | } |
| 5763 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5764 | if (adapter->device_mode == QDF_STA_MODE) |
| 5765 | hdd_clear_fils_connection_info(adapter); |
| 5766 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5767 | if (adapter->device_mode == QDF_SAP_MODE) { |
Jingxiang Ge | ec11359 | 2018-08-09 15:40:39 +0800 | [diff] [blame] | 5768 | wlansap_cleanup_cac_timer( |
| 5769 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5770 | /* |
| 5771 | * If adapter is SAP, set session ID to invalid |
| 5772 | * since SAP session will be cleanup during SSR. |
| 5773 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5774 | wlansap_set_invalid_session( |
| 5775 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5776 | } |
| 5777 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5778 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5779 | if (adapter->device_mode == QDF_STA_MODE || |
| 5780 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5781 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5782 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5783 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5784 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5785 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
Wu Gao | 6b81fc5 | 2018-05-24 19:27:27 +0800 | [diff] [blame] | 5786 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5787 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5788 | if (adapter->sta_info[sta_id].in_use) { |
| 5789 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5790 | sta_id); |
| 5791 | hdd_softap_deregister_sta(adapter, |
| 5792 | sta_id); |
| 5793 | adapter->sta_info[sta_id].in_use = 0; |
| 5794 | } |
| 5795 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5796 | } |
| 5797 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5798 | hdd_nud_ignore_tracking(adapter, true); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5799 | hdd_nud_reset_tracking(adapter); |
| 5800 | hdd_nud_flush_work(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5801 | hdd_set_disconnect_status(adapter, false); |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5802 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5803 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5804 | hdd_softap_deinit_tx_rx(adapter); |
Tiger Yu | 8c38770 | 2018-07-06 16:56:42 +0800 | [diff] [blame] | 5805 | hdd_deregister_tx_flow_control(adapter); |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5806 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5807 | /* Destroy vdev which will be recreated during reinit. */ |
| 5808 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5809 | } |
| 5810 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5811 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5812 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5813 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5814 | } |
| 5815 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5816 | bool hdd_is_any_interface_open(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5817 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5818 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5819 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5820 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5821 | hdd_info("FTM mode, don't close the module"); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5822 | return true; |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5823 | } |
| 5824 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5825 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5826 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5827 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5828 | return true; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5829 | } |
| 5830 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5831 | return false; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5832 | } |
| 5833 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5834 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5835 | { |
| 5836 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5837 | return true; |
| 5838 | else |
| 5839 | return false; |
| 5840 | } |
| 5841 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5842 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5843 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5844 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5845 | struct ieee80211_channel *channel, |
| 5846 | const u8 *bssid, const u8 *ssid, |
| 5847 | size_t ssid_len) |
| 5848 | { |
| 5849 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5850 | ssid, ssid_len, |
| 5851 | WLAN_CAPABILITY_ESS, |
| 5852 | WLAN_CAPABILITY_ESS); |
| 5853 | } |
| 5854 | #else |
| 5855 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5856 | struct ieee80211_channel *channel, |
| 5857 | const u8 *bssid, const u8 *ssid, |
| 5858 | size_t ssid_len) |
| 5859 | { |
| 5860 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5861 | ssid, ssid_len, |
| 5862 | IEEE80211_BSS_TYPE_ESS, |
| 5863 | IEEE80211_PRIVACY_ANY); |
| 5864 | } |
| 5865 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5866 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5867 | #if defined CFG80211_CONNECT_BSS || \ |
| 5868 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5869 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5870 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5871 | /** |
| 5872 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5873 | * @timeout_reason: reason for connect timeout |
| 5874 | * |
| 5875 | * This function is used to convert host timeout |
| 5876 | * reason enum to kernel specific enum. |
| 5877 | * |
| 5878 | * Return: nl timeout enum |
| 5879 | */ |
| 5880 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5881 | tSirResultCodes timeout_reason) |
| 5882 | { |
| 5883 | switch (timeout_reason) { |
| 5884 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5885 | return NL80211_TIMEOUT_SCAN; |
| 5886 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5887 | return NL80211_TIMEOUT_AUTH; |
| 5888 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5889 | return NL80211_TIMEOUT_ASSOC; |
| 5890 | default: |
| 5891 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5892 | } |
| 5893 | } |
| 5894 | |
| 5895 | /** |
| 5896 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5897 | * @dev: network device |
| 5898 | * @bssid: bssid to which we want to associate |
| 5899 | * @timeout_reason: reason for connect timeout |
| 5900 | * |
| 5901 | * This API is used to send connection timeout reason to supplicant |
| 5902 | * |
| 5903 | * Return: void |
| 5904 | */ |
| 5905 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5906 | const u8 *bssid, |
| 5907 | tSirResultCodes timeout_reason) |
| 5908 | { |
| 5909 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5910 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5911 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5912 | |
| 5913 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5914 | nl_timeout_reason); |
| 5915 | } |
| 5916 | |
| 5917 | /** |
| 5918 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5919 | * @dev: network device |
| 5920 | * @bssid: bssid to which we want to associate |
| 5921 | * @req_ie: Request Information Element |
| 5922 | * @req_ie_len: len of the req IE |
| 5923 | * @resp_ie: Response IE |
| 5924 | * @resp_ie_len: len of ht response IE |
| 5925 | * @status: status |
| 5926 | * @gfp: Kernel Flag |
| 5927 | * @timeout_reason: reason for connect timeout |
| 5928 | * |
| 5929 | * Return: void |
| 5930 | */ |
| 5931 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5932 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5933 | size_t req_ie_len, const u8 *resp_ie, |
| 5934 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5935 | tSirResultCodes timeout_reason) |
| 5936 | { |
| 5937 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5938 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5939 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5940 | |
| 5941 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5942 | resp_ie, resp_ie_len, status, gfp, |
| 5943 | nl_timeout_reason); |
| 5944 | } |
| 5945 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5946 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5947 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5948 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5949 | const u8 *bssid, |
| 5950 | tSirResultCodes timeout_reason) |
| 5951 | { |
| 5952 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5953 | } |
| 5954 | #endif |
| 5955 | |
| 5956 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5957 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5958 | size_t req_ie_len, const u8 *resp_ie, |
| 5959 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5960 | tSirResultCodes timeout_reason) |
| 5961 | { |
| 5962 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5963 | resp_ie, resp_ie_len, status, gfp); |
| 5964 | } |
| 5965 | #endif |
| 5966 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5967 | /** |
| 5968 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5969 | * @dev: network device |
| 5970 | * @bssid: bssid to which we want to associate |
| 5971 | * @req_ie: Request Information Element |
| 5972 | * @req_ie_len: len of the req IE |
| 5973 | * @resp_ie: Response IE |
| 5974 | * @resp_ie_len: len of ht response IE |
| 5975 | * @status: status |
| 5976 | * @gfp: Kernel Flag |
| 5977 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5978 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5979 | * |
| 5980 | * The API is a wrapper to send connection status to supplicant |
| 5981 | * |
| 5982 | * Return: Void |
| 5983 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5984 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5985 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5986 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5987 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5988 | size_t req_ie_len, const u8 *resp_ie, |
| 5989 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5990 | bool connect_timeout, |
| 5991 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5992 | { |
| 5993 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5994 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5995 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5996 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5997 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5998 | } |
| 5999 | #else |
| 6000 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6001 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6002 | size_t req_ie_len, const u8 *resp_ie, |
| 6003 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6004 | bool connect_timeout, |
| 6005 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6006 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6007 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6008 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6009 | } |
| 6010 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6011 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6012 | #if defined(WLAN_FEATURE_FILS_SK) |
| 6013 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 6014 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 6015 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 6016 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6017 | /** |
| 6018 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 6019 | * @fils_params: connect response to supplicant |
| 6020 | * @fils_kek: FILS kek |
| 6021 | * @fils_kek_len: FILS kek length |
| 6022 | * @pmk: FILS PMK |
| 6023 | * @pmk_len: FILS PMK length |
| 6024 | * @pmkid: PMKID |
| 6025 | * @fils_seq_num: FILS Seq number |
| 6026 | * |
| 6027 | * Return: None |
| 6028 | */ |
| 6029 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6030 | *fils_params, const uint8_t *fils_kek, |
| 6031 | size_t fils_kek_len, const uint8_t *pmk, |
| 6032 | size_t pmk_len, const uint8_t *pmkid, |
| 6033 | uint16_t fils_seq_num) |
| 6034 | { |
| 6035 | /* Increament seq number to be used for next FILS */ |
| 6036 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 6037 | fils_params->update_erp_next_seq_num = true; |
| 6038 | fils_params->fils_kek = fils_kek; |
| 6039 | fils_params->fils_kek_len = fils_kek_len; |
| 6040 | fils_params->pmk = pmk; |
| 6041 | fils_params->pmk_len = pmk_len; |
| 6042 | fils_params->pmkid = pmkid; |
| 6043 | } |
| 6044 | #else |
| 6045 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6046 | *fils_params, const uint8_t |
| 6047 | *fils_kek, size_t fils_kek_len, |
| 6048 | const uint8_t *pmk, size_t pmk_len, |
| 6049 | const uint8_t *pmkid, |
| 6050 | uint16_t fils_seq_num) |
| 6051 | { } |
| 6052 | #endif |
| 6053 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6054 | void hdd_update_hlp_info(struct net_device *dev, |
| 6055 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6056 | { |
| 6057 | struct sk_buff *skb; |
| 6058 | uint16_t skb_len; |
| 6059 | struct llc_snap_hdr_t *llc_hdr; |
| 6060 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6061 | uint8_t *hlp_data; |
| 6062 | uint16_t hlp_data_len; |
| 6063 | struct fils_join_rsp_params *roam_fils_params |
| 6064 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6065 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6066 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6067 | if (!roam_fils_params) { |
| 6068 | hdd_err("FILS Roam Param NULL"); |
| 6069 | return; |
| 6070 | } |
| 6071 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 6072 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6073 | hdd_err("FILS HLP Data NULL, len %d", |
| 6074 | roam_fils_params->hlp_data_len); |
| 6075 | return; |
| 6076 | } |
| 6077 | |
| 6078 | hlp_data = roam_fils_params->hlp_data; |
| 6079 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 6080 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6081 | /* Calculate skb length */ |
| 6082 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 6083 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 6084 | if (skb == NULL) { |
| 6085 | hdd_err("HLP packet nbuf alloc fails"); |
| 6086 | return; |
| 6087 | } |
| 6088 | |
| 6089 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 6090 | QDF_MAC_ADDR_SIZE); |
| 6091 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 6092 | QDF_MAC_ADDR_SIZE); |
| 6093 | |
| 6094 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 6095 | if (IS_SNAP(llc_hdr)) { |
| 6096 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6097 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6098 | } |
| 6099 | |
| 6100 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 6101 | |
| 6102 | /* |
| 6103 | * This HLP packet is formed from HLP info encapsulated |
| 6104 | * in assoc response frame which is AEAD encrypted. |
| 6105 | * Hence, this checksum validation can be set unnecessary. |
| 6106 | * i.e. network layer need not worry about checksum. |
| 6107 | */ |
| 6108 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 6109 | |
| 6110 | status = hdd_rx_packet_cbk(padapter, skb); |
| 6111 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6112 | hdd_err("Sending HLP packet fails"); |
| 6113 | return; |
| 6114 | } |
| 6115 | hdd_debug("send HLP packet to netif successfully"); |
| 6116 | } |
| 6117 | |
| 6118 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6119 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 6120 | * @dev: network device |
| 6121 | * @bssid: bssid to which we want to associate |
| 6122 | * @bss: cfg80211 bss info |
| 6123 | * @roam_info: information about connected bss |
| 6124 | * @req_ie: Request Information Element |
| 6125 | * @req_ie_len: len of the req IE |
| 6126 | * @resp_ie: Response IE |
| 6127 | * @resp_ie_len: len of ht response IE |
| 6128 | * @status: status |
| 6129 | * @gfp: allocation flags |
| 6130 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6131 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6132 | * |
| 6133 | * This API is used as wrapper to send FILS key/sequence number |
| 6134 | * params etc. to supplicant in case of FILS connection |
| 6135 | * |
| 6136 | * Return: None |
| 6137 | */ |
| 6138 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6139 | struct cfg80211_bss *bss, |
| 6140 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6141 | const u8 *req_ie, size_t req_ie_len, |
| 6142 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6143 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6144 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6145 | { |
| 6146 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6147 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6148 | struct fils_join_rsp_params *roam_fils_params = |
| 6149 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6150 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6151 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 6152 | |
| 6153 | if (!roam_fils_params) { |
| 6154 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 6155 | } else { |
| 6156 | fils_params.status = status; |
| 6157 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 6158 | fils_params.timeout_reason = |
| 6159 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6160 | fils_params.req_ie = req_ie; |
| 6161 | fils_params.req_ie_len = req_ie_len; |
| 6162 | fils_params.resp_ie = resp_ie; |
| 6163 | fils_params.resp_ie_len = resp_ie_len; |
| 6164 | fils_params.bss = bss; |
| 6165 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 6166 | roam_fils_params->kek_len, |
| 6167 | roam_fils_params->fils_pmk, |
| 6168 | roam_fils_params->fils_pmk_len, |
| 6169 | roam_fils_params->fils_pmkid, |
| 6170 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 6171 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6172 | } |
| 6173 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 6174 | fils_params.status, |
| 6175 | fils_params.fils_erp_next_seq_num); |
| 6176 | |
| 6177 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 6178 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6179 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6180 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6181 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6182 | /* Clear all the FILS key info */ |
| 6183 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 6184 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 6185 | if (roam_fils_params) |
| 6186 | qdf_mem_free(roam_fils_params); |
| 6187 | roam_info->fils_join_rsp = NULL; |
| 6188 | } |
| 6189 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6190 | static inline void |
| 6191 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6192 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6193 | const u8 *req_ie, size_t req_ie_len, |
| 6194 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 6195 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6196 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6197 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6198 | #endif |
| 6199 | #endif |
| 6200 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6201 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 6202 | (defined(CFG80211_CONNECT_DONE) || \ |
| 6203 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6204 | /** |
| 6205 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 6206 | * supplicant. |
| 6207 | * @dev: network device |
| 6208 | * @bssid: bssid to which we want to associate |
| 6209 | * @bss: cfg80211 bss info |
| 6210 | * @roam_info: information about connected bss |
| 6211 | * @req_ie: Request Information Element |
| 6212 | * @req_ie_len: len of the req IE |
| 6213 | * @resp_ie: Response IE |
| 6214 | * @resp_ie_len: len of ht response IE |
| 6215 | * @status: status |
| 6216 | * @gfp: allocation flags |
| 6217 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6218 | * @timeout_reason: reason for connect timeout |
| 6219 | * |
| 6220 | * The API is a wrapper to send connection status to supplicant |
| 6221 | * |
| 6222 | * Return: 0 if success else failure |
| 6223 | */ |
| 6224 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 6225 | const u8 *bssid, |
| 6226 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6227 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6228 | size_t req_ie_len, const u8 *resp_ie, |
| 6229 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6230 | bool connect_timeout, |
| 6231 | tSirResultCodes timeout_reason) |
| 6232 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6233 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6234 | if (!roam_info || !roam_info->is_fils_connection) |
| 6235 | return -EINVAL; |
| 6236 | |
| 6237 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 6238 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6239 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6240 | return 0; |
| 6241 | } |
| 6242 | #else |
| 6243 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 6244 | const u8 *bssid, |
| 6245 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6246 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6247 | size_t req_ie_len, const u8 *resp_ie, |
| 6248 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6249 | bool connect_timeout, |
| 6250 | tSirResultCodes timeout_reason) |
| 6251 | { |
| 6252 | return -EINVAL; |
| 6253 | } |
| 6254 | #endif |
| 6255 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6256 | /** |
| 6257 | * hdd_connect_result() - API to send connection status to supplicant |
| 6258 | * @dev: network device |
| 6259 | * @bssid: bssid to which we want to associate |
| 6260 | * @roam_info: information about connected bss |
| 6261 | * @req_ie: Request Information Element |
| 6262 | * @req_ie_len: len of the req IE |
| 6263 | * @resp_ie: Response IE |
| 6264 | * @resp_ie_len: len of ht response IE |
| 6265 | * @status: status |
| 6266 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6267 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6268 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6269 | * |
| 6270 | * The API is a wrapper to send connection status to supplicant |
| 6271 | * and allow runtime suspend |
| 6272 | * |
| 6273 | * Return: Void |
| 6274 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6275 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6276 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6277 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6278 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6279 | bool connect_timeout, |
| 6280 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6281 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6282 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6283 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 6284 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6285 | |
| 6286 | if (WLAN_STATUS_SUCCESS == status) { |
| 6287 | struct ieee80211_channel *chan; |
| 6288 | int freq; |
| 6289 | int chan_no = roam_info->pBssDesc->channelId; |
| 6290 | |
| 6291 | if (chan_no <= 14) |
| 6292 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6293 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6294 | else |
| 6295 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6296 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6297 | |
| 6298 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 6299 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 6300 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 6301 | roam_info->u.pConnectedProfile->SSID.length); |
| 6302 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6303 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6304 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 6305 | roam_info, req_ie, req_ie_len, resp_ie, |
| 6306 | resp_ie_len, status, gfp, connect_timeout, |
| 6307 | timeout_reason) != 0) { |
| 6308 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 6309 | req_ie_len, resp_ie, resp_ie_len, |
| 6310 | status, gfp, connect_timeout, timeout_reason); |
| 6311 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6312 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6313 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6314 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6315 | } |
| 6316 | #else |
| 6317 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6318 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6319 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6320 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6321 | bool connect_timeout, |
| 6322 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6323 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6324 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 6325 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6326 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6327 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 6328 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 6329 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6330 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6331 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6332 | } |
| 6333 | #endif |
| 6334 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6335 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6336 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 6337 | uint32_t bandwidth) |
| 6338 | { |
| 6339 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6340 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 6341 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 6342 | QDF_STATUS status; |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6343 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6344 | struct qdf_mac_addr bssid; |
| 6345 | struct csr_roam_profile roam_profile; |
| 6346 | struct ch_params ch_params; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6347 | eConnectionState connstate; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6348 | |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6349 | if (hdd_get_conparam() != QDF_GLOBAL_MONITOR_MODE && |
| 6350 | adapter->device_mode != QDF_STA_MODE) { |
| 6351 | 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] | 6352 | return -EINVAL; |
| 6353 | } |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6354 | if (adapter->device_mode == QDF_STA_MODE && |
| 6355 | hdd_ctx->config->enable_change_channel_bandwidth) { |
| 6356 | connstate = sta_ctx->conn_info.connState; |
| 6357 | if (eConnectionState_Associated == connstate || |
| 6358 | eConnectionState_Connecting == connstate) { |
| 6359 | return -EINVAL; |
| 6360 | } |
| 6361 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6362 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 6363 | /* Validate Channel */ |
| 6364 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6365 | hdd_err("Channel %d Not supported", chan); |
| 6366 | return -EINVAL; |
| 6367 | } |
| 6368 | |
| 6369 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 6370 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 6371 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 6372 | return -EINVAL; |
| 6373 | } |
| 6374 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 6375 | (bandwidth != CH_WIDTH_MAX)) { |
| 6376 | hdd_err("Only BW20 possible on channel 14"); |
| 6377 | return -EINVAL; |
| 6378 | } |
| 6379 | } |
| 6380 | |
| 6381 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6382 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 6383 | (bandwidth != CH_WIDTH_MAX)) { |
| 6384 | hdd_err("Only BW20 possible on channel 165"); |
| 6385 | return -EINVAL; |
| 6386 | } |
| 6387 | } |
| 6388 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6389 | hdd_debug("Set monitor mode Channel %d", chan); |
| 6390 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 6391 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 6392 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 6393 | roam_profile.phyMode = ch_info->phy_mode; |
| 6394 | roam_profile.ch_params.ch_width = bandwidth; |
| 6395 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6396 | if (hdd_ctx->config->enable_change_channel_bandwidth && |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6397 | (!sme_find_session_by_bssid(mac_handle, adapter->mac_addr.bytes))) { |
| 6398 | status = sme_create_mon_session(mac_handle, |
Rajeev Kumar Sirasanagandla | e3b5991 | 2018-08-24 15:53:31 +0530 | [diff] [blame] | 6399 | adapter->mac_addr.bytes, |
| 6400 | adapter->session_id); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6401 | if (status != QDF_STATUS_SUCCESS) { |
| 6402 | hdd_err("Status: %d Failed to create session.", |
| 6403 | status); |
| 6404 | return qdf_status_to_os_return(status); |
| 6405 | } |
| 6406 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6407 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 6408 | QDF_MAC_ADDR_SIZE); |
| 6409 | |
| 6410 | ch_params.ch_width = bandwidth; |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6411 | wlan_reg_set_channel_params(hdd_ctx->pdev, chan, 0, &ch_params); |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6412 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 6413 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 6414 | return -EINVAL; |
| 6415 | } |
| 6416 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 6417 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 6418 | hdd_err("Failed to change hw mode"); |
| 6419 | return -EINVAL; |
| 6420 | } |
| 6421 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 6422 | status = sme_roam_channel_change_req(hdd_ctx->mac_handle, |
| 6423 | bssid, &ch_params, |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6424 | &roam_profile); |
| 6425 | if (status) { |
| 6426 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 6427 | status); |
| 6428 | } |
| 6429 | |
| 6430 | adapter->mon_chan = chan; |
| 6431 | adapter->mon_bandwidth = bandwidth; |
| 6432 | return qdf_status_to_os_return(status); |
| 6433 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6434 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6435 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6436 | #ifdef MSM_PLATFORM |
| 6437 | /** |
| 6438 | * hdd_stop_p2p_go() - call cfg80211 API to stop P2P GO |
| 6439 | * @adapter: pointer to adapter |
| 6440 | * |
| 6441 | * This function calls cfg80211 API to stop P2P GO |
| 6442 | * |
| 6443 | * Return: None |
| 6444 | */ |
| 6445 | static void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6446 | { |
| 6447 | hdd_debug("[SSR] send stop ap to supplicant"); |
| 6448 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 6449 | } |
| 6450 | |
| 6451 | static inline void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6452 | { |
| 6453 | } |
| 6454 | #else |
| 6455 | static inline void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6456 | { |
| 6457 | } |
| 6458 | |
| 6459 | /** |
| 6460 | * hdd_delete_sta() - call cfg80211 API to delete STA |
| 6461 | * @adapter: pointer to adapter |
| 6462 | * |
| 6463 | * This function calls cfg80211 API to delete STA |
| 6464 | * |
| 6465 | * Return: None |
| 6466 | */ |
| 6467 | static void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6468 | { |
| 6469 | struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT; |
| 6470 | |
| 6471 | hdd_debug("[SSR] send restart supplicant"); |
| 6472 | /* event supplicant to restart */ |
| 6473 | cfg80211_del_sta(adapter->dev, |
| 6474 | (const u8 *)&bcast_mac.bytes[0], |
| 6475 | GFP_KERNEL); |
| 6476 | } |
| 6477 | #endif |
| 6478 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6479 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6480 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6481 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6482 | eConnectionState connState; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6483 | bool value; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6484 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6485 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6486 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6487 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6488 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6489 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6490 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6491 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 6492 | qdf_opmode_str(adapter->device_mode), |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6493 | adapter->device_mode); |
| 6494 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6495 | hdd_wmm_init(adapter); |
| 6496 | |
| 6497 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6498 | case QDF_STA_MODE: |
| 6499 | case QDF_P2P_CLIENT_MODE: |
| 6500 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6501 | |
| 6502 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 6503 | ->conn_info.connState; |
| 6504 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6505 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6506 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 6507 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6508 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6509 | /* Indicate disconnect event to supplicant |
| 6510 | * if associated previously |
| 6511 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6512 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 6513 | eConnectionState_IbssConnected == connState || |
| 6514 | eConnectionState_NotConnected == connState || |
| 6515 | eConnectionState_IbssDisconnected == connState || |
| 6516 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6517 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6518 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6519 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6520 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6521 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 6522 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 6523 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 6524 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 6525 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6526 | |
| 6527 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 6528 | wlan_hdd_cfg80211_indicate_disconnect( |
| 6529 | adapter->dev, false, |
| 6530 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6531 | } else if (eConnectionState_Connecting == connState) { |
| 6532 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6533 | * Indicate connect failure to supplicant if we |
| 6534 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6535 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6536 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6537 | NULL, 0, NULL, 0, |
| 6538 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6539 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6540 | } |
| 6541 | |
| 6542 | hdd_register_tx_flow_control(adapter, |
| 6543 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6544 | hdd_tx_resume_cb, |
| 6545 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6546 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 6547 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6548 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6549 | break; |
| 6550 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6551 | case QDF_SAP_MODE: |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 6552 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6553 | &value); |
| 6554 | if (value) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6555 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6556 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6557 | break; |
| 6558 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6559 | case QDF_P2P_GO_MODE: |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6560 | hdd_delete_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6561 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6562 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6563 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6564 | hdd_set_mon_rx_cb(adapter->dev); |
| 6565 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6566 | adapter->mon_bandwidth); |
| 6567 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6568 | default: |
| 6569 | break; |
| 6570 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6571 | /* |
| 6572 | * Action frame registered in one adapter which will |
| 6573 | * applicable to all interfaces |
| 6574 | */ |
| 6575 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6576 | } |
| 6577 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6578 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6579 | if (!hdd_is_interface_up(adapter)) |
| 6580 | continue; |
| 6581 | |
| 6582 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 6583 | hdd_stop_p2p_go(adapter); |
| 6584 | } |
| 6585 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6586 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6587 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6588 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6589 | } |
| 6590 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6591 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6592 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6593 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6594 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6595 | qdf_list_node_t *node; |
| 6596 | |
| 6597 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6598 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6599 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6600 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6601 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6602 | |
| 6603 | if (QDF_IS_STATUS_ERROR(status)) |
| 6604 | return status; |
| 6605 | |
| 6606 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6607 | |
| 6608 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6609 | } |
| 6610 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6611 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6612 | struct hdd_adapter *current_adapter, |
| 6613 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6614 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6615 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6616 | qdf_list_node_t *node; |
| 6617 | |
| 6618 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6619 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6620 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6621 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6622 | ¤t_adapter->node, |
| 6623 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6624 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6625 | |
| 6626 | if (QDF_IS_STATUS_ERROR(status)) |
| 6627 | return status; |
| 6628 | |
| 6629 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6630 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6631 | return status; |
| 6632 | } |
| 6633 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6634 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6635 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6636 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6637 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6638 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6639 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6640 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6641 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6642 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6643 | return status; |
| 6644 | } |
| 6645 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6646 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6647 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6648 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6649 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6650 | qdf_list_node_t *node; |
| 6651 | |
| 6652 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6653 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6654 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6655 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6656 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6657 | |
| 6658 | if (QDF_IS_STATUS_ERROR(status)) |
| 6659 | return status; |
| 6660 | |
| 6661 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6662 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6663 | return status; |
| 6664 | } |
| 6665 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6666 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6667 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6668 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6669 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6670 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6671 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6672 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6673 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6674 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6675 | return status; |
| 6676 | } |
| 6677 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6678 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6679 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6680 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6681 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6682 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6683 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6684 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6685 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6686 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6687 | return status; |
| 6688 | } |
| 6689 | |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 6690 | struct hdd_adapter *hdd_get_adapter_by_rand_macaddr( |
| 6691 | struct hdd_context *hdd_ctx, tSirMacAddr mac_addr) |
| 6692 | { |
| 6693 | struct hdd_adapter *adapter; |
| 6694 | |
| 6695 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6696 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6697 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6698 | adapter->device_mode == QDF_P2P_DEVICE_MODE) && |
| 6699 | ucfg_p2p_check_random_mac(hdd_ctx->psoc, |
| 6700 | adapter->session_id, mac_addr)) |
| 6701 | return adapter; |
| 6702 | } |
| 6703 | |
| 6704 | return NULL; |
| 6705 | } |
| 6706 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6707 | 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] | 6708 | tSirMacAddr macAddr) |
| 6709 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6710 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6711 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6712 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6713 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 6714 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6715 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6716 | } |
| 6717 | |
| 6718 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6719 | } |
| 6720 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6721 | 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] | 6722 | uint32_t vdev_id) |
| 6723 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6724 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6725 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6726 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6727 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6728 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6729 | } |
| 6730 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6731 | return NULL; |
| 6732 | } |
| 6733 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6734 | /** |
| 6735 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 6736 | * the sessionid |
| 6737 | * @hdd_ctx: hdd context. |
| 6738 | * @sme_session_id: sme session is for the adapter to get. |
| 6739 | * |
| 6740 | * This function is used to get the adapter with provided session id |
| 6741 | * |
| 6742 | * Return: adapter pointer if found |
| 6743 | * |
| 6744 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6745 | struct hdd_adapter * |
| 6746 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6747 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6748 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6749 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6750 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6751 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6752 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6753 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6754 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6755 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6756 | return NULL; |
| 6757 | } |
| 6758 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6759 | 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] | 6760 | const char *iface_name) |
| 6761 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6762 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6763 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6764 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6765 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6766 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6767 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6768 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6769 | return NULL; |
| 6770 | } |
| 6771 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6772 | /** |
| 6773 | * hdd_get_adapter() - to get adapter matching the mode |
| 6774 | * @hdd_ctx: hdd context |
| 6775 | * @mode: adapter mode |
| 6776 | * |
| 6777 | * This routine will return the pointer to adapter matching |
| 6778 | * with the passed mode. |
| 6779 | * |
| 6780 | * Return: pointer to adapter or null |
| 6781 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6782 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6783 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6784 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6785 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6786 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6787 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6788 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6789 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6790 | } |
| 6791 | |
| 6792 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6793 | } |
| 6794 | |
Jeff Johnson | 36a0abf | 2018-05-20 11:24:25 -0700 | [diff] [blame] | 6795 | enum QDF_OPMODE hdd_get_device_mode(uint32_t session_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6796 | { |
| 6797 | struct hdd_context *hdd_ctx; |
| 6798 | struct hdd_adapter *adapter; |
| 6799 | |
| 6800 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6801 | if (!hdd_ctx) { |
| 6802 | hdd_err("Invalid HDD context"); |
| 6803 | return QDF_MAX_NO_OF_MODE; |
| 6804 | } |
| 6805 | |
| 6806 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6807 | if (!adapter) { |
| 6808 | hdd_err("Invalid HDD adapter"); |
| 6809 | return QDF_MAX_NO_OF_MODE; |
| 6810 | } |
| 6811 | |
| 6812 | return adapter->device_mode; |
| 6813 | } |
| 6814 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6815 | /** |
| 6816 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6817 | * @hdd_ctx: Pointer to the HDD context. |
| 6818 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6819 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6820 | * QDF_STA_MODE, |
| 6821 | * QDF_P2P_CLIENT_MODE, |
| 6822 | * QDF_SAP_MODE, |
| 6823 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6824 | * |
| 6825 | * This API returns the operating channel of the requested device mode |
| 6826 | * |
| 6827 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6828 | * not connected. |
| 6829 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6830 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6831 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6832 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6833 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6834 | uint8_t operatingChannel = 0; |
| 6835 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6836 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6837 | if (mode == adapter->device_mode) { |
| 6838 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6839 | case QDF_STA_MODE: |
| 6840 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6841 | if (hdd_conn_is_connected |
| 6842 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6843 | (adapter))) { |
| 6844 | operatingChannel = |
| 6845 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6846 | (adapter))->conn_info. |
| 6847 | operationChannel; |
| 6848 | } |
| 6849 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6850 | case QDF_SAP_MODE: |
| 6851 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6852 | /* softap connection info */ |
| 6853 | if (test_bit |
| 6854 | (SOFTAP_BSS_STARTED, |
| 6855 | &adapter->event_flags)) |
| 6856 | operatingChannel = |
| 6857 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6858 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6859 | break; |
| 6860 | default: |
| 6861 | break; |
| 6862 | } |
| 6863 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6864 | /* Found the device of interest. break the loop */ |
| 6865 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6866 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6867 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6868 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6869 | return operatingChannel; |
| 6870 | } |
| 6871 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6872 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6873 | hdd_ctx) |
| 6874 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6875 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6876 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6877 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6878 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6879 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6880 | if (adapter->device_mode == QDF_STA_MODE || |
| 6881 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6882 | adapter->device_mode == QDF_IBSS_MODE || |
| 6883 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6884 | adapter->device_mode == QDF_SAP_MODE || |
| 6885 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6886 | hdd_unregister_wext(adapter->dev); |
| 6887 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6888 | } |
| 6889 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6890 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6891 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6892 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6893 | } |
| 6894 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6895 | 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] | 6896 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6897 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6898 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6899 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6900 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6901 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6902 | if (adapter->device_mode == QDF_STA_MODE || |
| 6903 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6904 | adapter->device_mode == QDF_IBSS_MODE || |
| 6905 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6906 | adapter->device_mode == QDF_SAP_MODE || |
| 6907 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6908 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6909 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6910 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6911 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6912 | } |
| 6913 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6914 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6915 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6916 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6917 | } |
| 6918 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6919 | /** |
| 6920 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6921 | * adapters |
| 6922 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6923 | * |
| 6924 | * return: QDF_STATUS_SUCCESS |
| 6925 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6926 | 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] | 6927 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6928 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6929 | int err; |
| 6930 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6931 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6932 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6933 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6934 | if (adapter->device_mode == QDF_STA_MODE || |
| 6935 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6936 | adapter->device_mode == QDF_IBSS_MODE || |
| 6937 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6938 | adapter->device_mode == QDF_SAP_MODE || |
| 6939 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6940 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6941 | if (err) |
| 6942 | hdd_err("Unable to stop scheduled scan"); |
| 6943 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6944 | } |
| 6945 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6946 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6947 | |
| 6948 | return QDF_STATUS_SUCCESS; |
| 6949 | } |
| 6950 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6951 | #ifdef WLAN_NS_OFFLOAD |
| 6952 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6953 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6954 | * @hdd_ctx: Pointer to hdd context |
| 6955 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6956 | * Unregister for IPv6 address change notifications. |
| 6957 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6958 | * Return: None |
| 6959 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6960 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6961 | { |
| 6962 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6963 | } |
| 6964 | |
| 6965 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6966 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6967 | * @hdd_ctx: Pointer to hdd context |
| 6968 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6969 | * Register for IPv6 address change notifications. |
| 6970 | * |
| 6971 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6972 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6973 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6974 | { |
| 6975 | int ret; |
| 6976 | |
| 6977 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6978 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6979 | if (ret) { |
| 6980 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6981 | goto out; |
| 6982 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6983 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6984 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6985 | out: |
| 6986 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6987 | } |
| 6988 | #else |
| 6989 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6990 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6991 | * @hdd_ctx: Pointer to hdd context |
| 6992 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6993 | * Unregister for IPv6 address change notifications. |
| 6994 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6995 | * Return: None |
| 6996 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6997 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6998 | { |
| 6999 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7000 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7001 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7002 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7003 | * @hdd_ctx: Pointer to hdd context |
| 7004 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7005 | * Register for IPv6 address change notifications. |
| 7006 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7007 | * Return: None |
| 7008 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7009 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7010 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7011 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7012 | } |
| 7013 | #endif |
| 7014 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7015 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 7016 | { |
| 7017 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 7018 | adapter->disconnection_in_progress = status; |
| 7019 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 7020 | hdd_debug("setting disconnection status: %d", status); |
| 7021 | } |
| 7022 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7023 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7024 | * hdd_register_notifiers - Register netdev notifiers. |
| 7025 | * @hdd_ctx: HDD context |
| 7026 | * |
| 7027 | * Register netdev notifiers like IPv4 and IPv6. |
| 7028 | * |
| 7029 | * Return: 0 on success and errno on failure |
| 7030 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7031 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7032 | { |
| 7033 | int ret; |
| 7034 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7035 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 7036 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7037 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7038 | |
| 7039 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 7040 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 7041 | if (ret) { |
| 7042 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 7043 | goto unregister_ip6_notifier; |
| 7044 | } |
| 7045 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7046 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 7047 | if (ret) { |
| 7048 | hdd_err("Failed to register netevent notifier: %d", |
| 7049 | ret); |
| 7050 | goto unregister_inetaddr_notifier; |
| 7051 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7052 | return 0; |
| 7053 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7054 | unregister_inetaddr_notifier: |
| 7055 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7056 | unregister_ip6_notifier: |
| 7057 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7058 | out: |
| 7059 | return ret; |
| 7060 | |
| 7061 | } |
| 7062 | |
| 7063 | /** |
| 7064 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 7065 | * @hdd_ctx: HDD context |
| 7066 | * |
| 7067 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 7068 | * |
| 7069 | * Return: None. |
| 7070 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7071 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7072 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7073 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7074 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 7075 | |
| 7076 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7077 | } |
| 7078 | |
| 7079 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7080 | * hdd_exit_netlink_services - Exit netlink services |
| 7081 | * @hdd_ctx: HDD context |
| 7082 | * |
| 7083 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7084 | * nl service. |
| 7085 | * |
| 7086 | * Return: None. |
| 7087 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7088 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7089 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7090 | spectral_scan_deactivate_service(); |
| 7091 | cnss_diag_deactivate_service(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7092 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7093 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7094 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7095 | |
| 7096 | nl_srv_exit(); |
| 7097 | } |
| 7098 | |
| 7099 | /** |
| 7100 | * hdd_init_netlink_services- Init netlink services |
| 7101 | * @hdd_ctx: HDD context |
| 7102 | * |
| 7103 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7104 | * nl service. |
| 7105 | * |
| 7106 | * Return: 0 on success and errno on failure. |
| 7107 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7108 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7109 | { |
| 7110 | int ret; |
| 7111 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7112 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7113 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7114 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7115 | goto out; |
| 7116 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7117 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7118 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 7119 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7120 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7121 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7122 | goto err_nl_srv; |
| 7123 | } |
| 7124 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7125 | ptt_sock_activate_svc(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7126 | |
| 7127 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 7128 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7129 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7130 | |
| 7131 | ret = cnss_diag_activate_service(); |
| 7132 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7133 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7134 | goto err_close_cesium; |
| 7135 | } |
| 7136 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7137 | spectral_scan_activate_service(); |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 7138 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7139 | return 0; |
| 7140 | |
| 7141 | err_close_cesium: |
| 7142 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7143 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7144 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7145 | err_nl_srv: |
| 7146 | nl_srv_exit(); |
| 7147 | out: |
| 7148 | return ret; |
| 7149 | } |
| 7150 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7151 | /** |
| 7152 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 7153 | * @hdd_ctx: HDD context. |
| 7154 | * |
| 7155 | * Destroy RX wakelock. |
| 7156 | * |
| 7157 | * Return: None. |
| 7158 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7159 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7160 | { |
| 7161 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 7162 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7163 | |
| 7164 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7165 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 7166 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7167 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7168 | * Create RX wakelock. |
| 7169 | * |
| 7170 | * Return: None. |
| 7171 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7172 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7173 | { |
| 7174 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 7175 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7176 | |
| 7177 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7178 | * hdd_context_deinit() - Deinitialize HDD context |
| 7179 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7180 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7181 | * Deinitialize HDD context along with all the feature specific contexts but |
| 7182 | * do not free hdd context itself. Caller of this API is supposed to free |
| 7183 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7184 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7185 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7186 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7187 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7188 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7189 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 7190 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7191 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7192 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7193 | hdd_sap_context_destroy(hdd_ctx); |
| 7194 | |
| 7195 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 7196 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7197 | hdd_scan_context_destroy(hdd_ctx); |
| 7198 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 7199 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7200 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7201 | return 0; |
| 7202 | } |
| 7203 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7204 | void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7205 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 7206 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 7207 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7208 | hdd_exit_netlink_services(hdd_ctx); |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 7209 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 7210 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7211 | hdd_context_deinit(hdd_ctx); |
| 7212 | |
Dustin Brown | db2df2e | 2018-10-31 15:29:24 -0700 | [diff] [blame] | 7213 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 7214 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7215 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7216 | hdd_ctx->config = NULL; |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 7217 | cfg_release(); |
| 7218 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7219 | wiphy_free(hdd_ctx->wiphy); |
| 7220 | } |
| 7221 | |
| 7222 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7223 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 7224 | * |
| 7225 | * This function is used to destroy bug report lock |
| 7226 | * |
| 7227 | * Return: None |
| 7228 | */ |
| 7229 | static void wlan_destroy_bug_report_lock(void) |
| 7230 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 7231 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7232 | |
| 7233 | p_cds_context = cds_get_global_context(); |
| 7234 | if (!p_cds_context) { |
| 7235 | hdd_err("cds context is NULL"); |
| 7236 | return; |
| 7237 | } |
| 7238 | |
| 7239 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 7240 | } |
| 7241 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7242 | #ifdef DISABLE_CHANNEL_LIST |
| 7243 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7244 | { |
| 7245 | qdf_mutex_destroy(&hdd_ctx->cache_channel_lock); |
| 7246 | } |
| 7247 | #else |
| 7248 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7249 | { |
| 7250 | } |
| 7251 | #endif |
| 7252 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 7253 | void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7254 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7255 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7256 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7257 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7258 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7259 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 7260 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Dustin Brown | 6470aba | 2018-09-05 09:49:58 -0700 | [diff] [blame] | 7261 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7262 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7263 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7264 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7265 | if (QDF_TIMER_STATE_RUNNING == |
| 7266 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 7267 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7268 | } |
| 7269 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7270 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7271 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 7272 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7273 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7274 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7275 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7276 | hdd_ctx->last_acs_channel_list = NULL; |
| 7277 | hdd_ctx->num_of_channels = 0; |
| 7278 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7279 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7280 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7281 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 7282 | driver_status = hdd_ctx->driver_status; |
| 7283 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 7284 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7285 | /* |
| 7286 | * Powersave Offload Case |
| 7287 | * Disable Idle Power Save Mode |
| 7288 | */ |
| 7289 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 7290 | /* clear the scan queue in all the scenarios */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7291 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7292 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7293 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 7294 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 7295 | /* |
| 7296 | * Cancel any outstanding scan requests. We are about to close |
| 7297 | * all of our adapters, but an adapter structure is what SME |
| 7298 | * passes back to our callback function. Hence if there |
| 7299 | * are any outstanding scan requests then there is a |
| 7300 | * race condition between when the adapter is closed and |
| 7301 | * when the callback is invoked. We try to resolve that |
| 7302 | * race condition here by canceling any outstanding scans |
| 7303 | * before we close the adapters. |
| 7304 | * Note that the scans may be cancelled in an asynchronous |
| 7305 | * manner, so ideally there needs to be some kind of |
| 7306 | * synchronization. Rather than introduce a new |
| 7307 | * synchronization here, we will utilize the fact that we are |
| 7308 | * about to Request Full Power, and since that is synchronized, |
| 7309 | * the expectation is that by the time Request Full Power has |
| 7310 | * completed, all scans will be cancelled |
| 7311 | */ |
| 7312 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7313 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 7314 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 7315 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7316 | } |
| 7317 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 7318 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7319 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 7320 | |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 7321 | qdf_dp_trace_deinit(); |
| 7322 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 7323 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 7324 | |
Visweswara Tanuku | c029a20 | 2018-11-27 10:42:10 +0530 | [diff] [blame] | 7325 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 7326 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 7327 | hdd_driver_memdump_deinit(); |
| 7328 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 7329 | qdf_nbuf_deinit_replenish_timer(); |
| 7330 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7331 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 7332 | hdd_info("Release wakelock for monitor mode!"); |
| 7333 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 7334 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 7335 | } |
| 7336 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7337 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7338 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7339 | wlan_hdd_cache_chann_mutex_destroy(hdd_ctx); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7340 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 7341 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7342 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 7343 | hdd_close_all_adapters(hdd_ctx, false); |
| 7344 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 7345 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7346 | /* |
| 7347 | * If there is re_init failure wiphy would have already de-registered |
| 7348 | * check the wiphy status before un-registering again |
| 7349 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 7350 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7351 | wiphy_unregister(wiphy); |
| 7352 | wlan_hdd_cfg80211_deinit(wiphy); |
| 7353 | hdd_lpass_notify_stop(hdd_ctx); |
| 7354 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 7355 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7356 | hdd_exit_netlink_services(hdd_ctx); |
| 7357 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7358 | #ifdef FEATURE_WLAN_CH_AVOID |
| 7359 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 7360 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7361 | } |
| 7362 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7363 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7364 | /** |
| 7365 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7366 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7367 | * |
| 7368 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 7369 | * Then new ACS request will do a fresh scan without reusing the cached |
| 7370 | * scan information. |
| 7371 | * |
| 7372 | * Return: void |
| 7373 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 7374 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7375 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7376 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7377 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7378 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7379 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7380 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7381 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7382 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7383 | hdd_ctx->last_acs_channel_list = NULL; |
| 7384 | hdd_ctx->num_of_channels = 0; |
| 7385 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7386 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7387 | mac_handle = hdd_ctx->mac_handle; |
| 7388 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7389 | return; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7390 | sme_scan_flush_result(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7391 | } |
| 7392 | #endif |
| 7393 | |
| 7394 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 7395 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 7396 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7397 | { |
| 7398 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7399 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 7400 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7401 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7402 | |
| 7403 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7404 | |
| 7405 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7406 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7407 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7408 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7409 | mac_handle = hdd_ctx->mac_handle; |
| 7410 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7411 | return -EINVAL; |
| 7412 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7413 | qdf_status = sme_notify_ht2040_mode(mac_handle, sta_id, sta_mac, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7414 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7415 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7416 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7417 | return -EINVAL; |
| 7418 | } |
| 7419 | |
| 7420 | return 0; |
| 7421 | } |
| 7422 | #endif |
| 7423 | |
| 7424 | /** |
| 7425 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 7426 | * @state: state |
| 7427 | * |
| 7428 | * This function notifies FW with modem power status |
| 7429 | * |
| 7430 | * Return: 0 if successful, error number otherwise |
| 7431 | */ |
| 7432 | int hdd_wlan_notify_modem_power_state(int state) |
| 7433 | { |
| 7434 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7435 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7436 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7437 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7438 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7439 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7440 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7441 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7442 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7443 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7444 | mac_handle = hdd_ctx->mac_handle; |
| 7445 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7446 | return -EINVAL; |
| 7447 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7448 | qdf_status = sme_notify_modem_power_state(mac_handle, state); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7449 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7450 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7451 | state); |
| 7452 | return -EINVAL; |
| 7453 | } |
| 7454 | return 0; |
| 7455 | } |
| 7456 | |
| 7457 | /** |
| 7458 | * |
| 7459 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 7460 | * @adapter - Pointer to the HDD |
| 7461 | * |
| 7462 | * Return: None |
| 7463 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7464 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7465 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7466 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7467 | |
| 7468 | /* |
| 7469 | * Send ready indication to the HDD. This will kick off the MAC |
| 7470 | * into a 'running' state and should kick off an initial scan. |
| 7471 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7472 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->mac_handle); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7473 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7474 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 7475 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7476 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7477 | } |
| 7478 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7479 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7480 | } |
| 7481 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 7482 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 7483 | { |
| 7484 | struct hdd_adapter *adapter; |
| 7485 | |
| 7486 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7487 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 7488 | return adapter; |
| 7489 | } |
| 7490 | |
| 7491 | return NULL; |
| 7492 | } |
| 7493 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7494 | /* wake lock APIs for HDD */ |
| 7495 | void hdd_prevent_suspend(uint32_t reason) |
| 7496 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7497 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7498 | } |
| 7499 | |
| 7500 | void hdd_allow_suspend(uint32_t reason) |
| 7501 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7502 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7503 | } |
| 7504 | |
| 7505 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 7506 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 7507 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 7508 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7509 | } |
| 7510 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7511 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7512 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7513 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7514 | return sme_init_chan_list(hdd_ctx->mac_handle, |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 7515 | hdd_ctx->reg.alpha2, |
| 7516 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7517 | } |
| 7518 | |
| 7519 | /** |
| 7520 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 7521 | * @hdd_ctx: Pointer to the hdd context |
| 7522 | * |
| 7523 | * HDD function to know if hardware supports 5GHz |
| 7524 | * |
| 7525 | * Return: true if hardware supports 5GHz |
| 7526 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7527 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7528 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7529 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7530 | return true; |
| 7531 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7532 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7533 | return true; |
| 7534 | else |
| 7535 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7536 | } |
| 7537 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7538 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7539 | { |
| 7540 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7541 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7542 | |
| 7543 | wiphy = hdd_ctx->wiphy; |
| 7544 | |
| 7545 | /* |
| 7546 | * The channel information in |
| 7547 | * wiphy needs to be initialized before wiphy registration |
| 7548 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7549 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7550 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7551 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7552 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7553 | } |
| 7554 | |
| 7555 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7556 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7557 | #else |
| 7558 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7559 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7560 | WIPHY_WOWLAN_DISCONNECT | |
| 7561 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7562 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7563 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7564 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7565 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7566 | |
| 7567 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7568 | WOW_MAX_FILTERS_PER_LIST); |
| 7569 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7570 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7571 | #endif |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7572 | if (hdd_ctx->obss_scan_offload) { |
| 7573 | hdd_debug("wmi_service_obss_scan supported"); |
| 7574 | } else if (hdd_ctx->config->nChannelBondingMode24GHz) { |
| 7575 | hdd_debug("enable wpa_supp obss_scan"); |
| 7576 | wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; |
| 7577 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7578 | |
| 7579 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7580 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7581 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7582 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7583 | return ret_val; |
| 7584 | } |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7585 | |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7586 | /* Check the kernel version for upstream commit aced43ce780dc5 that |
| 7587 | * has support for processing user cell_base hints when wiphy is |
| 7588 | * self managed or check the backport flag for the same. |
| 7589 | */ |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7590 | #if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \ |
| 7591 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7592 | hdd_send_wiphy_regd_sync_event(hdd_ctx); |
| 7593 | #endif |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7594 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7595 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7596 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7597 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7598 | } |
| 7599 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7600 | #ifdef MSM_PLATFORM |
| 7601 | /** |
| 7602 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7603 | * @hdd_ctx - handle to hdd context |
| 7604 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7605 | * |
| 7606 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7607 | * Stats show up in wlan driver logs. |
| 7608 | * |
| 7609 | * Returns: None |
| 7610 | */ |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7611 | static void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7612 | bool data_in_interval) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7613 | { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7614 | static uint32_t counter; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7615 | static bool data_in_time_period; |
| 7616 | ol_txrx_pdev_handle pdev; |
| 7617 | |
| 7618 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 7619 | return; |
| 7620 | |
| 7621 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7622 | if (!pdev) { |
| 7623 | hdd_err("pdev is NULL"); |
| 7624 | return; |
| 7625 | } |
| 7626 | |
| 7627 | counter++; |
| 7628 | if (data_in_interval) |
| 7629 | data_in_time_period = data_in_interval; |
| 7630 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7631 | if (counter * hdd_ctx->config->bus_bw_compute_interval >= |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7632 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 7633 | if (data_in_time_period) { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7634 | wlan_hdd_display_txrx_stats(hdd_ctx); |
| 7635 | dp_txrx_dump_stats(cds_get_context(QDF_MODULE_ID_SOC)); |
| 7636 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 7637 | CDP_RX_RING_STATS, |
| 7638 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7639 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 7640 | CDP_TXRX_PATH_STATS, |
| 7641 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7642 | wlan_hdd_display_netif_queue_history |
| 7643 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7644 | qdf_dp_trace_dump_stats(); |
| 7645 | } |
| 7646 | counter = 0; |
| 7647 | data_in_time_period = false; |
| 7648 | } |
| 7649 | } |
| 7650 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7651 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7652 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7653 | * @hdd_ctx: pointer to struct hdd_context |
| 7654 | * |
| 7655 | * Return: none |
| 7656 | */ |
| 7657 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7658 | { |
| 7659 | struct hdd_adapter *adapter; |
| 7660 | |
| 7661 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7662 | hdd_send_rps_disable_ind(adapter); |
| 7663 | } |
| 7664 | |
| 7665 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7666 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7667 | * @hdd_ctx - handle to hdd context |
| 7668 | * @tx_packets - transmit packet count |
| 7669 | * @rx_packets - receive packet count |
| 7670 | * |
| 7671 | * The function controls the bus bandwidth and dynamic control of |
| 7672 | * tcp delayed ack configuration |
| 7673 | * |
| 7674 | * Returns: None |
| 7675 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7676 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7677 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7678 | const uint64_t tx_packets, |
| 7679 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7680 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7681 | u64 total_pkts = tx_packets + rx_packets; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7682 | uint64_t temp_tx = 0, avg_rx = 0; |
| 7683 | uint64_t no_rx_offload_pkts = 0, avg_no_rx_offload_pkts = 0; |
| 7684 | uint64_t rx_offload_pkts = 0, avg_rx_offload_pkts = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7685 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7686 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7687 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7688 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7689 | uint16_t index = 0; |
| 7690 | bool vote_level_change = false; |
| 7691 | bool rx_level_change = false; |
| 7692 | bool tx_level_change = false; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7693 | bool rxthread_high_tput_req = false; |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7694 | bool dptrace_high_tput_req; |
Srinivas Girigowda | 5033534 | 2018-09-07 15:21:01 -0700 | [diff] [blame] | 7695 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7696 | if (total_pkts > hdd_ctx->config->bus_bw_high_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7697 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7698 | else if (total_pkts > hdd_ctx->config->bus_bw_medium_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7699 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7700 | else if (total_pkts > hdd_ctx->config->bus_bw_low_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7701 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7702 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7703 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7704 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7705 | dptrace_high_tput_req = |
| 7706 | next_vote_level > PLD_BUS_WIDTH_NONE ? true : false; |
| 7707 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7708 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7709 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7710 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7711 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7712 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7713 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7714 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7715 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7716 | if (hdd_ctx->hbw_requested) { |
| 7717 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7718 | hdd_ctx->hbw_requested = false; |
| 7719 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7720 | if (hdd_ctx->dynamic_rps) |
| 7721 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7722 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7723 | if (!hdd_ctx->hbw_requested) { |
| 7724 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7725 | hdd_ctx->hbw_requested = true; |
| 7726 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7727 | if (hdd_ctx->dynamic_rps) |
| 7728 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7729 | } |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7730 | |
Manjunathappa Prakash | cb6df76 | 2018-05-29 18:54:58 -0700 | [diff] [blame] | 7731 | if (hdd_ctx->config->napi_cpu_affinity_mask) |
| 7732 | hdd_napi_apply_throughput_policy(hdd_ctx, |
| 7733 | tx_packets, |
| 7734 | rx_packets); |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7735 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7736 | if (rx_packets < hdd_ctx->config->bus_bw_low_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7737 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
| 7738 | else |
| 7739 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7740 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7741 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7742 | qdf_dp_trace_apply_tput_policy(dptrace_high_tput_req); |
| 7743 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7744 | /* |
| 7745 | * Includes tcp+udp, if perf core is required for tcp, then |
| 7746 | * perf core is also required for udp. |
| 7747 | */ |
| 7748 | no_rx_offload_pkts = hdd_ctx->no_rx_offload_pkt_cnt; |
| 7749 | hdd_ctx->no_rx_offload_pkt_cnt = 0; |
| 7750 | rx_offload_pkts = rx_packets - no_rx_offload_pkts; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7751 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7752 | avg_no_rx_offload_pkts = (no_rx_offload_pkts + |
| 7753 | hdd_ctx->prev_no_rx_offload_pkts) / 2; |
| 7754 | hdd_ctx->prev_no_rx_offload_pkts = no_rx_offload_pkts; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7755 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7756 | avg_rx_offload_pkts = (rx_offload_pkts + |
| 7757 | hdd_ctx->prev_rx_offload_pkts) / 2; |
| 7758 | hdd_ctx->prev_rx_offload_pkts = rx_offload_pkts; |
| 7759 | |
| 7760 | avg_rx = avg_no_rx_offload_pkts + avg_rx_offload_pkts; |
| 7761 | /* |
| 7762 | * Takes care to set Rx_thread affinity for below case |
| 7763 | * 1)LRO/GRO not supported ROME case |
| 7764 | * 2)when rx_ol is disabled in cases like concurrency etc |
| 7765 | * 3)For UDP cases |
| 7766 | */ |
| 7767 | if (avg_no_rx_offload_pkts > |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7768 | hdd_ctx->config->bus_bw_high_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7769 | rxthread_high_tput_req = true; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7770 | else |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7771 | rxthread_high_tput_req = false; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7772 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7773 | if (cds_sched_handle_throughput_req(rxthread_high_tput_req)) |
| 7774 | hdd_warn("Rx thread high_tput(%d) affinity request failed", |
| 7775 | rxthread_high_tput_req); |
| 7776 | |
| 7777 | /* fine-tuning parameters for RX Flows */ |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7778 | if (avg_rx > hdd_ctx->config->tcp_delack_thres_high) { |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7779 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7780 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7781 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7782 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7783 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7784 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7785 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7786 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7787 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7788 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7789 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7790 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7791 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Jeff Johnson | b9feee4 | 2018-07-08 10:34:48 -0700 | [diff] [blame] | 7792 | next_rx_level, avg_rx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7793 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7794 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7795 | /* Send throughput indication only if it is enabled. |
| 7796 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7797 | * to default delayed ack. Note that this will disable the |
| 7798 | * dynamic delayed ack mechanism across the system |
| 7799 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7800 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7801 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7802 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7803 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7804 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7805 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7806 | rx_tp_data.level = next_rx_level; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7807 | wlan_hdd_update_tcp_rx_param(hdd_ctx, &rx_tp_data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7808 | } |
| 7809 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7810 | /* fine-tuning parameters for TX Flows */ |
| 7811 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7812 | hdd_ctx->prev_tx = tx_packets; |
| 7813 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7814 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7815 | else |
| 7816 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7817 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7818 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7819 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7820 | struct wlan_tx_tp_data tx_tp_data = {0}; |
| 7821 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7822 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7823 | next_tx_level, temp_tx); |
| 7824 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7825 | tx_level_change = true; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7826 | tx_tp_data.level = next_tx_level; |
| 7827 | tx_tp_data.tcp_limit_output = true; |
| 7828 | wlan_hdd_update_tcp_tx_param(hdd_ctx, &tx_tp_data); |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7829 | } |
| 7830 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7831 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7832 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7833 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7834 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7835 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7836 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7837 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7838 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7839 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7840 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7841 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7842 | |
| 7843 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7844 | } |
| 7845 | |
| 7846 | #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] | 7847 | static void __hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7848 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7849 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7850 | bus_bw_work); |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7851 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7852 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7853 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7854 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7855 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7856 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7857 | bool connected = false; |
| 7858 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7859 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7860 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7861 | return; |
| 7862 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7863 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7864 | goto restart_timer; |
| 7865 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7866 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7867 | /* |
| 7868 | * Validate magic so we don't end up accessing |
| 7869 | * an invalid adapter. |
| 7870 | */ |
| 7871 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7872 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7873 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7874 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7875 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7876 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7877 | != eConnectionState_Associated) { |
| 7878 | |
| 7879 | continue; |
| 7880 | } |
| 7881 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7882 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7883 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7884 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7885 | |
| 7886 | continue; |
| 7887 | } |
| 7888 | |
| 7889 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7890 | adapter->prev_tx_packets); |
| 7891 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7892 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7893 | |
| 7894 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7895 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7896 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7897 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7898 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7899 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7900 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7901 | &fwd_tx_packets, &fwd_rx_packets); |
| 7902 | if (ret == A_OK) { |
| 7903 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7904 | fwd_tx_packets, |
| 7905 | adapter->prev_fwd_tx_packets); |
| 7906 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7907 | fwd_tx_packets, |
| 7908 | adapter->prev_fwd_rx_packets); |
| 7909 | } |
| 7910 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7911 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7912 | if (adapter->device_mode == QDF_SAP_MODE) |
| 7913 | con_sap_adapter = adapter; |
| 7914 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7915 | total_rx += adapter->stats.rx_packets; |
| 7916 | total_tx += adapter->stats.tx_packets; |
| 7917 | |
| 7918 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7919 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7920 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7921 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7922 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7923 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7924 | connected = true; |
| 7925 | } |
| 7926 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7927 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7928 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7929 | return; |
| 7930 | } |
| 7931 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7932 | /* add intra bss forwarded tx and rx packets */ |
| 7933 | tx_packets += fwd_tx_packets_diff; |
| 7934 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7935 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7936 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->pdev)) { |
| 7937 | ucfg_ipa_uc_stat_query(hdd_ctx->pdev, &ipa_tx_packets, |
| 7938 | &ipa_rx_packets); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7939 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7940 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7941 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7942 | if (con_sap_adapter) { |
| 7943 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 7944 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 7945 | } |
| 7946 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7947 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, tx_packets, rx_packets); |
| 7948 | ucfg_ipa_uc_stat_request(hdd_ctx->pdev, 2); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7949 | } |
| 7950 | |
| 7951 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7952 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7953 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7954 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7955 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7956 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 7957 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7958 | hdd_ctx->config->bus_bw_compute_interval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7959 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7960 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7961 | |
Rajeev Kumar | b2b5e69 | 2018-08-31 15:12:40 -0700 | [diff] [blame] | 7962 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
| 7963 | { |
| 7964 | cds_ssr_protect(__func__); |
| 7965 | __hdd_bus_bw_work_handler(work); |
| 7966 | cds_ssr_unprotect(__func__); |
| 7967 | } |
| 7968 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7969 | /** |
| 7970 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 7971 | * @arg: Argument of timer function |
| 7972 | * |
| 7973 | * Schedule a workqueue in this function where all the processing is done. |
| 7974 | * |
| 7975 | * Return: None. |
| 7976 | */ |
| 7977 | static void __hdd_bus_bw_cbk(void *arg) |
| 7978 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7979 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7980 | |
| 7981 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7982 | return; |
| 7983 | |
| 7984 | schedule_work(&hdd_ctx->bus_bw_work); |
| 7985 | } |
| 7986 | |
| 7987 | /** |
| 7988 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 7989 | * @arg: Argument of timer function |
| 7990 | * |
| 7991 | * Return: None. |
| 7992 | */ |
| 7993 | static void hdd_bus_bw_cbk(void *arg) |
| 7994 | { |
| 7995 | cds_ssr_protect(__func__); |
| 7996 | __hdd_bus_bw_cbk(arg); |
| 7997 | cds_ssr_unprotect(__func__); |
| 7998 | } |
| 7999 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8000 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8001 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8002 | hdd_enter(); |
| 8003 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8004 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8005 | INIT_WORK(&hdd_ctx->bus_bw_work, hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 8006 | hdd_ctx->bus_bw_timer_running = false; |
| 8007 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8008 | qdf_timer_init(NULL, &hdd_ctx->bus_bw_timer, hdd_bus_bw_cbk, |
| 8009 | (void *)hdd_ctx, QDF_TIMER_TYPE_SW); |
| 8010 | |
| 8011 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8012 | |
| 8013 | return 0; |
| 8014 | } |
| 8015 | |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 8016 | void hdd_bus_bandwidth_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8017 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8018 | hdd_enter(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8019 | |
Rajeev Kumar | c27efb6 | 2018-08-31 14:21:22 -0700 | [diff] [blame] | 8020 | QDF_BUG(!hdd_ctx->bus_bw_timer_running); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8021 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 8022 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 8023 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8024 | |
| 8025 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8026 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 8027 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8028 | #endif /* MSM_PLATFORM */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8029 | |
| 8030 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8031 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 8032 | * @hdd_ctx: hdd context |
| 8033 | * |
| 8034 | * Return: 0 for success or error code |
| 8035 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8036 | 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] | 8037 | { |
| 8038 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 8039 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8040 | if (!hdd_ctx->hdd_txrx_hist) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8041 | return -ENOMEM; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8042 | return 0; |
| 8043 | } |
| 8044 | |
| 8045 | /** |
| 8046 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 8047 | * @hdd_ctx: hdd context |
| 8048 | * |
| 8049 | * Return: none |
| 8050 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8051 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8052 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 8053 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 8054 | return; |
| 8055 | |
| 8056 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 8057 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8058 | } |
| 8059 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8060 | static uint8_t *convert_level_to_string(uint32_t level) |
| 8061 | { |
| 8062 | switch (level) { |
| 8063 | /* initialize the wlan sub system */ |
| 8064 | case WLAN_SVC_TP_NONE: |
| 8065 | return "NONE"; |
| 8066 | case WLAN_SVC_TP_LOW: |
| 8067 | return "LOW"; |
| 8068 | case WLAN_SVC_TP_MEDIUM: |
| 8069 | return "MED"; |
| 8070 | case WLAN_SVC_TP_HIGH: |
| 8071 | return "HIGH"; |
| 8072 | default: |
| 8073 | return "INVAL"; |
| 8074 | } |
| 8075 | } |
| 8076 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8077 | |
| 8078 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8079 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 8080 | * @hdd_ctx: hdd context |
| 8081 | * |
| 8082 | * Return: none |
| 8083 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8084 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8085 | { |
| 8086 | int i; |
| 8087 | |
| 8088 | #ifdef MSM_PLATFORM |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8089 | hdd_nofl_info("BW compute Interval: %dms", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8090 | hdd_ctx->config->bus_bw_compute_interval); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8091 | 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] | 8092 | hdd_ctx->config->bus_bw_high_threshold, |
| 8093 | hdd_ctx->config->bus_bw_medium_threshold, |
| 8094 | hdd_ctx->config->bus_bw_low_threshold); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8095 | hdd_nofl_info("Enable TCP DEL ACK: %d", |
| 8096 | hdd_ctx->en_tcp_delack_no_lro); |
| 8097 | hdd_nofl_info("TCP DEL High TH: %d TCP DEL Low TH: %d", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8098 | hdd_ctx->config->tcp_delack_thres_high, |
| 8099 | hdd_ctx->config->tcp_delack_thres_low); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8100 | hdd_nofl_info("TCP TX HIGH TP TH: %d (Use to set tcp_output_bytes_limit)", |
| 8101 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8102 | #endif |
| 8103 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8104 | hdd_nofl_info("Total entries: %d Current index: %d", |
| 8105 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8106 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8107 | 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] | 8108 | |
| 8109 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8110 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 8111 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8112 | hdd_nofl_info("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 8113 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 8114 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 8115 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 8116 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8117 | hdd_ctx->hdd_txrx_hist[i]. |
| 8118 | next_vote_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8119 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8120 | hdd_ctx->hdd_txrx_hist[i]. |
| 8121 | next_rx_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8122 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8123 | hdd_ctx->hdd_txrx_hist[i]. |
| 8124 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8125 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8126 | } |
| 8127 | |
| 8128 | /** |
| 8129 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 8130 | * @hdd_ctx: hdd context |
| 8131 | * |
| 8132 | * Return: none |
| 8133 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8134 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8135 | { |
| 8136 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8137 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 8138 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8139 | } |
| 8140 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8141 | /* length of the netif queue log needed per adapter */ |
| 8142 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 8143 | |
| 8144 | /** |
| 8145 | * |
| 8146 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 8147 | * @hdd_ctx: hdd context |
| 8148 | * |
| 8149 | * Return: none |
| 8150 | */ |
| 8151 | static void |
| 8152 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 8153 | { |
| 8154 | int adapter_num = 0; |
| 8155 | int i; |
| 8156 | int bytes_written; |
| 8157 | u32 tbytes; |
| 8158 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8159 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8160 | char *comb_log_str; |
| 8161 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8162 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8163 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 8164 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * CSR_ROAM_SESSION_MAX) + 1; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8165 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8166 | if (!comb_log_str) |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8167 | return; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8168 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8169 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8170 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8171 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8172 | curr_time = qdf_system_ticks(); |
| 8173 | total = curr_time - adapter->start_time; |
| 8174 | delta = curr_time - adapter->last_time; |
| 8175 | |
| 8176 | if (adapter->pause_map) { |
| 8177 | pause = adapter->total_pause_time + delta; |
| 8178 | unpause = adapter->total_unpause_time; |
| 8179 | } else { |
| 8180 | unpause = adapter->total_unpause_time + delta; |
| 8181 | pause = adapter->total_pause_time; |
| 8182 | } |
| 8183 | |
| 8184 | tbytes = 0; |
| 8185 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 8186 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8187 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 8188 | continue; |
| 8189 | tbytes += |
| 8190 | snprintf( |
| 8191 | &temp_str[tbytes], |
| 8192 | (tbytes >= sizeof(temp_str) ? |
| 8193 | 0 : sizeof(temp_str) - tbytes), |
| 8194 | "%d(%d,%d) ", |
| 8195 | i, |
| 8196 | adapter->queue_oper_stats[i]. |
| 8197 | pause_count, |
| 8198 | adapter->queue_oper_stats[i]. |
| 8199 | unpause_count); |
| 8200 | } |
| 8201 | if (tbytes >= sizeof(temp_str)) |
| 8202 | hdd_warn("log truncated"); |
| 8203 | |
| 8204 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8205 | bytes_written >= comb_log_str_size ? 0 : |
| 8206 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8207 | "[%d %d] (%d) %u/%ums %s|", |
| 8208 | adapter->session_id, adapter->device_mode, |
| 8209 | adapter->pause_map, |
| 8210 | qdf_system_ticks_to_msecs(pause), |
| 8211 | qdf_system_ticks_to_msecs(total), |
| 8212 | temp_str); |
| 8213 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8214 | adapter_num++; |
| 8215 | } |
| 8216 | |
| 8217 | /* using QDF_TRACE to avoid printing function name */ |
| 8218 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 8219 | "STATS |%s", comb_log_str); |
| 8220 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8221 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8222 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8223 | |
| 8224 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8225 | } |
| 8226 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8227 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 8228 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 8229 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8230 | * |
| 8231 | * Return: none |
| 8232 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8233 | void |
| 8234 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 8235 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8236 | { |
| 8237 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8238 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8239 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8240 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8241 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8242 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 8243 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 8244 | return; |
| 8245 | } |
| 8246 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8247 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8248 | hdd_nofl_info("Netif queue operation statistics:"); |
| 8249 | hdd_nofl_info("Session_id %d device mode %d", |
| 8250 | adapter->session_id, adapter->device_mode); |
| 8251 | hdd_nofl_info("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8252 | curr_time = qdf_system_ticks(); |
| 8253 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8254 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8255 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8256 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8257 | unpause = adapter->total_unpause_time; |
| 8258 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8259 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8260 | pause = adapter->total_pause_time; |
| 8261 | } |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8262 | hdd_nofl_info("Total: %ums Pause: %ums Unpause: %ums", |
| 8263 | qdf_system_ticks_to_msecs(total), |
| 8264 | qdf_system_ticks_to_msecs(pause), |
| 8265 | qdf_system_ticks_to_msecs(unpause)); |
| 8266 | hdd_nofl_info("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8267 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8268 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8269 | qdf_time_t pause_delta = 0; |
| 8270 | |
| 8271 | if (adapter->pause_map & (1 << i)) |
| 8272 | pause_delta = delta; |
| 8273 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8274 | /* using hdd_log to avoid printing function name */ |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8275 | hdd_nofl_info("%s: %d: %d: %ums", |
| 8276 | hdd_reason_type_to_string(i), |
| 8277 | adapter->queue_oper_stats[i].pause_count, |
| 8278 | adapter->queue_oper_stats[i]. |
| 8279 | unpause_count, |
| 8280 | qdf_system_ticks_to_msecs( |
| 8281 | adapter->queue_oper_stats[i]. |
| 8282 | total_pause_time + pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8283 | } |
| 8284 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8285 | hdd_nofl_info("Netif queue operation history:"); |
| 8286 | hdd_nofl_info("Total entries: %d current index %d", |
| 8287 | WLAN_HDD_MAX_HISTORY_ENTRY, |
| 8288 | adapter->history_index); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8289 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8290 | hdd_nofl_info("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8291 | |
| 8292 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8293 | /* using hdd_log to avoid printing function name */ |
| 8294 | if (adapter->queue_oper_history[i].time == 0) |
| 8295 | continue; |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8296 | hdd_nofl_info("%d: %u: %s: %s: %x", |
| 8297 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8298 | adapter->queue_oper_history[i].time), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8299 | hdd_action_type_to_string( |
| 8300 | adapter->queue_oper_history[i]. |
| 8301 | netif_action), |
| 8302 | hdd_reason_type_to_string( |
| 8303 | adapter->queue_oper_history[i]. |
| 8304 | netif_reason), |
| 8305 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8306 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8307 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8308 | } |
| 8309 | |
| 8310 | /** |
| 8311 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 8312 | * @hdd_ctx: hdd context |
| 8313 | * |
| 8314 | * Return: none |
| 8315 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8316 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8317 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8318 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8319 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8320 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8321 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8322 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8323 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8324 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8325 | adapter->history_index = 0; |
| 8326 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 8327 | adapter->total_pause_time = 0; |
| 8328 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8329 | } |
| 8330 | } |
| 8331 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8332 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 8333 | /** |
| 8334 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 8335 | * @hdd_ctx: hdd global context |
| 8336 | * |
| 8337 | * Return: none |
| 8338 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8339 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8340 | { |
| 8341 | uint8_t i; |
| 8342 | |
| 8343 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 8344 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 8345 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 8346 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 8347 | } |
| 8348 | } |
| 8349 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8350 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8351 | { |
| 8352 | } |
| 8353 | #endif |
| 8354 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8355 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 8356 | /** |
| 8357 | * 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] | 8358 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8359 | * @enable: enable or disable this behaviour |
| 8360 | * |
| 8361 | * Return: int |
| 8362 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8363 | 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] | 8364 | { |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8365 | struct wow_pulse_mode wow_pulse_set_info; |
| 8366 | QDF_STATUS status; |
| 8367 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8368 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8369 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8370 | if (!ucfg_pmo_is_wow_pulse_enabled(phddctx->psoc)) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8371 | return 0; |
| 8372 | |
| 8373 | /* prepare the request to send to SME */ |
| 8374 | if (enable == true) { |
| 8375 | wow_pulse_set_info.wow_pulse_enable = true; |
| 8376 | wow_pulse_set_info.wow_pulse_pin = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8377 | ucfg_pmo_get_wow_pulse_pin(phddctx->psoc); |
| 8378 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8379 | wow_pulse_set_info.wow_pulse_interval_high = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8380 | ucfg_pmo_get_wow_pulse_interval_high(phddctx->psoc); |
| 8381 | |
| 8382 | wow_pulse_set_info.wow_pulse_interval_low = |
| 8383 | ucfg_pmo_get_wow_pulse_interval_low(phddctx->psoc); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8384 | } else { |
| 8385 | wow_pulse_set_info.wow_pulse_enable = false; |
| 8386 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 8387 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 8388 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 8389 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8390 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8391 | wow_pulse_set_info.wow_pulse_enable, |
| 8392 | wow_pulse_set_info.wow_pulse_pin, |
| 8393 | wow_pulse_set_info.wow_pulse_interval_low, |
| 8394 | wow_pulse_set_info.wow_pulse_interval_high); |
| 8395 | |
| 8396 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 8397 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8398 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8399 | return -EIO; |
| 8400 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8401 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8402 | return 0; |
| 8403 | } |
| 8404 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8405 | 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] | 8406 | { |
| 8407 | return 0; |
| 8408 | } |
| 8409 | #endif |
| 8410 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8411 | #ifdef WLAN_FEATURE_FASTPATH |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8412 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8413 | /** |
| 8414 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 8415 | * @hdd_cfg: hdd config |
| 8416 | * @context: lower layer context |
| 8417 | * |
| 8418 | * Return: none |
| 8419 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8420 | void hdd_enable_fastpath(struct hdd_context *hdd_ctx, |
| 8421 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8422 | { |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8423 | if (cfg_get(hdd_ctx->psoc, CFG_DP_ENABLE_FASTPATH)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8424 | hif_enable_fastpath(context); |
| 8425 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8426 | #endif |
| 8427 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8428 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8429 | /** |
| 8430 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8431 | * @hdd_handle: opaque handle for the hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8432 | * @level: thermal level |
| 8433 | * |
| 8434 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8435 | * than 0, and restore the original data path when throttle level is 0 |
| 8436 | * |
| 8437 | * Return: none |
| 8438 | */ |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8439 | 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] | 8440 | { |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8441 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8442 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8443 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 8444 | if (level > THROTTLE_LEVEL_0) |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8445 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8446 | else |
| 8447 | /* restore original concurrency mode */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8448 | 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] | 8449 | } |
| 8450 | |
| 8451 | /** |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8452 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8453 | * @hdd_ctx: pointer to hdd context |
| 8454 | * @adapter: pointer to softap adapter |
| 8455 | * |
| 8456 | * This function is used to get safe channel from current regulatory valid |
| 8457 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8458 | * |
| 8459 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8460 | * failure, the channel number returned is zero. |
| 8461 | */ |
| 8462 | static uint8_t |
| 8463 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8464 | struct hdd_adapter *adapter) |
| 8465 | { |
| 8466 | struct sir_pcl_list pcl = {0}; |
| 8467 | uint32_t i, j; |
| 8468 | bool found = false; |
| 8469 | int ret; |
| 8470 | |
| 8471 | /* Try for safe channel from all valid channel */ |
| 8472 | pcl.pcl_len = MAX_NUM_CHAN; |
| 8473 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 8474 | &pcl.pcl_len); |
| 8475 | if (ret) { |
| 8476 | hdd_err("error %d in getting valid channel list", ret); |
| 8477 | return INVALID_CHANNEL_ID; |
| 8478 | } |
| 8479 | |
| 8480 | for (i = 0; i < pcl.pcl_len; i++) { |
| 8481 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 8482 | found = false; |
| 8483 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
| 8484 | if (pcl.pcl_list[i] == |
| 8485 | hdd_ctx->unsafe_channel_list[j]) { |
| 8486 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
| 8487 | found = true; |
| 8488 | break; |
| 8489 | } |
| 8490 | } |
| 8491 | |
| 8492 | if (found) |
| 8493 | continue; |
| 8494 | |
| 8495 | if ((pcl.pcl_list[i] >= |
| 8496 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
| 8497 | (pcl.pcl_list[i] <= |
| 8498 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
| 8499 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
| 8500 | return pcl.pcl_list[i]; |
| 8501 | } |
| 8502 | } |
| 8503 | |
| 8504 | return INVALID_CHANNEL_ID; |
| 8505 | } |
| 8506 | |
| 8507 | #else |
| 8508 | /** |
| 8509 | * hdd_set_thermal_level_cb() - set thermal level callback function |
| 8510 | * @hdd_handle: opaque handle for the hdd context |
| 8511 | * @level: thermal level |
| 8512 | * |
| 8513 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8514 | * than 0, and restore the original data path when throttle level is 0 |
| 8515 | * |
| 8516 | * Return: none |
| 8517 | */ |
| 8518 | static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level) |
| 8519 | { |
| 8520 | } |
| 8521 | |
| 8522 | /** |
| 8523 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8524 | * @hdd_ctx: pointer to hdd context |
| 8525 | * @adapter: pointer to softap adapter |
| 8526 | * |
| 8527 | * This function is used to get safe channel from current regulatory valid |
| 8528 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8529 | * |
| 8530 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8531 | * failure, the channel number returned is zero. |
| 8532 | */ |
| 8533 | static uint8_t |
| 8534 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8535 | struct hdd_adapter *adapter) |
| 8536 | { |
| 8537 | return 0; |
| 8538 | } |
| 8539 | #endif |
| 8540 | |
| 8541 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8542 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 8543 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 8544 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8545 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8546 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 8547 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 8548 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8549 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8550 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8551 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8552 | */ |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8553 | static uint8_t |
| 8554 | 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] | 8555 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8556 | struct sir_pcl_list pcl; |
| 8557 | QDF_STATUS status; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8558 | uint32_t i; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8559 | mac_handle_t mac_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8560 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8561 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8562 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8563 | if (!hdd_ctx) { |
| 8564 | hdd_err("invalid HDD context"); |
| 8565 | return INVALID_CHANNEL_ID; |
| 8566 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8567 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8568 | mac_handle = hdd_ctx->mac_handle; |
| 8569 | if (!mac_handle) { |
| 8570 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 8571 | return INVALID_CHANNEL_ID; |
| 8572 | } |
| 8573 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8574 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8575 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 8576 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 8577 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8578 | if (QDF_IS_STATUS_ERROR(status)) { |
| 8579 | hdd_err("Get PCL failed"); |
| 8580 | return INVALID_CHANNEL_ID; |
| 8581 | } |
| 8582 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 8583 | /* |
| 8584 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 8585 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 8586 | * try to choose a safe channel from acs range. |
| 8587 | */ |
| 8588 | if (!pcl.pcl_len) |
| 8589 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8590 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8591 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8592 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 8593 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8594 | |
| 8595 | /* PCL already takes unsafe channel into account */ |
| 8596 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8597 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8598 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8599 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8600 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8601 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8602 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8603 | return pcl.pcl_list[i]; |
| 8604 | } |
| 8605 | } |
| 8606 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8607 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8608 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8609 | return hdd_get_safe_channel(hdd_ctx, adapter); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8610 | } |
| 8611 | |
| 8612 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8613 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8614 | * @adapter: AP adapter |
| 8615 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8616 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8617 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8618 | * Moves the SAP interface by invoking the function which |
| 8619 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8620 | * |
| 8621 | * Return: None |
| 8622 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8623 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8624 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8625 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8626 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8627 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8628 | mac_handle_t mac_handle; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8629 | |
| 8630 | if (!adapter) { |
| 8631 | hdd_err("invalid adapter"); |
| 8632 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8633 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8634 | |
| 8635 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8636 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8637 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 8638 | if (!mac_handle) { |
| 8639 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8640 | return; |
| 8641 | } |
| 8642 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8643 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8644 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8645 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8646 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8647 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8648 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8649 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8650 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8651 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8652 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8653 | 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] | 8654 | { |
| 8655 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8656 | int status; |
| 8657 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8658 | |
| 8659 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8660 | |
| 8661 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8662 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8663 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8664 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8665 | } |
| 8666 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8667 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8668 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8669 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8670 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8671 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8672 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8673 | hdd_err("failed to start external acs timer"); |
| 8674 | return -ENOSPC; |
| 8675 | } |
| 8676 | /* Update config to application */ |
| 8677 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8678 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8679 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8680 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8681 | } |
| 8682 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8683 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8684 | /** |
| 8685 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8686 | * @hdd_ctx: hdd context pointer |
| 8687 | * |
| 8688 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8689 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8690 | * sap. User space on LTE coex indication restart driver. |
| 8691 | * |
| 8692 | * Return - none |
| 8693 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8694 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8695 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8696 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8697 | uint32_t i; |
| 8698 | bool found = false; |
| 8699 | uint8_t restart_chan; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8700 | uint8_t scc_on_lte_coex = 0; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8701 | bool value; |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8702 | QDF_STATUS status; |
| 8703 | bool is_acs_support_for_dfs_ltecoex = cfg_default(CFG_USER_ACS_DFS_LTE); |
| 8704 | bool is_vendor_acs_support = |
| 8705 | cfg_default(CFG_USER_AUTO_CHANNEL_SELECTION); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8706 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8707 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8708 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8709 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8710 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8711 | adapter->device_mode, |
| 8712 | adapter->session.ap.sap_config. |
| 8713 | acs_cfg.acs_mode); |
| 8714 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8715 | } |
| 8716 | |
| 8717 | found = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8718 | status = |
| 8719 | ucfg_policy_mgr_get_sta_sap_scc_lte_coex_chnl(hdd_ctxt->psoc, |
| 8720 | &scc_on_lte_coex); |
| 8721 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8722 | hdd_err("can't get scc on lte coex chnl, use def"); |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8723 | /* |
| 8724 | * If STA+SAP is doing SCC & g_sta_sap_scc_on_lte_coex_chan |
| 8725 | * is set, no need to move SAP. |
| 8726 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8727 | if (policy_mgr_is_sta_sap_scc(hdd_ctxt->psoc, |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8728 | adapter->session.ap.operating_channel) && |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8729 | scc_on_lte_coex) |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8730 | hdd_debug("SAP is allowed on SCC channel, no need to move SAP"); |
| 8731 | else { |
| 8732 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
| 8733 | if (adapter->session.ap.operating_channel == |
| 8734 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8735 | found = true; |
| 8736 | hdd_debug("operating ch:%d is unsafe", |
| 8737 | adapter->session.ap.operating_channel); |
| 8738 | break; |
| 8739 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8740 | } |
| 8741 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8742 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8743 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8744 | adapter->session.ap.operating_channel); |
| 8745 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8746 | } |
| 8747 | |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8748 | status = ucfg_mlme_get_acs_support_for_dfs_ltecoex( |
| 8749 | hdd_ctxt->psoc, |
| 8750 | &is_acs_support_for_dfs_ltecoex); |
| 8751 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8752 | hdd_err("get_acs_support_for_dfs_ltecoex failed,set def"); |
| 8753 | |
| 8754 | status = ucfg_mlme_get_vendor_acs_support( |
| 8755 | hdd_ctxt->psoc, |
| 8756 | &is_vendor_acs_support); |
| 8757 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8758 | hdd_err("get_vendor_acs_support failed, set default"); |
| 8759 | |
| 8760 | if (is_vendor_acs_support && is_acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8761 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8762 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8763 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8764 | } else |
| 8765 | restart_chan = |
| 8766 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8767 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8768 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8769 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8770 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8771 | /* |
| 8772 | * SAP restart due to unsafe channel. While |
| 8773 | * restarting the SAP, make sure to clear |
| 8774 | * acs_channel, channel to reset to |
| 8775 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8776 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8777 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8778 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8779 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8780 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8781 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 8782 | ucfg_mlme_get_sap_internal_restart(hdd_ctxt->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8783 | &value); |
| 8784 | hdd_debug("driver to start sap: %d", value); |
| 8785 | if (value) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8786 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8787 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8788 | else |
| 8789 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8790 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8791 | } |
| 8792 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8793 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8794 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8795 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8796 | * @hdd_ctx: HDD global context |
| 8797 | * |
| 8798 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8799 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8800 | * down to the lower layers. Then subscribe to subsequent channel |
| 8801 | * avoidance events. |
| 8802 | * |
| 8803 | * Return: None |
| 8804 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8805 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8806 | { |
| 8807 | uint16_t unsafe_channel_count; |
| 8808 | int index; |
| 8809 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8810 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8811 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8812 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8813 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8814 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8815 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8816 | hdd_ctx->unsafe_channel_count); |
| 8817 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8818 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8819 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8820 | |
| 8821 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8822 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8823 | hdd_ctx->unsafe_channel_list[index]); |
| 8824 | |
| 8825 | } |
| 8826 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8827 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8828 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8829 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8830 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8831 | { |
| 8832 | uint8_t restart_chan; |
| 8833 | |
| 8834 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8835 | if (!restart_chan) { |
| 8836 | hdd_alert("fail to restart SAP"); |
| 8837 | return; |
| 8838 | } |
| 8839 | |
| 8840 | /* SAP restart due to unsafe channel. While restarting |
| 8841 | * the SAP, make sure to clear acs_channel, channel to |
| 8842 | * reset to 0. Otherwise these settings will override |
| 8843 | * the ACS while restart. |
| 8844 | */ |
| 8845 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8846 | |
| 8847 | hdd_debug("sending coex indication"); |
| 8848 | |
| 8849 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8850 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8851 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8852 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8853 | |
| 8854 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8855 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8856 | { |
| 8857 | uint32_t size; |
| 8858 | uint16_t *unsafe_list; |
| 8859 | uint16_t chan_count; |
| 8860 | |
| 8861 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8862 | return -EINVAL; |
| 8863 | |
| 8864 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8865 | NUM_CHANNELS); |
| 8866 | if (chan_count) { |
| 8867 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8868 | unsafe_list = qdf_mem_malloc(size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8869 | if (!unsafe_list) |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8870 | return -ENOMEM; |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8871 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8872 | } else { |
| 8873 | unsafe_list = NULL; |
| 8874 | } |
| 8875 | |
| 8876 | *local_unsafe_list = unsafe_list; |
| 8877 | *local_unsafe_list_count = chan_count; |
| 8878 | |
| 8879 | return 0; |
| 8880 | } |
| 8881 | |
| 8882 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8883 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8884 | { |
| 8885 | int i, j; |
| 8886 | |
| 8887 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8888 | return true; |
| 8889 | if (local_unsafe_list_count == 0) |
| 8890 | return false; |
| 8891 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8892 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8893 | if (local_unsafe_list[i] == |
| 8894 | hdd_ctx->unsafe_channel_list[j]) |
| 8895 | break; |
| 8896 | if (j >= local_unsafe_list_count) |
| 8897 | break; |
| 8898 | } |
| 8899 | if (i >= local_unsafe_list_count) { |
| 8900 | hdd_info("unsafe chan list same"); |
| 8901 | return false; |
| 8902 | } |
| 8903 | |
| 8904 | return true; |
| 8905 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8906 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8907 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8908 | { |
| 8909 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8910 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8911 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8912 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8913 | { |
| 8914 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8915 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8916 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8917 | |
| 8918 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8919 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8920 | * user space |
| 8921 | * @frame_ind: Management frame data to be informed. |
| 8922 | * |
| 8923 | * This function is used to indicate management frame to |
| 8924 | * user space |
| 8925 | * |
| 8926 | * Return: None |
| 8927 | * |
| 8928 | */ |
| 8929 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8930 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8931 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8932 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8933 | int i; |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8934 | struct ieee80211_mgmt *mgmt = |
| 8935 | (struct ieee80211_mgmt *)frame_ind->frameBuf; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8936 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 8937 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8938 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8939 | return; |
| 8940 | |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 8941 | if (frame_ind->frame_len < ieee80211_hdrlen(mgmt->frame_control)) { |
| 8942 | hdd_err(" Invalid frame length"); |
| 8943 | return; |
| 8944 | } |
| 8945 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8946 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 8947 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 8948 | adapter = |
| 8949 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 8950 | if (adapter) |
| 8951 | break; |
| 8952 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8953 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8954 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8955 | if ((NULL != adapter) && |
| 8956 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8957 | __hdd_indicate_mgmt_frame(adapter, |
| 8958 | frame_ind->frame_len, |
| 8959 | frame_ind->frameBuf, |
| 8960 | frame_ind->frameType, |
| 8961 | frame_ind->rxChan, |
| 8962 | frame_ind->rxRssi); |
| 8963 | } |
| 8964 | } |
| 8965 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8966 | } else { |
| 8967 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 8968 | frame_ind->sessionId); |
| 8969 | } |
| 8970 | |
| 8971 | if ((NULL != adapter) && |
| 8972 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8973 | __hdd_indicate_mgmt_frame(adapter, |
| 8974 | frame_ind->frame_len, |
| 8975 | frame_ind->frameBuf, |
| 8976 | frame_ind->frameType, |
| 8977 | frame_ind->rxChan, |
| 8978 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8979 | } |
| 8980 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8981 | void hdd_acs_response_timeout_handler(void *context) |
| 8982 | { |
| 8983 | struct hdd_external_acs_timer_context *timer_context = |
| 8984 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8985 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8986 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8987 | uint8_t reason; |
| 8988 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8989 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8990 | if (!timer_context) { |
| 8991 | hdd_err("invlaid timer context"); |
| 8992 | return; |
| 8993 | } |
| 8994 | adapter = timer_context->adapter; |
| 8995 | reason = timer_context->reason; |
| 8996 | |
| 8997 | |
| 8998 | if ((!adapter) || |
| 8999 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 9000 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 9001 | return; |
| 9002 | } |
| 9003 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9004 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 9005 | return; |
| 9006 | |
| 9007 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 9008 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 9009 | else |
| 9010 | return; |
| 9011 | |
| 9012 | hdd_err("ACS timeout happened for %s reason %d", |
| 9013 | adapter->dev->name, reason); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9014 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9015 | switch (reason) { |
| 9016 | /* SAP init case */ |
| 9017 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 9018 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 9019 | false); |
| 9020 | wlan_hdd_cfg80211_start_acs(adapter); |
| 9021 | break; |
| 9022 | /* DFS detected on current channel */ |
| 9023 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 9024 | wlan_sap_update_next_channel( |
| 9025 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9026 | sme_update_new_channel_event(hdd_ctx->mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 9027 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9028 | break; |
| 9029 | /* LTE coex event on current channel */ |
| 9030 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 9031 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 9032 | break; |
| 9033 | default: |
| 9034 | hdd_info("invalid reason for timer invoke"); |
| 9035 | |
| 9036 | } |
| 9037 | } |
| 9038 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9039 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9040 | * hdd_override_ini_config - Override INI config |
| 9041 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9042 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9043 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9044 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9045 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9046 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9047 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9048 | { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9049 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9050 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9051 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 9052 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9053 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9054 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9055 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9056 | if (0 == enable_11d || 1 == enable_11d) { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9057 | status = ucfg_mlme_set_11d_enabled(hdd_ctx->psoc, enable_11d); |
| 9058 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9059 | hdd_err("Failed to set 11d_enable flag"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9060 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 9061 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9062 | if (hdd_ctx->config->action_oui_enable && !ucfg_action_oui_enabled()) { |
| 9063 | hdd_ctx->config->action_oui_enable = 0; |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9064 | hdd_err("Ignore action oui ini, since no action_oui component"); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9065 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9066 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9067 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9068 | #ifdef ENABLE_MTRACE_LOG |
| 9069 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9070 | { |
| 9071 | uint8_t module_id = 0; |
| 9072 | int qdf_print_idx = -1; |
| 9073 | |
| 9074 | qdf_print_idx = qdf_get_pidx(); |
| 9075 | for (module_id = 0; module_id < QDF_MODULE_ID_MAX; module_id++) |
| 9076 | qdf_print_set_category_verbose( |
| 9077 | qdf_print_idx, |
| 9078 | module_id, QDF_TRACE_LEVEL_TRACE, |
| 9079 | hdd_ctx->config->enable_mtrace); |
| 9080 | } |
| 9081 | #else |
| 9082 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9083 | { |
| 9084 | } |
| 9085 | |
| 9086 | #endif |
| 9087 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9088 | /** |
| 9089 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 9090 | * @hdd_ctx - HDD context |
| 9091 | * |
| 9092 | * Set trace level for each module based on INI config. |
| 9093 | * |
| 9094 | * Return: None |
| 9095 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9096 | 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] | 9097 | { |
Wu Gao | bc6eaa1 | 2018-11-30 14:17:45 +0800 | [diff] [blame] | 9098 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, 0x7f); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 9099 | hdd_qdf_trace_enable(QDF_MODULE_ID_MLME, 0xffff); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 9100 | hdd_qdf_trace_enable(QDF_MODULE_ID_FWOL, 0xffff); |
Kiran Kumar Lokere | 4ce4048 | 2018-08-30 16:31:00 -0700 | [diff] [blame] | 9101 | hdd_qdf_trace_enable(QDF_MODULE_ID_CRYPTO, 0xffff); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 9102 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9103 | hdd_set_mtrace_for_each(hdd_ctx); |
| 9104 | |
Nirav Shah | 5c083da | 2018-08-03 13:46:02 +0530 | [diff] [blame] | 9105 | hdd_cfg_print_global_config(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9106 | } |
| 9107 | |
| 9108 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9109 | * hdd_context_init() - Initialize HDD context |
| 9110 | * @hdd_ctx: HDD context. |
| 9111 | * |
| 9112 | * Initialize HDD context along with all the feature specific contexts. |
| 9113 | * |
| 9114 | * return: 0 on success and errno on failure. |
| 9115 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9116 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9117 | { |
| 9118 | int ret; |
| 9119 | |
| 9120 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 9121 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 9122 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9123 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 9124 | init_completion(&hdd_ctx->ready_to_suspend); |
| 9125 | |
| 9126 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9127 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 9128 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 9129 | qdf_list_create(&hdd_ctx->hdd_adapters, 0); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9130 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9131 | ret = hdd_scan_context_init(hdd_ctx); |
| 9132 | if (ret) |
| 9133 | goto list_destroy; |
| 9134 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9135 | hdd_rx_wake_lock_create(hdd_ctx); |
| 9136 | |
| 9137 | ret = hdd_sap_context_init(hdd_ctx); |
| 9138 | if (ret) |
| 9139 | goto scan_destroy; |
| 9140 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9141 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 9142 | |
| 9143 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 9144 | |
| 9145 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 9146 | hdd_ctx->config); |
| 9147 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 9148 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9149 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 9150 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 9151 | "monitor_mode_wakelock"); |
| 9152 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9153 | return 0; |
| 9154 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9155 | sap_destroy: |
| 9156 | hdd_sap_context_destroy(hdd_ctx); |
| 9157 | |
| 9158 | scan_destroy: |
| 9159 | hdd_scan_context_destroy(hdd_ctx); |
| 9160 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9161 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 9162 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 9163 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9164 | return ret; |
| 9165 | } |
| 9166 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9167 | void hdd_psoc_idle_timer_start(struct hdd_context *hdd_ctx) |
| 9168 | { |
| 9169 | uint32_t timeout_ms = hdd_ctx->config->iface_change_wait_time; |
| 9170 | enum wake_lock_reason reason = |
| 9171 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER; |
| 9172 | |
| 9173 | hdd_debug("Starting psoc idle timer"); |
| 9174 | qdf_sched_delayed_work(&hdd_ctx->psoc_idle_timeout_work, timeout_ms); |
| 9175 | hdd_prevent_suspend_timeout(timeout_ms, reason); |
| 9176 | } |
| 9177 | |
| 9178 | void hdd_psoc_idle_timer_stop(struct hdd_context *hdd_ctx) |
| 9179 | { |
| 9180 | qdf_cancel_delayed_work(&hdd_ctx->psoc_idle_timeout_work); |
| 9181 | hdd_debug("Stopped psoc idle timer"); |
| 9182 | } |
| 9183 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9184 | /** |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9185 | * hdd_psoc_idle_shutdown() - perform an idle shutdown on the given psoc |
| 9186 | * @hdd_ctx: the hdd context which should be shutdown |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9187 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9188 | * When no interfaces are "up" on a psoc, an idle shutdown timer is started. |
| 9189 | * If no interfaces are brought up before the timer expires, we do an |
| 9190 | * "idle shutdown," cutting power to the physical SoC to save power. This is |
| 9191 | * done completely transparently from the perspective of userspace. |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9192 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9193 | * Return: None |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9194 | */ |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9195 | static void hdd_psoc_idle_shutdown(struct hdd_context *hdd_ctx) |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9196 | { |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9197 | struct hdd_psoc *hdd_psoc = hdd_ctx->hdd_psoc; |
| 9198 | QDF_STATUS status; |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9199 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9200 | hdd_enter(); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9201 | |
| 9202 | status = dsc_psoc_trans_start(hdd_psoc->dsc_psoc, "idle shutdown"); |
| 9203 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9204 | hdd_info("psoc busy, abort idle shutdown; status:%u", status); |
| 9205 | return; |
| 9206 | } |
| 9207 | |
| 9208 | QDF_BUG(!hdd_wlan_stop_modules(hdd_ctx, false)); |
| 9209 | |
| 9210 | hdd_psoc->state = psoc_state_idle; |
| 9211 | dsc_psoc_trans_stop(hdd_psoc->dsc_psoc); |
| 9212 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9213 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9214 | } |
| 9215 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9216 | int hdd_psoc_idle_restart(struct hdd_context *hdd_ctx) |
| 9217 | { |
| 9218 | struct hdd_psoc *hdd_psoc = hdd_ctx->hdd_psoc; |
| 9219 | QDF_STATUS status; |
| 9220 | int errno; |
| 9221 | |
| 9222 | status = dsc_psoc_trans_start_wait(hdd_psoc->dsc_psoc, "idle restart"); |
| 9223 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9224 | hdd_info("unable to start 'idle restart'; status:%u", status); |
| 9225 | return qdf_status_to_os_return(status); |
| 9226 | } |
| 9227 | |
| 9228 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 9229 | if (!errno) |
| 9230 | hdd_psoc->state = psoc_state_active; |
| 9231 | |
| 9232 | dsc_psoc_trans_stop(hdd_psoc->dsc_psoc); |
| 9233 | |
| 9234 | return errno; |
| 9235 | } |
| 9236 | |
| 9237 | /** |
| 9238 | * hdd_psoc_idle_timeout_callback() - Handler for psoc idle timeout |
| 9239 | * @priv: pointer to hdd context |
| 9240 | * |
| 9241 | * Return: None |
| 9242 | */ |
| 9243 | static void hdd_psoc_idle_timeout_callback(void *priv) |
| 9244 | { |
| 9245 | struct hdd_context *hdd_ctx = priv; |
| 9246 | |
| 9247 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 9248 | return; |
| 9249 | |
| 9250 | hdd_debug("Psoc idle timeout elapsed; starting psoc shutdown"); |
| 9251 | hdd_psoc_idle_shutdown(hdd_ctx); |
| 9252 | } |
| 9253 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9254 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9255 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9256 | { |
| 9257 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 9258 | wlan_logging_to_console); |
| 9259 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 9260 | } |
| 9261 | #else |
| 9262 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9263 | { } |
| 9264 | #endif |
| 9265 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9266 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9267 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9268 | struct wlan_objmgr_psoc *psoc) |
| 9269 | { |
| 9270 | config->wlan_logging_enable = cfg_get(psoc, CFG_WLAN_LOGGING_SUPPORT); |
| 9271 | |
| 9272 | config->wlan_logging_to_console = |
| 9273 | cfg_get(psoc, CFG_WLAN_LOGGING_CONSOLE_SUPPORT); |
| 9274 | } |
| 9275 | #else |
| 9276 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9277 | struct wlan_objmgr_psoc *psoc) |
| 9278 | { |
| 9279 | } |
| 9280 | #endif |
| 9281 | |
| 9282 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9283 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9284 | struct wlan_objmgr_psoc *psoc) |
| 9285 | { |
| 9286 | config->wlan_auto_shutdown = cfg_get(psoc, CFG_WLAN_AUTO_SHUTDOWN); |
| 9287 | } |
| 9288 | #else |
| 9289 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9290 | struct wlan_objmgr_psoc *psoc) |
| 9291 | { |
| 9292 | } |
| 9293 | #endif |
| 9294 | |
| 9295 | #ifndef REMOVE_PKT_LOG |
| 9296 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9297 | struct wlan_objmgr_psoc *psoc) |
| 9298 | { |
| 9299 | config->enable_packet_log = cfg_get(psoc, CFG_ENABLE_PACKET_LOG); |
| 9300 | } |
| 9301 | #else |
| 9302 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9303 | struct wlan_objmgr_psoc *psoc) |
| 9304 | { |
| 9305 | } |
| 9306 | #endif |
| 9307 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9308 | #ifdef FEATURE_RUNTIME_PM |
| 9309 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9310 | struct wlan_objmgr_psoc *psoc) |
| 9311 | { |
| 9312 | config->runtime_pm = cfg_get(psoc, CFG_ENABLE_RUNTIME_PM); |
| 9313 | } |
| 9314 | #else |
| 9315 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9316 | struct wlan_objmgr_psoc *psoc) |
| 9317 | |
| 9318 | { |
| 9319 | } |
| 9320 | #endif |
| 9321 | |
| 9322 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 9323 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9324 | struct wlan_objmgr_psoc *psoc) |
| 9325 | { |
| 9326 | config->vc_mode_cfg_bitmap = cfg_get(psoc, CFG_VC_MODE_BITMAP); |
| 9327 | } |
| 9328 | #else |
| 9329 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9330 | struct wlan_objmgr_psoc *psoc) |
| 9331 | { |
| 9332 | } |
| 9333 | #endif |
| 9334 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9335 | /** |
| 9336 | * hdd_cfg_params_init() - Initialize hdd params in hdd_config strucuture |
| 9337 | * @hdd_ctx - Pointer to HDD context |
| 9338 | * |
| 9339 | * Return: None |
| 9340 | */ |
| 9341 | static void hdd_cfg_params_init(struct hdd_context *hdd_ctx) |
| 9342 | { |
| 9343 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
| 9344 | struct hdd_config *config = hdd_ctx->config; |
| 9345 | |
| 9346 | if (!psoc) { |
| 9347 | hdd_err("Invalid psoc"); |
| 9348 | return; |
| 9349 | } |
| 9350 | |
| 9351 | if (!config) { |
| 9352 | hdd_err("Invalid hdd config"); |
| 9353 | return; |
| 9354 | } |
| 9355 | |
| 9356 | config->bug_on_reinit_failure = cfg_get(psoc, |
| 9357 | CFG_BUG_ON_REINIT_FAILURE); |
| 9358 | |
| 9359 | config->is_ramdump_enabled = cfg_get(psoc, |
| 9360 | CFG_ENABLE_RAMDUMP_COLLECTION); |
| 9361 | |
| 9362 | config->iface_change_wait_time = cfg_get(psoc, |
| 9363 | CFG_INTERFACE_CHANGE_WAIT); |
| 9364 | |
| 9365 | config->multicast_host_fw_msgs = cfg_get(psoc, |
| 9366 | CFG_MULTICAST_HOST_FW_MSGS); |
| 9367 | |
| 9368 | config->private_wext_control = cfg_get(psoc, CFG_PRIVATE_WEXT_CONTROL); |
| 9369 | config->timer_multiplier = cfg_get(psoc, CFG_TIMER_MULTIPLIER); |
| 9370 | config->enablefwprint = cfg_get(psoc, CFG_ENABLE_FW_UART_PRINT); |
| 9371 | config->enable_fw_log = cfg_get(psoc, CFG_ENABLE_FW_LOG); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9372 | config->operating_channel = cfg_get(psoc, CFG_OPERATING_CHANNEL); |
| 9373 | config->num_vdevs = cfg_get(psoc, CFG_NUM_VDEV_ENABLE); |
| 9374 | |
| 9375 | qdf_str_lcopy(config->enable_concurrent_sta, |
| 9376 | cfg_get(psoc, CFG_ENABLE_CONCURRENT_STA), |
| 9377 | CFG_CONCURRENT_IFACE_MAX_LEN); |
| 9378 | qdf_str_lcopy(config->dbs_scan_selection, |
| 9379 | cfg_get(psoc, CFG_DBS_SCAN_SELECTION), |
| 9380 | CFG_DBS_SCAN_PARAM_LENGTH); |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9381 | config->inform_bss_rssi_raw = cfg_get(psoc, CFG_INFORM_BSS_RSSI_RAW); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9382 | config->intfMacAddr[0] = cfg_get(psoc, CFG_INTF0_MAC_ADDR); |
| 9383 | config->intfMacAddr[1] = cfg_get(psoc, CFG_INTF1_MAC_ADDR); |
| 9384 | config->intfMacAddr[2] = cfg_get(psoc, CFG_INTF2_MAC_ADDR); |
| 9385 | config->intfMacAddr[3] = cfg_get(psoc, CFG_INTF3_MAC_ADDR); |
| 9386 | config->action_oui_enable = cfg_get(psoc, CFG_ENABLE_ACTION_OUI); |
| 9387 | |
| 9388 | qdf_str_lcopy(config->action_oui_str[0], |
| 9389 | cfg_get(psoc, CFG_ACTION_OUI_CONNECT_1X1), |
| 9390 | ACTION_OUI_MAX_STR_LEN); |
| 9391 | qdf_str_lcopy(config->action_oui_str[1], |
| 9392 | cfg_get(psoc, CFG_ACTION_OUI_ITO_EXTENSION), |
| 9393 | ACTION_OUI_MAX_STR_LEN); |
| 9394 | qdf_str_lcopy(config->action_oui_str[2], |
| 9395 | cfg_get(psoc, CFG_ACTION_OUI_CCKM_1X1), |
| 9396 | ACTION_OUI_MAX_STR_LEN); |
| 9397 | qdf_str_lcopy(config->action_oui_str[3], |
| 9398 | cfg_get(psoc, CFG_ACTION_OUI_ITO_ALTERNATE), |
| 9399 | ACTION_OUI_MAX_STR_LEN); |
| 9400 | qdf_str_lcopy(config->action_oui_str[4], |
| 9401 | cfg_get(psoc, CFG_ACTION_OUI_SWITCH_TO_11N_MODE), |
| 9402 | ACTION_OUI_MAX_STR_LEN); |
| 9403 | qdf_str_lcopy(config->action_oui_str[5], |
| 9404 | cfg_get(psoc, |
| 9405 | CFG_ACTION_OUI_CONNECT_1X1_WITH_1_CHAIN), |
| 9406 | ACTION_OUI_MAX_STR_LEN); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9407 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9408 | hdd_init_vc_mode_cfg_bitmap(config, psoc); |
| 9409 | hdd_init_runtime_pm(config, psoc); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9410 | hdd_init_wlan_auto_shutdown(config, psoc); |
| 9411 | hdd_init_wlan_logging_params(config, psoc); |
| 9412 | hdd_init_packet_log(config, psoc); |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 9413 | hdd_dp_cfg_update(psoc, hdd_ctx); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9414 | } |
| 9415 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 9416 | struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9417 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9418 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9419 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9420 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9421 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9422 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9423 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 9424 | hdd_ctx = hdd_cfg80211_wiphy_alloc(); |
| 9425 | if (!hdd_ctx) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9426 | ret = -ENOMEM; |
| 9427 | goto err_out; |
| 9428 | } |
| 9429 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9430 | qdf_create_delayed_work(&hdd_ctx->psoc_idle_timeout_work, |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9431 | hdd_psoc_idle_timeout_callback, |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9432 | hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9433 | |
| 9434 | mutex_init(&hdd_ctx->iface_change_lock); |
| 9435 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9436 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 9437 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9438 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9439 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9440 | if (!hdd_ctx->config) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9441 | ret = -ENOMEM; |
| 9442 | goto err_free_hdd_context; |
| 9443 | } |
| 9444 | |
| 9445 | /* Read and parse the qcom_cfg.ini file */ |
| 9446 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9447 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9448 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9449 | WLAN_INI_FILE); |
| 9450 | ret = -EINVAL; |
| 9451 | goto err_free_config; |
| 9452 | } |
| 9453 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 9454 | status = cfg_parse(WLAN_INI_FILE); |
| 9455 | if (QDF_IS_STATUS_ERROR(status)) |
| 9456 | hdd_err("Failed to parse cfg %s; status:%d\n", |
| 9457 | WLAN_INI_FILE, status); |
| 9458 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9459 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID); |
| 9460 | if (ret) { |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9461 | QDF_DEBUG_PANIC("Psoc creation fails!"); |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9462 | goto err_free_config; |
| 9463 | } |
| 9464 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9465 | hdd_cfg_params_init(hdd_ctx); |
| 9466 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 9467 | hdd_debug("setting timer multiplier: %u", |
| 9468 | hdd_ctx->config->timer_multiplier); |
| 9469 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 9470 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9471 | cds_set_fatal_event(cfg_get(hdd_ctx->psoc, |
| 9472 | CFG_ENABLE_FATAL_EVENT_TRIGGER)); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 9473 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9474 | hdd_override_ini_config(hdd_ctx); |
| 9475 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9476 | ret = hdd_context_init(hdd_ctx); |
| 9477 | |
| 9478 | if (ret) |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9479 | goto err_hdd_objmgr_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9480 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 9481 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9482 | goto skip_multicast_logging; |
| 9483 | |
| 9484 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 9485 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9486 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 9487 | if (ret) |
| 9488 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9489 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9490 | ret = hdd_init_netlink_services(hdd_ctx); |
| 9491 | if (ret) |
| 9492 | goto err_deinit_txrx_histogram; |
| 9493 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9494 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9495 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9496 | skip_multicast_logging: |
| 9497 | hdd_set_trace_level_for_each(hdd_ctx); |
| 9498 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 9499 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 9500 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9501 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 9502 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9503 | return hdd_ctx; |
| 9504 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9505 | err_deinit_txrx_histogram: |
| 9506 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 9507 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9508 | err_deinit_hdd_context: |
| 9509 | hdd_context_deinit(hdd_ctx); |
| 9510 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9511 | err_hdd_objmgr_destroy: |
| 9512 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 9513 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9514 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9515 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9516 | |
| 9517 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9518 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 9519 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9520 | |
| 9521 | err_out: |
| 9522 | return ERR_PTR(ret); |
| 9523 | } |
| 9524 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9525 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 9526 | /** |
| 9527 | * hdd_open_p2p_interface - Open P2P interface |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9528 | * @hdd_ctx: HDD context |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9529 | * |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9530 | * Return: QDF_STATUS |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9531 | */ |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9532 | static QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9533 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9534 | struct hdd_adapter *adapter; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9535 | bool p2p_dev_addr_admin; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9536 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9537 | cfg_p2p_get_device_addr_admin(hdd_ctx->psoc, &p2p_dev_addr_admin); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9538 | |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9539 | if (p2p_dev_addr_admin && |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9540 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9541 | hdd_ctx->p2p_device_address = hdd_ctx->config->intfMacAddr[0]; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9542 | |
| 9543 | /* |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9544 | * Generate the P2P Device Address. This consists of |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9545 | * the device's primary MAC address with the locally |
| 9546 | * administered bit set. |
| 9547 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9548 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9549 | } else { |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9550 | uint8_t *p2p_dev_addr; |
| 9551 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9552 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9553 | if (!p2p_dev_addr) { |
| 9554 | hdd_err("Failed to get MAC address for new p2p device"); |
| 9555 | return QDF_STATUS_E_INVAL; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9556 | } |
| 9557 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9558 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9559 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9560 | } |
| 9561 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9562 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9563 | hdd_ctx->p2p_device_address.bytes, |
| 9564 | NET_NAME_UNKNOWN, true); |
| 9565 | if (!adapter) { |
| 9566 | hdd_err("Failed to open p2p interface"); |
| 9567 | return QDF_STATUS_E_INVAL; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9568 | } |
| 9569 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9570 | return QDF_STATUS_SUCCESS; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9571 | } |
| 9572 | #else |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9573 | static inline QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9574 | { |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9575 | return QDF_STATUS_SUCCESS; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9576 | } |
| 9577 | #endif |
| 9578 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9579 | static QDF_STATUS hdd_open_ocb_interface(struct hdd_context *hdd_ctx) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9580 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9581 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9582 | |
| 9583 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 9584 | wlan_hdd_get_intf_addr(hdd_ctx), |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9585 | NET_NAME_UNKNOWN, true); |
| 9586 | if (!adapter) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9587 | hdd_err("Failed to open 802.11p interface"); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9588 | return QDF_STATUS_E_INVAL; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9589 | } |
| 9590 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9591 | return QDF_STATUS_SUCCESS; |
| 9592 | } |
| 9593 | |
| 9594 | static QDF_STATUS hdd_open_concurrent_interface(struct hdd_context *hdd_ctx) |
| 9595 | { |
| 9596 | struct hdd_adapter *adapter; |
| 9597 | |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9598 | if (qdf_str_eq(hdd_ctx->config->enable_concurrent_sta, "")) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9599 | return QDF_STATUS_SUCCESS; |
| 9600 | |
| 9601 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9602 | hdd_ctx->config->enable_concurrent_sta, |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 9603 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9604 | NET_NAME_UNKNOWN, true); |
| 9605 | if (!adapter) { |
| 9606 | hdd_err("Failed to open concurrent station interface"); |
| 9607 | return QDF_STATUS_E_INVAL; |
| 9608 | } |
| 9609 | |
| 9610 | return QDF_STATUS_SUCCESS; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9611 | } |
| 9612 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9613 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9614 | * hdd_start_station_adapter()- Start the Station Adapter |
| 9615 | * @adapter: HDD adapter |
| 9616 | * |
| 9617 | * This function initializes the adapter for the station mode. |
| 9618 | * |
| 9619 | * Return: 0 on success or errno on failure. |
| 9620 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9621 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9622 | { |
| 9623 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9624 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9625 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9626 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9627 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9628 | hdd_err("session is already opened, %d", |
| 9629 | adapter->session_id); |
| 9630 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9631 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9632 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9633 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 9634 | if (ret) { |
| 9635 | hdd_err("failed to create vdev: %d", ret); |
| 9636 | return ret; |
| 9637 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9638 | status = hdd_init_station_mode(adapter); |
| 9639 | |
| 9640 | if (QDF_STATUS_SUCCESS != status) { |
| 9641 | hdd_err("Error Initializing station mode: %d", status); |
| 9642 | return qdf_status_to_os_return(status); |
| 9643 | } |
| 9644 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9645 | hdd_register_tx_flow_control(adapter, |
| 9646 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9647 | hdd_tx_resume_cb, |
| 9648 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9649 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9650 | hdd_exit(); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 9651 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9652 | return 0; |
| 9653 | } |
| 9654 | |
| 9655 | /** |
| 9656 | * hdd_start_ap_adapter()- Start AP Adapter |
| 9657 | * @adapter: HDD adapter |
| 9658 | * |
| 9659 | * This function initializes the adapter for the AP mode. |
| 9660 | * |
| 9661 | * Return: 0 on success errno on failure. |
| 9662 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9663 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9664 | { |
| 9665 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9666 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9667 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9668 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9669 | uint32_t fine_time_meas_cap = 0; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9670 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9671 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9672 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9673 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9674 | hdd_err("session is already opened, %d", |
| 9675 | adapter->session_id); |
| 9676 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9677 | } |
| 9678 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9679 | * In SSR case no need to create new sap context. |
| 9680 | * Otherwise create sap context first and then create |
| 9681 | * vdev as while creating the vdev, driver needs to |
| 9682 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9683 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9684 | if (adapter->session.ap.sap_context) { |
| 9685 | is_ssr = true; |
| 9686 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9687 | hdd_err("sap creation failed"); |
| 9688 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 9689 | } |
| 9690 | |
| 9691 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 9692 | adapter->session.ap.sap_context); |
| 9693 | if (ret) { |
| 9694 | hdd_err("failed to create vdev, status:%d", ret); |
| 9695 | hdd_sap_destroy_ctx(adapter); |
| 9696 | return ret; |
| 9697 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9698 | |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9699 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 9700 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 9701 | &fine_time_meas_cap); |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9702 | sme_cli_set_command(adapter->session_id, |
| 9703 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9704 | (bool)(fine_time_meas_cap & WMI_FW_AP_RTT_RESPR), |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9705 | VDEV_CMD); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9706 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9707 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9708 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9709 | |
| 9710 | if (QDF_STATUS_SUCCESS != status) { |
| 9711 | hdd_err("Error Initializing the AP mode: %d", status); |
| 9712 | return qdf_status_to_os_return(status); |
| 9713 | } |
| 9714 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9715 | hdd_register_tx_flow_control(adapter, |
| 9716 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9717 | hdd_softap_tx_resume_cb, |
| 9718 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9719 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9720 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9721 | return 0; |
| 9722 | } |
| 9723 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9724 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 9725 | /** |
| 9726 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9727 | * @cds_cfg: CDS Configuration |
| 9728 | * @hdd_ctx: Pointer to hdd context |
| 9729 | * |
| 9730 | * Return: none |
| 9731 | */ |
| 9732 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9733 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9734 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9735 | { |
| 9736 | cds_cfg->tx_flow_stop_queue_th = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9737 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9738 | cds_cfg->tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9739 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 9740 | /* configuration for DP RX Threads */ |
| 9741 | cds_cfg->enable_dp_rx_threads = hdd_ctx->enable_dp_rx_threads; |
| 9742 | cds_cfg->num_dp_rx_threads = hdd_ctx->config->num_dp_rx_threads; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9743 | } |
| 9744 | #else |
| 9745 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9746 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9747 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9748 | { |
| 9749 | } |
| 9750 | #endif |
| 9751 | |
| 9752 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 9753 | /** |
| 9754 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 9755 | * @cds_cfg: CDS Configuration |
| 9756 | * @hdd_ctx: Pointer to hdd context |
| 9757 | * |
| 9758 | * Return: none |
| 9759 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9760 | 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] | 9761 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9762 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 9763 | bool is_rate_limit_enabled; |
| 9764 | QDF_STATUS status; |
| 9765 | |
| 9766 | status = ucfg_fwol_get_is_rate_limit_enabled(hdd_ctx->psoc, |
| 9767 | &is_rate_limit_enabled); |
| 9768 | if (QDF_IS_STATUS_ERROR(status)) |
| 9769 | return; |
| 9770 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9771 | cds_cfg->ra_ratelimit_interval = |
| 9772 | hdd_ctx->config->RArateLimitInterval; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 9773 | cds_cfg->is_ra_ratelimit_enabled = is_rate_limit_enabled; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9774 | } |
| 9775 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9776 | 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] | 9777 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9778 | { |
| 9779 | } |
| 9780 | #endif |
| 9781 | |
| 9782 | /** |
| 9783 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9784 | * @hdd_ctx: HDD Context |
| 9785 | * |
| 9786 | * Return: 0 for Success, errno on failure |
| 9787 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9788 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9789 | { |
| 9790 | struct cds_config_info *cds_cfg; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9791 | int value; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9792 | uint8_t band_capability; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9793 | uint8_t ito_repeat_count; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9794 | bool crash_inject; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9795 | bool self_recovery; |
| 9796 | bool fw_timeout_crash; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9797 | QDF_STATUS status; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9798 | |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9799 | cds_cfg = qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9800 | if (!cds_cfg) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9801 | return -ENOMEM; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9802 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9803 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 9804 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 9805 | &cds_cfg->sta_maxlimod_dtim); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9806 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9807 | status = ucfg_mlme_get_crash_inject(hdd_ctx->psoc, &crash_inject); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9808 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9809 | hdd_err("Failed to get crash inject ini config"); |
| 9810 | goto exit; |
| 9811 | } |
| 9812 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9813 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 9814 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9815 | hdd_err("Failed to get self recovery ini config"); |
| 9816 | goto exit; |
| 9817 | } |
| 9818 | |
| 9819 | status = ucfg_mlme_get_fw_timeout_crash(hdd_ctx->psoc, |
| 9820 | &fw_timeout_crash); |
| 9821 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9822 | hdd_err("Failed to get fw timeout crash ini config"); |
| 9823 | goto exit; |
| 9824 | } |
| 9825 | |
| 9826 | status = ucfg_mlme_get_ito_repeat_count(hdd_ctx->psoc, |
| 9827 | &ito_repeat_count); |
| 9828 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9829 | hdd_err("Failed to get ITO repeat count ini config"); |
| 9830 | goto exit; |
| 9831 | } |
| 9832 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9833 | cds_cfg->force_target_assert_enabled = crash_inject; |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9834 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9835 | ucfg_mlme_get_sap_max_offload_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9836 | cds_cfg->ap_maxoffload_peers = value; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9837 | ucfg_mlme_get_sap_max_offload_reorder_buffs(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9838 | &value); |
| 9839 | cds_cfg->ap_maxoffload_reorderbuffs = value; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9840 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9841 | cds_cfg->reorder_offload = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9842 | cfg_get(hdd_ctx->psoc, CFG_DP_REORDER_OFFLOAD_SUPPORT); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9843 | |
| 9844 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9845 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9846 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 9847 | |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9848 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9849 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9850 | ucfg_mlme_get_sap_max_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9851 | cds_cfg->max_station = value; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9852 | 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] | 9853 | cds_cfg->max_msdus_per_rxinorderind = |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 9854 | cfg_get(hdd_ctx->psoc, CFG_DP_MAX_MSDUS_PER_RXIND); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9855 | cds_cfg->self_recovery_enabled = self_recovery; |
| 9856 | cds_cfg->fw_timeout_crash = fw_timeout_crash; |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 9857 | cds_cfg->active_uc_apf_mode = hdd_ctx->config->active_uc_apf_mode; |
| 9858 | cds_cfg->active_mc_bc_apf_mode = hdd_ctx->config->active_mc_bc_apf_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9859 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9860 | cds_cfg->ito_repeat_count = ito_repeat_count; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9861 | |
| 9862 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9863 | if (QDF_IS_STATUS_ERROR(status)) |
| 9864 | goto exit; |
| 9865 | |
| 9866 | cds_cfg->bandcapability = band_capability; |
Rachit Kankane | 0106e38 | 2018-05-16 18:59:28 +0530 | [diff] [blame] | 9867 | cds_cfg->num_vdevs = hdd_ctx->config->num_vdevs; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9868 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9869 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 9870 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9871 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9872 | cds_init_ini_config(cds_cfg); |
| 9873 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9874 | |
| 9875 | exit: |
| 9876 | qdf_mem_free(cds_cfg); |
| 9877 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9878 | } |
| 9879 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9880 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9881 | * hdd_update_user_config() - API to update user configuration |
| 9882 | * parameters to obj mgr which are used by multiple components |
| 9883 | * @hdd_ctx: HDD Context |
| 9884 | * |
| 9885 | * Return: 0 for Success, errno on failure |
| 9886 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9887 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9888 | { |
| 9889 | struct wlan_objmgr_psoc_user_config *user_config; |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9890 | bool skip_dfs_in_p2p_search = false; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9891 | uint8_t band_capability; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 9892 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9893 | QDF_STATUS status; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9894 | bool value = false; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9895 | |
| 9896 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9897 | if (QDF_IS_STATUS_ERROR(status)) |
| 9898 | return -EIO; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9899 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 9900 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 9901 | &dual_mac_feature); |
| 9902 | if (QDF_IS_STATUS_ERROR(status)) |
| 9903 | return -EIO; |
| 9904 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9905 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9906 | if (!user_config) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9907 | return -ENOMEM; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9908 | |
| 9909 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 9910 | user_config->dual_mac_feature_disable = dual_mac_feature; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9911 | user_config->indoor_channel_support = |
| 9912 | hdd_ctx->config->indoor_channel_support; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9913 | |
| 9914 | status = ucfg_mlme_is_11d_enabled(hdd_ctx->psoc, &value); |
| 9915 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9916 | hdd_err("Invalid 11d_enable flag"); |
| 9917 | user_config->is_11d_support_enabled = value; |
| 9918 | |
| 9919 | value = false; |
| 9920 | status = ucfg_mlme_is_11h_enabled(hdd_ctx->psoc, &value); |
| 9921 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9922 | hdd_err("Invalid 11h_enable flag"); |
| 9923 | user_config->is_11h_support_enabled = value; |
| 9924 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9925 | cfg_p2p_get_skip_dfs_channel_p2p_search(hdd_ctx->psoc, |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 9926 | &skip_dfs_in_p2p_search); |
| 9927 | 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] | 9928 | user_config->band_capability = band_capability; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9929 | wlan_objmgr_psoc_set_user_config(hdd_ctx->psoc, user_config); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9930 | |
| 9931 | qdf_mem_free(user_config); |
| 9932 | return 0; |
| 9933 | } |
| 9934 | |
| 9935 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9936 | * hdd_init_thermal_info - Initialize thermal level |
| 9937 | * @hdd_ctx: HDD context |
| 9938 | * |
| 9939 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9940 | * which would be called when a configured thermal threshold is hit. |
| 9941 | * |
| 9942 | * Return: 0 on success and errno on failure |
| 9943 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9944 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9945 | { |
| 9946 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9947 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9948 | mac_handle_t mac_handle; |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9949 | struct wlan_fwol_thermal_temp thermal_temp = {0}; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9950 | |
| 9951 | thermal_param.smeThermalMgmtEnabled = |
| 9952 | hdd_ctx->config->thermalMitigationEnable; |
| 9953 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 9954 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 9955 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 9956 | hdd_ctx->config->throttle_dutycycle_level0; |
| 9957 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 9958 | hdd_ctx->config->throttle_dutycycle_level1; |
| 9959 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 9960 | hdd_ctx->config->throttle_dutycycle_level2; |
| 9961 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 9962 | hdd_ctx->config->throttle_dutycycle_level3; |
| 9963 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9964 | status = ucfg_fwol_get_thermal_temp(hdd_ctx->psoc, &thermal_temp); |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9965 | if (QDF_IS_STATUS_ERROR(status)) |
| 9966 | return qdf_status_to_os_return(status); |
| 9967 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9968 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9969 | thermal_temp.thermal_temp_min_level0; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9970 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9971 | thermal_temp.thermal_temp_max_level0; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9972 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9973 | thermal_temp.thermal_temp_min_level1; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9974 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9975 | thermal_temp.thermal_temp_max_level1; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9976 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9977 | thermal_temp.thermal_temp_min_level2; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9978 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9979 | thermal_temp.thermal_temp_max_level2; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9980 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9981 | thermal_temp.thermal_temp_min_level3; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9982 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
Dundi Raviteja | 47ac709 | 2018-09-07 10:40:28 +0530 | [diff] [blame] | 9983 | thermal_temp.thermal_temp_max_level3; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9984 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9985 | mac_handle = hdd_ctx->mac_handle; |
| 9986 | status = sme_init_thermal_info(mac_handle, thermal_param); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9987 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9988 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9989 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9990 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9991 | sme_add_set_thermal_level_callback(mac_handle, |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9992 | hdd_set_thermal_level_cb); |
| 9993 | |
| 9994 | return 0; |
| 9995 | |
| 9996 | } |
| 9997 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9998 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9999 | /** |
| 10000 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 10001 | * |
| 10002 | * Hold RTNL lock |
| 10003 | * |
| 10004 | * Return: True if held and false otherwise |
| 10005 | */ |
| 10006 | static inline bool hdd_hold_rtnl_lock(void) |
| 10007 | { |
| 10008 | rtnl_lock(); |
| 10009 | return true; |
| 10010 | } |
| 10011 | |
| 10012 | /** |
| 10013 | * hdd_release_rtnl_lock - Release RTNL lock |
| 10014 | * |
| 10015 | * Release RTNL lock |
| 10016 | * |
| 10017 | * Return: None |
| 10018 | */ |
| 10019 | static inline void hdd_release_rtnl_lock(void) |
| 10020 | { |
| 10021 | rtnl_unlock(); |
| 10022 | } |
| 10023 | #else |
| 10024 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 10025 | static inline void hdd_release_rtnl_lock(void) { } |
| 10026 | #endif |
| 10027 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10028 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10029 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10030 | /* MAX iwpriv command support */ |
| 10031 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10032 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10033 | #define MAX_PKTLOG_SIZE 16 |
| 10034 | |
| 10035 | /** |
| 10036 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 10037 | * @hdd_ctx: hdd context |
| 10038 | * @set_value2: pktlog buffer size value |
| 10039 | * |
| 10040 | * |
| 10041 | * Return: 0 for success or error. |
| 10042 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10043 | 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] | 10044 | { |
| 10045 | struct sir_wifi_start_log start_log = { 0 }; |
| 10046 | QDF_STATUS status; |
| 10047 | |
| 10048 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10049 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 10050 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10051 | start_log.user_triggered = 1; |
| 10052 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10053 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10054 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10055 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10056 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10057 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10058 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10059 | return -EINVAL; |
| 10060 | } |
| 10061 | |
| 10062 | return 0; |
| 10063 | } |
| 10064 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10065 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10066 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 10067 | * @hdd_ctx: hdd context |
| 10068 | * |
| 10069 | * Return: 0 for success or error. |
| 10070 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10071 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10072 | { |
| 10073 | struct sir_wifi_start_log start_log; |
| 10074 | QDF_STATUS status; |
| 10075 | |
| 10076 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10077 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 10078 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10079 | start_log.user_triggered = 1; |
| 10080 | start_log.size = 0; |
| 10081 | start_log.is_pktlog_buff_clear = true; |
| 10082 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10083 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10084 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10085 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10086 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10087 | return -EINVAL; |
| 10088 | } |
| 10089 | |
| 10090 | return 0; |
| 10091 | } |
| 10092 | |
| 10093 | |
| 10094 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10095 | * hdd_process_pktlog_command() - process pktlog command |
| 10096 | * @hdd_ctx: hdd context |
| 10097 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10098 | * @set_value2: pktlog buffer size value |
| 10099 | * |
| 10100 | * This function process pktlog command. |
| 10101 | * set_value2 only matters when set_value is 3 (set buff size) |
| 10102 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10103 | * |
| 10104 | * Return: 0 for success or error. |
| 10105 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10106 | 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] | 10107 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10108 | { |
| 10109 | int ret; |
| 10110 | bool enable; |
| 10111 | uint8_t user_triggered = 0; |
| 10112 | |
| 10113 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10114 | if (0 != ret) |
| 10115 | return ret; |
| 10116 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10117 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10118 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10119 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10120 | hdd_err("invalid pktlog value %d", set_value); |
| 10121 | return -EINVAL; |
| 10122 | } |
| 10123 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10124 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 10125 | if (set_value2 <= 0) { |
| 10126 | hdd_err("invalid pktlog size %d", set_value2); |
| 10127 | return -EINVAL; |
| 10128 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 10129 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 10130 | return -EINVAL; |
| 10131 | } |
| 10132 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10133 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 10134 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10135 | } |
| 10136 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10137 | /* |
| 10138 | * set_value = 0 then disable packetlog |
| 10139 | * set_value = 1 enable packetlog forcefully |
| 10140 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 10141 | * enable packetlog with AUTO type. |
| 10142 | */ |
| 10143 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 10144 | true : false; |
| 10145 | |
| 10146 | if (1 == set_value) { |
| 10147 | enable = true; |
| 10148 | user_triggered = 1; |
| 10149 | } |
| 10150 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10151 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10152 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10153 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10154 | /** |
| 10155 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 10156 | * @hdd_ctx: HDD context |
| 10157 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10158 | * @user_triggered: triggered through iwpriv |
| 10159 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10160 | * |
| 10161 | * Return: 0 on success; error number otherwise |
| 10162 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10163 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10164 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10165 | { |
| 10166 | struct sir_wifi_start_log start_log; |
| 10167 | QDF_STATUS status; |
| 10168 | |
| 10169 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10170 | start_log.verbose_level = |
| 10171 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10172 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10173 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10174 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10175 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 10176 | /* |
| 10177 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 10178 | * commands. Host uses this flag to decide whether to send pktlog |
| 10179 | * disable command to fw without sending pktlog enable command |
| 10180 | * previously. For eg, If vendor sends pktlog disable command without |
| 10181 | * sending pktlog enable command, then host discards the packet |
| 10182 | * but for iwpriv command, host will send it to fw. |
| 10183 | */ |
| 10184 | start_log.is_iwpriv_command = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10185 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10186 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10187 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10188 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10189 | return -EINVAL; |
| 10190 | } |
| 10191 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10192 | if (enable == true) |
| 10193 | hdd_ctx->is_pktlog_enabled = 1; |
| 10194 | else |
| 10195 | hdd_ctx->is_pktlog_enabled = 0; |
| 10196 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10197 | return 0; |
| 10198 | } |
| 10199 | #endif /* REMOVE_PKT_LOG */ |
| 10200 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10201 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10202 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 10203 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10204 | * @dev: Device Pointer |
| 10205 | * @num: Number of Valid Mac address |
| 10206 | * |
| 10207 | * Return: Pointer to MAC address buffer |
| 10208 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10209 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 10210 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10211 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10212 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10213 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10214 | |
| 10215 | /** |
| 10216 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 10217 | * @hdd_ctx: HDD Context |
| 10218 | * @num: Number of random mac addresses needed |
| 10219 | * |
| 10220 | * Generate random addresses using bit manipulation on the base mac address |
| 10221 | * |
| 10222 | * Return: None |
| 10223 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10224 | 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] | 10225 | { |
| 10226 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 10227 | uint32_t iter; |
| 10228 | struct hdd_config *ini = hdd_ctx->config; |
| 10229 | uint8_t *buf = NULL; |
| 10230 | uint8_t macaddr_b3, tmp_br3; |
| 10231 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 10232 | |
| 10233 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 10234 | buf = ini->intfMacAddr[iter].bytes; |
| 10235 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 10236 | macaddr_b3 = buf[3]; |
| 10237 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 10238 | INTF_MACADDR_MASK; |
| 10239 | macaddr_b3 += tmp_br3; |
| 10240 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 10241 | buf[0] |= 0x02; |
| 10242 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10243 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10244 | } |
| 10245 | } |
| 10246 | |
| 10247 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10248 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10249 | * @hdd_ctx: HDD Context |
| 10250 | * |
| 10251 | * API to get mac addresses from platform driver and update the driver |
| 10252 | * structures and configure FW with the base mac address. |
| 10253 | * Return: int |
| 10254 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10255 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10256 | { |
| 10257 | uint32_t no_of_mac_addr, iter; |
| 10258 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 10259 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 10260 | uint8_t *addr, *buf; |
| 10261 | struct device *dev = hdd_ctx->parent_dev; |
| 10262 | struct hdd_config *ini = hdd_ctx->config; |
| 10263 | tSirMacAddr mac_addr; |
| 10264 | QDF_STATUS status; |
| 10265 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10266 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10267 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10268 | if (no_of_mac_addr == 0 || !addr) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10269 | return -EINVAL; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10270 | |
| 10271 | if (no_of_mac_addr > max_mac_addr) |
| 10272 | no_of_mac_addr = max_mac_addr; |
| 10273 | |
| 10274 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 10275 | |
| 10276 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 10277 | buf = ini->intfMacAddr[iter].bytes; |
| 10278 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10279 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10280 | } |
| 10281 | |
| 10282 | status = sme_set_custom_mac_addr(mac_addr); |
| 10283 | |
| 10284 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10285 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10286 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10287 | if (no_of_mac_addr < max_mac_addr) |
| 10288 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 10289 | no_of_mac_addr); |
| 10290 | return 0; |
| 10291 | } |
| 10292 | |
| 10293 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10294 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 10295 | * @hdd_ctx: HDD Context |
| 10296 | * |
| 10297 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 10298 | * will generate its own MAC and update it to FW. |
| 10299 | * |
| 10300 | * Return: 0 for success |
| 10301 | * Non-zero error code for failure |
| 10302 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10303 | 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] | 10304 | { |
| 10305 | tSirMacAddr customMacAddr; |
| 10306 | QDF_STATUS status; |
| 10307 | |
| 10308 | qdf_mem_copy(&customMacAddr, |
| 10309 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 10310 | sizeof(tSirMacAddr)); |
| 10311 | status = sme_set_custom_mac_addr(customMacAddr); |
| 10312 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10313 | return -EAGAIN; |
| 10314 | return 0; |
| 10315 | } |
| 10316 | |
| 10317 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10318 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 10319 | * @hdd_ctx: HDD Context |
| 10320 | * |
| 10321 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 10322 | * is provisioned with mac addresses, driver uses it, else it will use |
| 10323 | * wlan_mac.bin to update HW MAC addresses. |
| 10324 | * |
| 10325 | * Return: None |
| 10326 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10327 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10328 | { |
| 10329 | QDF_STATUS status; |
| 10330 | int ret; |
| 10331 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10332 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10333 | if (!ret) { |
| 10334 | hdd_info("using MAC address from platform driver"); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10335 | return; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10336 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10337 | |
| 10338 | status = hdd_update_mac_config(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10339 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 10340 | hdd_info("using MAC address from wlan_mac.bin"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10341 | return; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10342 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10343 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10344 | hdd_info("using default MAC address"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10345 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 10346 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10347 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10348 | if (ret) |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 10349 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10350 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10351 | } |
| 10352 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10353 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10354 | { |
| 10355 | int vdev_id = 0; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10356 | QDF_STATUS status; |
| 10357 | bool smart_chainmask_enabled; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10358 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10359 | int vpdev = PDEV_CMD; |
| 10360 | int ret; |
| 10361 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10362 | status = ucfg_get_smart_chainmask_enabled(hdd_ctx->psoc, |
| 10363 | &smart_chainmask_enabled); |
| 10364 | if (QDF_IS_STATUS_ERROR(status)) |
| 10365 | return -EINVAL; |
| 10366 | |
| 10367 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10368 | (int)smart_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10369 | if (ret) |
| 10370 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 10371 | |
| 10372 | return ret; |
| 10373 | } |
| 10374 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10375 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10376 | { |
| 10377 | int vdev_id = 0; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10378 | QDF_STATUS status; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10379 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10380 | bool alternative_chainmask_enabled; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10381 | int vpdev = PDEV_CMD; |
| 10382 | int ret; |
| 10383 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10384 | status = ucfg_get_alternative_chainmask_enabled( |
| 10385 | hdd_ctx->psoc, |
| 10386 | &alternative_chainmask_enabled); |
| 10387 | if (QDF_IS_STATUS_ERROR(status)) |
| 10388 | return -EINVAL; |
| 10389 | |
| 10390 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10391 | (int)alternative_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10392 | if (ret) |
| 10393 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 10394 | ret); |
| 10395 | |
| 10396 | return ret; |
| 10397 | } |
| 10398 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10399 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10400 | { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10401 | QDF_STATUS status; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10402 | int vdev_id = 0; |
| 10403 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10404 | bool value; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10405 | int vpdev = PDEV_CMD; |
| 10406 | int ret; |
| 10407 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10408 | status = ucfg_fwol_get_ani_enabled(hdd_ctx->psoc, &value); |
| 10409 | if (QDF_IS_STATUS_ERROR(status)) |
| 10410 | return -EINVAL; |
| 10411 | |
| 10412 | ret = sme_cli_set_command(vdev_id, param_id, (int)value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10413 | if (ret) |
| 10414 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 10415 | |
| 10416 | return ret; |
| 10417 | } |
| 10418 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 10419 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10420 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 10421 | * @hdd_ctx: HDD context |
| 10422 | * |
| 10423 | * Pre configurations to be done at lower layer before calling cds enable. |
| 10424 | * |
| 10425 | * Return: 0 on success and errno on failure. |
| 10426 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10427 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10428 | { |
| 10429 | int ret; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10430 | uint8_t val = 0; |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10431 | QDF_STATUS status; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10432 | uint32_t arp_ac_category; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10433 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10434 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10435 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Ajit Pal Singh | 5d26961 | 2018-04-19 16:29:12 +0530 | [diff] [blame] | 10436 | /* Register HL netdev flow control callback */ |
| 10437 | cdp_hl_fc_register(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10438 | |
| 10439 | /* |
| 10440 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 10441 | * The cfg download must occur before we update the SME config |
| 10442 | * since the SME config operation must access the cfg database |
| 10443 | */ |
| 10444 | status = hdd_set_sme_config(hdd_ctx); |
| 10445 | |
| 10446 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10447 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10448 | ret = qdf_status_to_os_return(status); |
| 10449 | goto out; |
| 10450 | } |
| 10451 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 10452 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 10453 | if (QDF_STATUS_SUCCESS != status) { |
| 10454 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 10455 | ret = qdf_status_to_os_return(status); |
| 10456 | goto out; |
| 10457 | } |
| 10458 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10459 | status = ucfg_mlme_get_tx_chainmask_1ss(hdd_ctx->psoc, &val); |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10460 | if (QDF_STATUS_SUCCESS != status) { |
| 10461 | hdd_err("Get tx_chainmask_1ss from mlme failed"); |
| 10462 | ret = qdf_status_to_os_return(status); |
| 10463 | goto out; |
| 10464 | } |
| 10465 | 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] | 10466 | PDEV_CMD); |
| 10467 | if (0 != ret) { |
| 10468 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 10469 | goto out; |
| 10470 | } |
| 10471 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10472 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 10473 | if (ret) |
| 10474 | goto out; |
| 10475 | |
| 10476 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 10477 | if (ret) |
| 10478 | goto out; |
| 10479 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10480 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 10481 | if (ret) |
| 10482 | goto out; |
| 10483 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10484 | status = ucfg_get_arp_ac_category(hdd_ctx->psoc, &arp_ac_category); |
| 10485 | |
| 10486 | if (QDF_IS_STATUS_ERROR(status)) |
| 10487 | return -EINVAL; |
| 10488 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10489 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10490 | arp_ac_category, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10491 | PDEV_CMD); |
| 10492 | if (0 != ret) { |
| 10493 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10494 | arp_ac_category, ret); |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10495 | goto out; |
| 10496 | } |
| 10497 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10498 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 10499 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10500 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10501 | ret = qdf_status_to_os_return(status); |
| 10502 | goto out; |
| 10503 | } |
| 10504 | |
| 10505 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 10506 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10507 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10508 | ret = -EINVAL; |
| 10509 | goto out; |
| 10510 | } |
| 10511 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10512 | /* |
| 10513 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 10514 | * Remove this once self sta is added as part of session open. |
| 10515 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10516 | status = sme_cfg_set_str(hdd_ctx->mac_handle, WNI_CFG_STA_ID, |
Jeff Johnson | bae59f9 | 2018-06-01 17:05:43 -0700 | [diff] [blame] | 10517 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 10518 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10519 | |
Jeff Johnson | bae59f9 | 2018-06-01 17:05:43 -0700 | [diff] [blame] | 10520 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10521 | hdd_err("Failed to set MAC Address, status %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10522 | ret = -EINVAL; |
| 10523 | goto out; |
| 10524 | } |
| 10525 | |
| 10526 | hdd_init_channel_avoidance(hdd_ctx); |
| 10527 | |
| 10528 | out: |
| 10529 | return ret; |
| 10530 | } |
| 10531 | |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10532 | #ifdef FEATURE_P2P_LISTEN_OFFLOAD |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10533 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10534 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10535 | * @context: context registered with sme_register_p2p_lo_event(). HDD |
| 10536 | * always registers a hdd context pointer |
| 10537 | * @evt:event structure pointer |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10538 | * |
| 10539 | * This is the p2p listen offload stop event handler, it sends vendor |
| 10540 | * event back to supplicant to notify the stop reason. |
| 10541 | * |
| 10542 | * Return: None |
| 10543 | */ |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10544 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10545 | struct sir_p2p_lo_event *evt) |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10546 | { |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10547 | struct hdd_context *hdd_ctx = context; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10548 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10549 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10550 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10551 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10552 | |
| 10553 | if (hdd_ctx == NULL) { |
| 10554 | hdd_err("Invalid HDD context pointer"); |
| 10555 | return; |
| 10556 | } |
| 10557 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10558 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 10559 | if (!adapter) { |
| 10560 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 10561 | evt->vdev_id); |
| 10562 | return; |
| 10563 | } |
| 10564 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10565 | vendor_event = |
| 10566 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10567 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10568 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 10569 | GFP_KERNEL); |
| 10570 | |
| 10571 | if (!vendor_event) { |
| 10572 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 10573 | return; |
| 10574 | } |
| 10575 | |
| 10576 | if (nla_put_u32(vendor_event, |
| 10577 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 10578 | evt->reason_code)) { |
| 10579 | hdd_err("nla put failed"); |
| 10580 | kfree_skb(vendor_event); |
| 10581 | return; |
| 10582 | } |
| 10583 | |
| 10584 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10585 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 10586 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10587 | } |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10588 | #else |
| 10589 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10590 | struct sir_p2p_lo_event *evt) |
| 10591 | { |
| 10592 | } |
| 10593 | #endif |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10594 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10595 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 10596 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10597 | { |
| 10598 | return sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap); |
| 10599 | } |
| 10600 | #else |
| 10601 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10602 | { |
| 10603 | return QDF_STATUS_SUCCESS; |
| 10604 | } |
| 10605 | #endif |
| 10606 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10607 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10608 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 10609 | * @hdd_ctx: HDD context |
| 10610 | * |
| 10611 | * This function sends the adaptive dwell time config configuration to the |
| 10612 | * firmware via WMA |
| 10613 | * |
| 10614 | * Return: 0 - success, < 0 - failure |
| 10615 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10616 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10617 | { |
| 10618 | QDF_STATUS status; |
| 10619 | struct adaptive_dwelltime_params dwelltime_params; |
| 10620 | |
| 10621 | dwelltime_params.is_enabled = |
| 10622 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 10623 | dwelltime_params.dwelltime_mode = |
| 10624 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 10625 | dwelltime_params.lpf_weight = |
| 10626 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 10627 | dwelltime_params.passive_mon_intval = |
| 10628 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 10629 | dwelltime_params.wifi_act_threshold = |
| 10630 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 10631 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10632 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->mac_handle, |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10633 | &dwelltime_params); |
| 10634 | |
| 10635 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 10636 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10637 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 10638 | return -EAGAIN; |
| 10639 | } |
| 10640 | return 0; |
| 10641 | } |
| 10642 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10643 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10644 | { |
| 10645 | QDF_STATUS status; |
| 10646 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 10647 | uint32_t i = 0; |
| 10648 | uint8_t count = 0, numentries = 0; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10649 | uint8_t dual_mac_feature; |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10650 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10651 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 10652 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10653 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 10654 | &dual_mac_feature); |
| 10655 | |
| 10656 | if (status != QDF_STATUS_SUCCESS) { |
| 10657 | hdd_err("can't get dual mac feature flag"); |
| 10658 | return -EINVAL; |
| 10659 | } |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10660 | /* check if DBS is enabled or supported */ |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10661 | if ((dual_mac_feature == DISABLE_DBS_CXN_AND_SCAN) || |
| 10662 | (dual_mac_feature == ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10663 | return -EINVAL; |
| 10664 | |
| 10665 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 10666 | dbs_scan_config, &numentries, |
| 10667 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10668 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 10669 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10670 | if (!numentries) { |
Dustin Brown | 6a8d39b | 2018-08-14 15:27:26 -0700 | [diff] [blame] | 10671 | hdd_debug("Do not send scan_selection_config"); |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10672 | return 0; |
| 10673 | } |
| 10674 | |
| 10675 | /* hdd_set_fw_log_params */ |
| 10676 | dbs_scan_params.num_clients = 0; |
| 10677 | while (count < (numentries - 2)) { |
| 10678 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 10679 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 10680 | dbs_scan_params.num_non_dbs_scans[i] = |
| 10681 | dbs_scan_config[count + 2]; |
| 10682 | dbs_scan_params.num_clients++; |
| 10683 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 10684 | dbs_scan_params.module_id[i], |
| 10685 | dbs_scan_params.num_dbs_scans[i], |
| 10686 | dbs_scan_params.num_non_dbs_scans[i]); |
| 10687 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 10688 | i++; |
| 10689 | } |
| 10690 | |
| 10691 | dbs_scan_params.pdev_id = 0; |
| 10692 | |
| 10693 | hdd_debug("clients:%d pdev:%d", |
| 10694 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 10695 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10696 | status = sme_set_dbs_scan_selection_config(hdd_ctx->mac_handle, |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10697 | &dbs_scan_params); |
| 10698 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 10699 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10700 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 10701 | return -EAGAIN; |
| 10702 | } |
| 10703 | return 0; |
| 10704 | } |
| 10705 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10706 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10707 | /** |
| 10708 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 10709 | * @hdd_ctx: HDD context |
| 10710 | * |
| 10711 | * Set auto shutdown callback to get indications from firmware to indicate |
| 10712 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 10713 | * |
| 10714 | * Return: 0 on success and errno on failure. |
| 10715 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10716 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10717 | { |
| 10718 | QDF_STATUS status; |
| 10719 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 10720 | if (!hdd_ctx->config->wlan_auto_shutdown) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10721 | return 0; |
| 10722 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10723 | status = sme_set_auto_shutdown_cb(hdd_ctx->mac_handle, |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10724 | wlan_hdd_auto_shutdown_cb); |
| 10725 | if (status != QDF_STATUS_SUCCESS) |
| 10726 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 10727 | status); |
| 10728 | |
| 10729 | return qdf_status_to_os_return(status); |
| 10730 | } |
| 10731 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10732 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10733 | { |
| 10734 | return 0; |
| 10735 | } |
| 10736 | #endif |
| 10737 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10738 | #ifdef MWS_COEX |
| 10739 | /** |
| 10740 | * hdd_set_mws_coex() - Set MWS coex configurations |
| 10741 | * @hdd_ctx: HDD context |
| 10742 | * |
| 10743 | * This function sends MWS-COEX 4G quick FTDM and |
| 10744 | * MWS-COEX 5G-NR power limit to FW |
| 10745 | * |
| 10746 | * Return: 0 on success and errno on failure. |
| 10747 | */ |
| 10748 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10749 | { |
| 10750 | int ret = 0; |
| 10751 | |
| 10752 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_MWSCOEX_4G_ALLOW_QUICK_FTDM, |
| 10753 | hdd_ctx->config->mws_coex_4g_quick_tdm, |
| 10754 | PDEV_CMD); |
| 10755 | if (ret) { |
| 10756 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10757 | return ret; |
| 10758 | } |
| 10759 | |
| 10760 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_MWSCOEX_SET_5GNR_PWR_LIMIT, |
| 10761 | hdd_ctx->config->mws_coex_5g_nr_pwr_limit, |
| 10762 | PDEV_CMD); |
| 10763 | if (ret) { |
| 10764 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10765 | return ret; |
| 10766 | } |
| 10767 | return ret; |
| 10768 | } |
| 10769 | #else |
| 10770 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10771 | { |
| 10772 | return 0; |
| 10773 | } |
| 10774 | #endif |
| 10775 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10776 | /** |
| 10777 | * hdd_features_init() - Init features |
| 10778 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10779 | * |
| 10780 | * Initialize features and their feature context after WLAN firmware is up. |
| 10781 | * |
| 10782 | * Return: 0 on success and errno on failure. |
| 10783 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10784 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10785 | { |
| 10786 | tSirTxPowerLimit hddtxlimit; |
| 10787 | QDF_STATUS status; |
| 10788 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10789 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10790 | struct hdd_config *cfg; |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 10791 | bool b_cts2self; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10792 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10793 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10794 | |
Dustin Brown | ad698ae | 2018-09-05 17:19:30 -0700 | [diff] [blame] | 10795 | ret = hdd_update_country_code(hdd_ctx); |
| 10796 | if (ret) { |
| 10797 | hdd_err("Failed to update country code; errno:%d", ret); |
| 10798 | return -EINVAL; |
| 10799 | } |
| 10800 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10801 | ret = hdd_init_mws_coex(hdd_ctx); |
| 10802 | if (ret) |
| 10803 | hdd_warn("Error initializing mws-coex"); |
| 10804 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10805 | cfg = hdd_ctx->config; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10806 | /* FW capabilities received, Set the Dot11 mode */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10807 | mac_handle = hdd_ctx->mac_handle; |
| 10808 | sme_setdef_dot11mode(mac_handle); |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10809 | sme_set_etsi13_srd_ch_in_master_mode(mac_handle, |
| 10810 | cfg-> |
| 10811 | etsi13_srd_chan_in_master_mode); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10812 | |
| 10813 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10814 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 10815 | else |
| 10816 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 10817 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10818 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10819 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 10820 | cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 10821 | cfg_dp_enable_data_stall), PDEV_CMD); |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10822 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10823 | ucfg_mlme_get_go_cts2self_for_sta(hdd_ctx->psoc, &b_cts2self); |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 10824 | if (b_cts2self) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10825 | sme_set_cts2self_for_p2p_go(mac_handle); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10826 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10827 | if (hdd_set_vc_mode_config(hdd_ctx)) |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10828 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10829 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10830 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10831 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10832 | |
| 10833 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10834 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10835 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10836 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10837 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10838 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10839 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10840 | if (ret) { |
| 10841 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10842 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10843 | } |
| 10844 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10845 | /** |
| 10846 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 10847 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 10848 | * device up. |
| 10849 | */ |
| 10850 | if (cds_is_driver_recovering()) { |
| 10851 | if (hdd_ctx->is_pktlog_enabled) |
| 10852 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Alok Kumar | 5a75b9d | 2018-08-31 10:55:43 +0530 | [diff] [blame] | 10853 | } else if (cds_is_packet_log_enabled()) |
| 10854 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10855 | |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 10856 | hddtxlimit.txPower2g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_2G); |
| 10857 | hddtxlimit.txPower5g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_5G); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10858 | status = sme_txpower_limit(mac_handle, &hddtxlimit); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10859 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10860 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10861 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10862 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10863 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 10864 | status = sme_enable_disable_chanavoidind_event(mac_handle, 0); |
| 10865 | if (QDF_IS_STATUS_ERROR(status) && (status != QDF_STATUS_E_NOSUPPORT)) { |
| 10866 | hdd_err("Failed to disable Chan Avoidance Indication"); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10867 | return -EINVAL; |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10868 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10869 | |
| 10870 | /* register P2P Listen Offload event callback */ |
| 10871 | if (wma_is_p2p_lo_capable()) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10872 | sme_register_p2p_lo_event(mac_handle, hdd_ctx, |
| 10873 | wlan_hdd_p2p_lo_event_callback); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10874 | |
| 10875 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10876 | |
| 10877 | if (ret) |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10878 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10879 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10880 | wlan_hdd_init_chan_info(hdd_ctx); |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10881 | wlan_hdd_twt_init(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10882 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10883 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10884 | return 0; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10885 | } |
| 10886 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10887 | /** |
| 10888 | * hdd_features_deinit() - Deinit features |
| 10889 | * @hdd_ctx: HDD context |
| 10890 | * |
| 10891 | * De-Initialize features and their feature context. |
| 10892 | * |
| 10893 | * Return: none. |
| 10894 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10895 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10896 | { |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10897 | wlan_hdd_twt_deinit(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10898 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10899 | wlan_hdd_tsf_deinit(hdd_ctx); |
jitiphil | 4e3bef4 | 2018-11-14 14:31:13 +0530 | [diff] [blame] | 10900 | if (cds_is_packet_log_enabled()) |
| 10901 | hdd_pktlog_enable_disable(hdd_ctx, false, 0, 0); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10902 | } |
| 10903 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10904 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10905 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10906 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10907 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10908 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10909 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10910 | 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] | 10911 | { |
| 10912 | QDF_STATUS status; |
| 10913 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10914 | status = ucfg_scan_register_bcn_cb(hdd_ctx->psoc, |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10915 | wlan_cfg80211_inform_bss_frame, |
| 10916 | SCAN_CB_TYPE_INFORM_BCN); |
| 10917 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10918 | hdd_err("failed with status code %08d [x%08x]", |
| 10919 | status, status); |
| 10920 | return status; |
| 10921 | } |
| 10922 | |
| 10923 | return QDF_STATUS_SUCCESS; |
| 10924 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10925 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10926 | /** |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 10927 | * hdd_v2_flow_pool_map() - Flow pool create callback when vdev is active |
| 10928 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10929 | * |
| 10930 | * Return: none. |
| 10931 | */ |
| 10932 | static void hdd_v2_flow_pool_map(int vdev_id) |
| 10933 | { |
| 10934 | QDF_STATUS status; |
| 10935 | |
| 10936 | status = cdp_flow_pool_map(cds_get_context(QDF_MODULE_ID_SOC), |
| 10937 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 10938 | vdev_id); |
| 10939 | /* |
| 10940 | * For Adrastea flow control v2 is based on FW MAP events, |
| 10941 | * so this above callback is not implemented. |
| 10942 | * Hence this is not actual failure. Dont return failure |
| 10943 | */ |
| 10944 | if ((status != QDF_STATUS_SUCCESS) && |
| 10945 | (status != QDF_STATUS_E_INVAL)) { |
| 10946 | hdd_err("vdev_id: %d, failed to create flow pool status %d", |
| 10947 | vdev_id, status); |
| 10948 | } |
| 10949 | } |
| 10950 | |
| 10951 | /** |
| 10952 | * hdd_v2_flow_pool_unmap() - Flow pool create callback when vdev is not active |
| 10953 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10954 | * |
| 10955 | * Return: none. |
| 10956 | */ |
| 10957 | static void hdd_v2_flow_pool_unmap(int vdev_id) |
| 10958 | { |
| 10959 | cdp_flow_pool_unmap(cds_get_context(QDF_MODULE_ID_SOC), |
| 10960 | cds_get_context(QDF_MODULE_ID_TXRX), vdev_id); |
| 10961 | } |
| 10962 | |
| 10963 | /** |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10964 | * hdd_action_oui_config() - Configure action_oui strings |
| 10965 | * @hdd_ctx: pointer to hdd context |
| 10966 | * |
| 10967 | * This is a HDD wrapper function which invokes ucfg api |
| 10968 | * of action_oui component to parse action oui strings. |
| 10969 | * |
| 10970 | * Return: None |
| 10971 | */ |
| 10972 | static void hdd_action_oui_config(struct hdd_context *hdd_ctx) |
| 10973 | { |
| 10974 | QDF_STATUS status; |
| 10975 | uint32_t id; |
| 10976 | uint8_t *str; |
| 10977 | |
| 10978 | if (!hdd_ctx->config->action_oui_enable) |
| 10979 | return; |
| 10980 | |
| 10981 | for (id = 0; id < ACTION_OUI_MAXIMUM_ID; id++) { |
| 10982 | str = hdd_ctx->config->action_oui_str[id]; |
| 10983 | if (!qdf_str_len(str)) |
| 10984 | continue; |
| 10985 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10986 | status = ucfg_action_oui_parse(hdd_ctx->psoc, str, id); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 10987 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10988 | hdd_err("Failed to parse action_oui str: %u", id); |
| 10989 | } |
| 10990 | } |
| 10991 | |
| 10992 | /** |
| 10993 | * hdd_action_oui_send() - Send action_oui extensions to firmware |
| 10994 | * @hdd_ctx: pointer to hdd context |
| 10995 | * |
| 10996 | * This is a HDD wrapper function which invokes ucfg api |
| 10997 | * of action_oui component to send action oui extensions to firmware. |
| 10998 | * |
| 10999 | * Return: None |
| 11000 | */ |
| 11001 | static void hdd_action_oui_send(struct hdd_context *hdd_ctx) |
| 11002 | { |
| 11003 | QDF_STATUS status; |
| 11004 | |
| 11005 | if (!hdd_ctx->config->action_oui_enable) |
| 11006 | return; |
| 11007 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11008 | status = ucfg_action_oui_send(hdd_ctx->psoc); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11009 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11010 | hdd_err("Failed to send one or all action_ouis"); |
| 11011 | } |
| 11012 | |
| 11013 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11014 | * hdd_configure_cds() - Configure cds modules |
| 11015 | * @hdd_ctx: HDD context |
| 11016 | * @adapter: Primary adapter context |
| 11017 | * |
| 11018 | * Enable Cds modules after WLAN firmware is up. |
| 11019 | * |
| 11020 | * Return: 0 on success and errno on failure. |
| 11021 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11022 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11023 | { |
| 11024 | int ret; |
| 11025 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11026 | int set_value; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11027 | mac_handle_t mac_handle; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11028 | bool enable_rts_sifsbursting; |
| 11029 | uint8_t enable_phy_reg_retention; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11030 | uint8_t max_mpdus_inampdu, is_force_1x1 = 0; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11031 | uint32_t num_abg_tx_chains = 0; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11032 | uint16_t num_11b_tx_chains = 0; |
| 11033 | uint16_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 11034 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11035 | bool value; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11036 | enum pmo_auto_pwr_detect_failure_mode auto_power_fail_mode; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11037 | bool bval = false; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11038 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11039 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11040 | |
| 11041 | hdd_action_oui_send(hdd_ctx); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11042 | status = ucfg_policy_mgr_get_force_1x1(hdd_ctx->psoc, &is_force_1x1); |
| 11043 | if (status != QDF_STATUS_SUCCESS) { |
| 11044 | hdd_err("Failed to get force 1x1 value"); |
| 11045 | goto out; |
| 11046 | } |
| 11047 | if (is_force_1x1) |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11048 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 11049 | 1, PDEV_CMD); |
| 11050 | /* set chip power save failure detected callback */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11051 | sme_set_chip_pwr_save_fail_cb(mac_handle, |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11052 | hdd_chip_pwr_save_fail_detected_cb); |
| 11053 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11054 | status = ucfg_get_max_mpdus_inampdu(hdd_ctx->psoc, |
| 11055 | &max_mpdus_inampdu); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11056 | if (status) { |
| 11057 | hdd_err("Failed to get max mpdus in ampdu value"); |
| 11058 | goto out; |
| 11059 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11060 | |
| 11061 | if (max_mpdus_inampdu) { |
| 11062 | set_value = max_mpdus_inampdu; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11063 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 11064 | set_value, PDEV_CMD); |
| 11065 | } |
| 11066 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11067 | status = ucfg_get_enable_rts_sifsbursting(hdd_ctx->psoc, |
| 11068 | &enable_rts_sifsbursting); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11069 | if (status) { |
| 11070 | hdd_err("Failed to get rts sifs bursting value"); |
| 11071 | goto out; |
| 11072 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11073 | |
| 11074 | if (enable_rts_sifsbursting) { |
| 11075 | set_value = enable_rts_sifsbursting; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11076 | sme_cli_set_command(0, |
| 11077 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 11078 | set_value, PDEV_CMD); |
| 11079 | } |
| 11080 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 11081 | ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11082 | if (value) { |
| 11083 | set_value = value; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11084 | sme_cli_set_command(0, |
| 11085 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 11086 | set_value, PDEV_CMD); |
| 11087 | } |
| 11088 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11089 | status = ucfg_mlme_get_num_11b_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11090 | &num_11b_tx_chains); |
| 11091 | if (status != QDF_STATUS_SUCCESS) { |
| 11092 | hdd_err("Failed to get num_11b_tx_chains"); |
| 11093 | goto out; |
| 11094 | } |
| 11095 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11096 | status = ucfg_mlme_get_num_11ag_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11097 | &num_11ag_tx_chains); |
| 11098 | if (status != QDF_STATUS_SUCCESS) { |
| 11099 | hdd_err("Failed to get num_11ag_tx_chains"); |
| 11100 | goto out; |
| 11101 | } |
| 11102 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11103 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 11104 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11105 | hdd_err("unable to get vht_enable2x2"); |
| 11106 | |
| 11107 | if (!bval) { |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11108 | if (num_11b_tx_chains > 1) |
| 11109 | num_11b_tx_chains = 1; |
| 11110 | if (num_11ag_tx_chains > 1) |
| 11111 | num_11ag_tx_chains = 1; |
| 11112 | } |
| 11113 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11114 | num_11b_tx_chains); |
| 11115 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11116 | num_11ag_tx_chains); |
| 11117 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 11118 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11119 | |
Paul Zhang | 02526cd | 2018-09-20 17:47:46 +0800 | [diff] [blame] | 11120 | if (!ucfg_reg_is_regdb_offloaded(hdd_ctx->psoc)) |
| 11121 | ucfg_reg_program_default_cc(hdd_ctx->pdev, |
| 11122 | hdd_ctx->reg.reg_domain); |
| 11123 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11124 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 11125 | if (ret) { |
| 11126 | hdd_err("Failed to pre-configure cds"); |
| 11127 | goto out; |
| 11128 | } |
| 11129 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11130 | /* Always get latest IPA resources allocated from cds_open and configure |
| 11131 | * IPA module before configuring them to FW. Sequence required as crash |
| 11132 | * observed otherwise. |
| 11133 | */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11134 | if (ucfg_ipa_uc_ol_init(hdd_ctx->pdev, |
| 11135 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 11136 | hdd_err("Failed to setup pipes"); |
| 11137 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11138 | } |
| 11139 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11140 | /* |
| 11141 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 11142 | * else |
| 11143 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11144 | status = cds_enable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11145 | |
| 11146 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11147 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11148 | goto out; |
| 11149 | } |
| 11150 | |
| 11151 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 11152 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11153 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11154 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11155 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11156 | status = hdd_register_bcn_cb(hdd_ctx); |
| 11157 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 11158 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11159 | goto cds_disable; |
| 11160 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11161 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11162 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11163 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11164 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11165 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 11166 | if (hdd_ctx->ol_enable) |
| 11167 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 11168 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11169 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 11170 | 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] | 11171 | dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; |
| 11172 | dp_cbs.hdd_v2_flow_pool_unmap = hdd_v2_flow_pool_unmap; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11173 | status = policy_mgr_register_dp_cb(hdd_ctx->psoc, &dp_cbs); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11174 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11175 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11176 | goto cds_disable; |
| 11177 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11178 | status = policy_mgr_register_mode_change_cb(hdd_ctx->psoc, |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11179 | wlan_hdd_send_mode_change_event); |
| 11180 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 11181 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 11182 | goto cds_disable; |
| 11183 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11184 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 11185 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 11186 | hdd_debug("enhance green ap is not enabled"); |
| 11187 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 11188 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 11189 | hdd_debug("Failed to set wow pulse"); |
| 11190 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 11191 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
| 11192 | hdd_ctx->config->gcmp_enabled, PDEV_CMD); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11193 | |
| 11194 | auto_power_fail_mode = |
| 11195 | ucfg_pmo_get_auto_power_fail_mode(hdd_ctx->psoc); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11196 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11197 | auto_power_fail_mode, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11198 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11199 | status = ucfg_get_enable_phy_reg_retention(hdd_ctx->psoc, |
| 11200 | &enable_phy_reg_retention); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11201 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11202 | if (QDF_IS_STATUS_ERROR(status)) |
| 11203 | return -EINVAL; |
| 11204 | |
| 11205 | if (enable_phy_reg_retention) |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11206 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11207 | enable_phy_reg_retention, PDEV_CMD); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11208 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11209 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11210 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11211 | cds_disable: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11212 | cds_disable(hdd_ctx->psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11213 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11214 | out: |
| 11215 | return -EINVAL; |
| 11216 | } |
| 11217 | |
| 11218 | /** |
| 11219 | * hdd_deconfigure_cds() -De-Configure cds |
| 11220 | * @hdd_ctx: HDD context |
| 11221 | * |
| 11222 | * Deconfigure Cds modules before WLAN firmware is down. |
| 11223 | * |
| 11224 | * Return: 0 on success and errno on failure. |
| 11225 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11226 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11227 | { |
| 11228 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11229 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11230 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11231 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 11232 | |
| 11233 | /* De-init features */ |
| 11234 | hdd_features_deinit(hdd_ctx); |
| 11235 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11236 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->psoc); |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 11237 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11238 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11239 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11240 | qdf_status = cds_disable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11241 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11242 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 11243 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11244 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11245 | } |
| 11246 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11247 | 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] | 11248 | hdd_err("Failed to disconnect pipes"); |
| 11249 | ret = -EINVAL; |
| 11250 | } |
| 11251 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11252 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11253 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11254 | } |
| 11255 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11256 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 11257 | static void hdd_deregister_policy_manager_callback( |
| 11258 | struct wlan_objmgr_psoc *psoc) |
| 11259 | { |
| 11260 | if (QDF_STATUS_SUCCESS != |
| 11261 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 11262 | hdd_err("HDD callback deregister with policy manager failed"); |
| 11263 | } |
| 11264 | } |
| 11265 | #else |
| 11266 | static void hdd_deregister_policy_manager_callback( |
| 11267 | struct wlan_objmgr_psoc *psoc) |
| 11268 | { |
| 11269 | } |
| 11270 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11271 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11272 | 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] | 11273 | { |
| 11274 | void *hif_ctx; |
| 11275 | qdf_device_t qdf_ctx; |
| 11276 | QDF_STATUS qdf_status; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11277 | bool is_recovery_stop = cds_is_driver_recovering(); |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11278 | int ret = 0; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11279 | int active_threads; |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11280 | int debugfs_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11281 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11282 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11283 | hdd_enter(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11284 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11285 | hdd_deregister_policy_manager_callback(hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11286 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11287 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11288 | if (!qdf_ctx) { |
| 11289 | hdd_err("QDF device context NULL"); |
| 11290 | return -EINVAL; |
| 11291 | } |
| 11292 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11293 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 11294 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11295 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11296 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11297 | active_threads = cds_return_external_threads_count(); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11298 | debugfs_threads = hdd_return_debugfs_threads_count(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11299 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11300 | if (active_threads > 0 || debugfs_threads > 0 || |
| 11301 | hdd_ctx->is_wiphy_suspended) { |
| 11302 | hdd_warn("External threads %d, Debugfs threads %d, wiphy suspend %d", |
| 11303 | active_threads, debugfs_threads, |
| 11304 | hdd_ctx->is_wiphy_suspended); |
| 11305 | |
| 11306 | if (active_threads) |
| 11307 | cds_print_external_threads(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11308 | |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11309 | if (IS_IDLE_STOP && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11310 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 11311 | hdd_psoc_idle_timer_start(hdd_ctx); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11312 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11313 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11314 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11315 | return 0; |
| 11316 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 11317 | } |
| 11318 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 11319 | /* free user wowl patterns */ |
| 11320 | hdd_free_user_wowl_ptrns(); |
| 11321 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11322 | switch (hdd_ctx->driver_status) { |
| 11323 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11324 | hdd_debug("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11325 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11326 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11327 | hdd_debug("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11328 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11329 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 11330 | hdd_info("Wlan transitioning (CLOSED <- ENABLED)"); |
| 11331 | |
| 11332 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) |
| 11333 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11334 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 11335 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11336 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11337 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11338 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11339 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11340 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11341 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11342 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11343 | break; |
| 11344 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11345 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11346 | hdd_ctx->driver_status); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11347 | ret = -EINVAL; |
| 11348 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11349 | } |
| 11350 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11351 | hdd_sysfs_destroy_powerstats_interface(); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11352 | hdd_sysfs_destroy_version_interface(); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11353 | hdd_sysfs_destroy_driver_root_obj(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11354 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11355 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 11356 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 11357 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11358 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 11359 | qdf_status); |
| 11360 | ret = -EINVAL; |
| 11361 | QDF_ASSERT(0); |
| 11362 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11363 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 11364 | /* De-register the SME callbacks */ |
| 11365 | hdd_deregister_cb(hdd_ctx); |
| 11366 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 11367 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 11368 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11369 | qdf_status = cds_dp_close(hdd_ctx->psoc); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11370 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11371 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 11372 | ret = -EINVAL; |
| 11373 | QDF_ASSERT(0); |
| 11374 | } |
| 11375 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11376 | qdf_status = cds_close(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11377 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11378 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 11379 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11380 | QDF_ASSERT(0); |
| 11381 | } |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11382 | |
| 11383 | qdf_status = wbuff_module_deinit(); |
| 11384 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 11385 | hdd_err("WBUFF de-init unsuccessful; status: %d", qdf_status); |
| 11386 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 11387 | hdd_component_pdev_close(hdd_ctx->pdev); |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11388 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11389 | hdd_component_psoc_close(hdd_ctx->psoc); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11390 | dispatcher_pdev_close(hdd_ctx->pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11391 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 11392 | if (ret) { |
| 11393 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 11394 | QDF_ASSERT(0); |
| 11395 | } |
| 11396 | |
| 11397 | /* |
| 11398 | * Reset total mac phy during module stop such that during |
| 11399 | * next module start same psoc is used to populate new service |
| 11400 | * ready data |
| 11401 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11402 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11403 | if (tgt_hdl) |
| 11404 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 11405 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11406 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11407 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 11408 | if (!hif_ctx) { |
| 11409 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11410 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11411 | } |
| 11412 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 11413 | if (hdd_ctx->target_hw_name) { |
| 11414 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 11415 | hdd_ctx->target_hw_name = NULL; |
| 11416 | } |
| 11417 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 11418 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11419 | |
| 11420 | ol_cds_free(); |
| 11421 | |
Dustin Brown | c2a156e | 2018-10-25 16:56:27 -0700 | [diff] [blame] | 11422 | if (IS_IDLE_STOP) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11423 | ret = pld_power_off(qdf_ctx->dev); |
| 11424 | if (ret) |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11425 | hdd_err("Failed to power down device; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11426 | } |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11427 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11428 | /* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */ |
| 11429 | wlan_hdd_free_cache_channels(hdd_ctx); |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11430 | |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 11431 | hdd_check_for_leaks(hdd_ctx, is_recovery_stop); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 11432 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11433 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11434 | /* Once the firmware sequence is completed reset this flag */ |
| 11435 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11436 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11437 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11438 | |
Kai Liu | eabb1df | 2018-11-08 14:58:54 +0800 | [diff] [blame] | 11439 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, PLD_BUS_WIDTH_NONE); |
| 11440 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11441 | done: |
| 11442 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11443 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11444 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11445 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11446 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11447 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11448 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11449 | } |
| 11450 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11451 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11452 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11453 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11454 | * hdd_state_info_dump() - prints state information of hdd layer |
| 11455 | * @buf: buffer pointer |
| 11456 | * @size: size of buffer to be filled |
| 11457 | * |
| 11458 | * This function is used to dump state information of hdd layer |
| 11459 | * |
| 11460 | * Return: None |
| 11461 | */ |
| 11462 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 11463 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11464 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 11465 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11466 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11467 | uint16_t len = 0; |
| 11468 | char *buf = *buf_ptr; |
| 11469 | |
| 11470 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11471 | if (!hdd_ctx) { |
| 11472 | hdd_err("Failed to get hdd context "); |
| 11473 | return; |
| 11474 | } |
| 11475 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11476 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11477 | |
| 11478 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 11479 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11480 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 11481 | "\n is_scheduler_suspended %d", |
| 11482 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11483 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11484 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11485 | if (adapter->dev) |
| 11486 | len += scnprintf(buf + len, *size - len, |
| 11487 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 11488 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11489 | "\n device_mode: %d", adapter->device_mode); |
| 11490 | switch (adapter->device_mode) { |
| 11491 | case QDF_STA_MODE: |
| 11492 | case QDF_P2P_CLIENT_MODE: |
| 11493 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11494 | len += scnprintf(buf + len, *size - len, |
| 11495 | "\n connState: %d", |
| 11496 | hdd_sta_ctx->conn_info.connState); |
| 11497 | break; |
| 11498 | |
| 11499 | default: |
| 11500 | break; |
| 11501 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11502 | } |
| 11503 | |
| 11504 | *size -= len; |
| 11505 | *buf_ptr += len; |
| 11506 | } |
| 11507 | |
| 11508 | /** |
| 11509 | * hdd_register_debug_callback() - registration function for hdd layer |
| 11510 | * to print hdd state information |
| 11511 | * |
| 11512 | * Return: None |
| 11513 | */ |
| 11514 | static void hdd_register_debug_callback(void) |
| 11515 | { |
| 11516 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 11517 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11518 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 11519 | static void hdd_register_debug_callback(void) |
| 11520 | { |
| 11521 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11522 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11523 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11524 | /* |
| 11525 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 11526 | * |
| 11527 | * This function is used to create bug report lock |
| 11528 | * |
| 11529 | * Return: None |
| 11530 | */ |
| 11531 | static void wlan_init_bug_report_lock(void) |
| 11532 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 11533 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11534 | |
| 11535 | p_cds_context = cds_get_global_context(); |
| 11536 | if (!p_cds_context) { |
| 11537 | hdd_err("cds context is NULL"); |
| 11538 | return; |
| 11539 | } |
| 11540 | |
| 11541 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 11542 | } |
| 11543 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11544 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11545 | void hdd_dp_trace_init(struct hdd_config *config) |
| 11546 | { |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11547 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 11548 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 11549 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 11550 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 11551 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 11552 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 11553 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11554 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11555 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11556 | if (!config->enable_dp_trace) { |
| 11557 | hdd_err("dp trace is disabled from ini"); |
| 11558 | return; |
| 11559 | } |
| 11560 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11561 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 11562 | &num_entries, sizeof(config_params)); |
| 11563 | |
| 11564 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11565 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11566 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11567 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11568 | else if (bw_compute_interval > 1000) { |
| 11569 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 11570 | thresh_time_limit = 1; |
| 11571 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11572 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 11573 | |
| 11574 | switch (num_entries) { |
| 11575 | case 4: |
| 11576 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11577 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11578 | case 3: |
| 11579 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11580 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11581 | case 2: |
| 11582 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11583 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11584 | case 1: |
| 11585 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11586 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11587 | default: |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 11588 | hdd_debug("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 11589 | live_mode, thresh, thresh_time_limit, |
| 11590 | verbosity, proto_bitmap); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11591 | }; |
| 11592 | |
| 11593 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 11594 | verbosity, proto_bitmap); |
| 11595 | |
| 11596 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11597 | #endif |
| 11598 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11599 | #ifdef DISABLE_CHANNEL_LIST |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11600 | 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] | 11601 | { |
| 11602 | return qdf_mutex_create(&hdd_ctx->cache_channel_lock); |
| 11603 | } |
| 11604 | #else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11605 | 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] | 11606 | { |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11607 | return QDF_STATUS_SUCCESS; |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11608 | } |
| 11609 | #endif |
| 11610 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11611 | static QDF_STATUS |
| 11612 | hdd_open_adapters_for_mission_mode(struct hdd_context *hdd_ctx) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11613 | { |
| 11614 | struct hdd_adapter *adapter; |
| 11615 | enum dot11p_mode dot11p_mode; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11616 | QDF_STATUS status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11617 | |
| 11618 | ucfg_mlme_get_dot11p_mode(hdd_ctx->psoc, &dot11p_mode); |
| 11619 | |
| 11620 | /* Create only 802.11p interface? */ |
| 11621 | if (dot11p_mode == CFG_11P_STANDALONE) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11622 | return hdd_open_ocb_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11623 | |
| 11624 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
| 11625 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11626 | NET_NAME_UNKNOWN, true); |
| 11627 | if (!adapter) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11628 | return QDF_STATUS_E_INVAL; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11629 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11630 | /* opening concurrent STA is best effort, continue on error */ |
| 11631 | hdd_open_concurrent_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11632 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11633 | status = hdd_open_p2p_interface(hdd_ctx); |
| 11634 | if (status) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11635 | goto err_close_adapters; |
| 11636 | |
| 11637 | /* Open 802.11p Interface */ |
| 11638 | if (dot11p_mode == CFG_11P_CONCURRENT) { |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11639 | status = hdd_open_ocb_interface(hdd_ctx); |
| 11640 | if (QDF_IS_STATUS_ERROR(status)) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11641 | goto err_close_adapters; |
| 11642 | } |
| 11643 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11644 | return QDF_STATUS_SUCCESS; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11645 | |
| 11646 | err_close_adapters: |
| 11647 | hdd_close_all_adapters(hdd_ctx, true); |
| 11648 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11649 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11650 | } |
| 11651 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11652 | 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] | 11653 | { |
| 11654 | struct hdd_adapter *adapter; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11655 | |
| 11656 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 11657 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11658 | NET_NAME_UNKNOWN, true); |
| 11659 | |
| 11660 | return adapter ? QDF_STATUS_SUCCESS : QDF_STATUS_E_INVAL; |
| 11661 | } |
| 11662 | |
| 11663 | static QDF_STATUS |
| 11664 | hdd_open_adapters_for_monitor_mode(struct hdd_context *hdd_ctx) |
| 11665 | { |
| 11666 | struct hdd_adapter *adapter; |
| 11667 | |
| 11668 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 11669 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11670 | NET_NAME_UNKNOWN, true); |
| 11671 | |
| 11672 | return adapter ? QDF_STATUS_SUCCESS : QDF_STATUS_E_INVAL; |
| 11673 | } |
| 11674 | |
| 11675 | static QDF_STATUS hdd_open_adapters_for_epping_mode(struct hdd_context *hdd_ctx) |
| 11676 | { |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11677 | QDF_STATUS status; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11678 | qdf_device_t qdf_dev; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11679 | |
| 11680 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11681 | QDF_BUG(qdf_dev); |
| 11682 | if (!qdf_dev) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11683 | return QDF_STATUS_E_INVAL; |
| 11684 | |
| 11685 | status = epping_open(); |
| 11686 | if (QDF_IS_STATUS_ERROR(status)) |
| 11687 | return status; |
| 11688 | |
| 11689 | if (epping_enable(qdf_dev->dev)) { |
| 11690 | status = QDF_STATUS_E_INVAL; |
| 11691 | goto epping_close; |
| 11692 | } |
| 11693 | |
| 11694 | return QDF_STATUS_SUCCESS; |
| 11695 | |
| 11696 | epping_close: |
| 11697 | epping_close(); |
| 11698 | |
| 11699 | return status; |
| 11700 | } |
| 11701 | |
| 11702 | typedef QDF_STATUS (*hdd_open_mode_handler)(struct hdd_context *hdd_ctx); |
| 11703 | |
| 11704 | static const hdd_open_mode_handler |
| 11705 | hdd_open_mode_handlers[QDF_GLOBAL_MAX_MODE] = { |
| 11706 | [QDF_GLOBAL_MISSION_MODE] = hdd_open_adapters_for_mission_mode, |
| 11707 | [QDF_GLOBAL_FTM_MODE] = hdd_open_adapters_for_ftm_mode, |
| 11708 | [QDF_GLOBAL_MONITOR_MODE] = hdd_open_adapters_for_monitor_mode, |
| 11709 | [QDF_GLOBAL_EPPING_MODE] = hdd_open_adapters_for_epping_mode, |
| 11710 | }; |
| 11711 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11712 | static QDF_STATUS hdd_open_adapters_for_mode(struct hdd_context *hdd_ctx, |
| 11713 | enum QDF_GLOBAL_MODE driver_mode) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11714 | { |
| 11715 | QDF_STATUS status; |
| 11716 | |
| 11717 | if (driver_mode < 0 || |
| 11718 | driver_mode >= QDF_GLOBAL_MAX_MODE || |
| 11719 | !hdd_open_mode_handlers[driver_mode]) { |
| 11720 | hdd_err("Driver mode %d not supported", driver_mode); |
| 11721 | return -ENOTSUPP; |
| 11722 | } |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11723 | |
| 11724 | hdd_hold_rtnl_lock(); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11725 | status = hdd_open_mode_handlers[driver_mode](hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11726 | hdd_release_rtnl_lock(); |
| 11727 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11728 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11729 | } |
| 11730 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11731 | int hdd_wlan_startup(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11732 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11733 | QDF_STATUS status; |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11734 | int errno; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11735 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11736 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11737 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11738 | hdd_action_oui_config(hdd_ctx); |
| 11739 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11740 | qdf_nbuf_init_replenish_timer(); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11741 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11742 | status = wlan_hdd_cache_chann_mutex_create(hdd_ctx); |
| 11743 | if (QDF_IS_STATUS_ERROR(status)) |
| 11744 | return qdf_status_to_os_return(status); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11745 | |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 11746 | #ifdef FEATURE_WLAN_CH_AVOID |
| 11747 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 11748 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11749 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11750 | osif_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 11751 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11752 | hdd_driver_memdump_init(); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11753 | hdd_bus_bandwidth_init(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11754 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11755 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 11756 | if (errno) { |
| 11757 | hdd_err("Failed to start modules; errno:%d", errno); |
| 11758 | goto memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11759 | } |
| 11760 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 11761 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11762 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11763 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 11764 | if (!hdd_ctx->mac_handle) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11765 | hdd_err("Mac Handle is null"); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11766 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11767 | } |
| 11768 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11769 | errno = hdd_wiphy_init(hdd_ctx); |
| 11770 | if (errno) { |
| 11771 | hdd_err("Failed to initialize wiphy; errno:%d", errno); |
| 11772 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11773 | } |
| 11774 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11775 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 11776 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 11777 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 11778 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11779 | errno = register_netdevice_notifier(&hdd_netdev_notifier); |
| 11780 | if (errno) { |
| 11781 | hdd_err("register_netdevice_notifier failed; errno:%d", errno); |
| 11782 | goto unregister_wiphy; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11783 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 11784 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11785 | errno = register_reboot_notifier(&system_reboot_notifier); |
| 11786 | if (errno) { |
| 11787 | hdd_err("Failed to register reboot notifier; errno:%d", errno); |
| 11788 | goto unregister_netdev; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11789 | } |
| 11790 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 11791 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 11792 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11793 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 11794 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11795 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11796 | hdd_skip_acs_scan_timer_handler, |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11797 | hdd_ctx); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11798 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11799 | hdd_err("Failed to init ACS Skip timer"); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11800 | |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 11801 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11802 | #endif |
| 11803 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 11804 | hdd_lpass_notify_wlan_version(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11805 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11806 | errno = hdd_register_notifiers(hdd_ctx); |
| 11807 | if (errno) |
| 11808 | goto unregister_reboot; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 11809 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11810 | status = wlansap_global_init(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11811 | if (QDF_IS_STATUS_ERROR(status)) |
| 11812 | goto unregister_notifiers; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11813 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11814 | hdd_set_idle_ps_config(hdd_ctx, hdd_ctx->config->fIsImpsEnabled); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11815 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11816 | hdd_exit(); |
| 11817 | |
| 11818 | return 0; |
| 11819 | |
| 11820 | unregister_notifiers: |
| 11821 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11822 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11823 | unregister_reboot: |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11824 | unregister_reboot_notifier(&system_reboot_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11825 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11826 | unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11827 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 11828 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11829 | unregister_wiphy: |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 11830 | qdf_dp_trace_deinit(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11831 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11832 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11833 | stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11834 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11835 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11836 | memdump_deinit: |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11837 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11838 | hdd_driver_memdump_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11839 | osif_request_manager_deinit(); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11840 | qdf_nbuf_deinit_replenish_timer(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 11841 | |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 11842 | if (cds_is_fw_down()) |
| 11843 | hdd_err("Not setting the complete event as fw is down"); |
| 11844 | else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11845 | hdd_start_complete(errno); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11846 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11847 | hdd_exit(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11848 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11849 | return errno; |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11850 | } |
| 11851 | |
| 11852 | QDF_STATUS hdd_psoc_create_vdevs(struct hdd_context *hdd_ctx) |
| 11853 | { |
| 11854 | enum QDF_GLOBAL_MODE driver_mode = hdd_get_conparam(); |
| 11855 | QDF_STATUS status; |
| 11856 | |
| 11857 | status = hdd_open_adapters_for_mode(hdd_ctx, driver_mode); |
| 11858 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11859 | hdd_err("Failed to create vdevs; status:%d", status); |
| 11860 | return status; |
| 11861 | } |
| 11862 | |
| 11863 | if (hdd_ctx->rps) |
| 11864 | hdd_set_rps_cpu_mask(hdd_ctx); |
| 11865 | |
| 11866 | if (driver_mode != QDF_GLOBAL_FTM_MODE) |
| 11867 | hdd_psoc_idle_timer_start(hdd_ctx); |
| 11868 | |
| 11869 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11870 | } |
| 11871 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11872 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11873 | * hdd_wlan_update_target_info() - update target type info |
| 11874 | * @hdd_ctx: HDD context |
| 11875 | * @context: hif context |
| 11876 | * |
| 11877 | * Update target info received from firmware in hdd context |
| 11878 | * Return:None |
| 11879 | */ |
| 11880 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11881 | 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] | 11882 | { |
| 11883 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 11884 | |
| 11885 | if (!tgt_info) { |
| 11886 | hdd_err("Target info is Null"); |
| 11887 | return; |
| 11888 | } |
| 11889 | |
| 11890 | hdd_ctx->target_type = tgt_info->target_type; |
| 11891 | } |
| 11892 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11893 | 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] | 11894 | { |
| 11895 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11896 | int status; |
| 11897 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11898 | struct osif_request *request = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11899 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11900 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11901 | |
| 11902 | if (!rsp) { |
| 11903 | hdd_err("data is null"); |
| 11904 | return; |
| 11905 | } |
| 11906 | |
| 11907 | status = wlan_hdd_validate_context(hdd_ctx); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11908 | if (status != 0) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11909 | return; |
| 11910 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11911 | request = osif_request_get(context); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11912 | if (!request) { |
| 11913 | hdd_err("obselete request"); |
| 11914 | return; |
| 11915 | } |
| 11916 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11917 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 11918 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 11919 | hdd_err("Invalid adapter or adapter has invalid magic"); |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11920 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11921 | return; |
| 11922 | } |
| 11923 | |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 11924 | hdd_debug("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 11925 | hdd_debug("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 11926 | hdd_debug("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 11927 | hdd_debug("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 11928 | hdd_debug("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 11929 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 11930 | hdd_debug("rsp->dad_detected :%x", rsp->dad_detected); |
| 11931 | hdd_debug("rsp->connect_status :%x", rsp->connect_status); |
| 11932 | hdd_debug("rsp->ba_session_establishment_status :%x", |
| 11933 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11934 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11935 | 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] | 11936 | adapter->dad |= rsp->dad_detected; |
| 11937 | adapter->con_status = rsp->connect_status; |
| 11938 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11939 | /* Flag true indicates connectivity check stats present. */ |
| 11940 | if (rsp->connect_stats_present) { |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 11941 | hdd_debug("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 11942 | hdd_debug("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11943 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 11944 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 11945 | rsp->icmpv4_rsp_recvd; |
| 11946 | } |
| 11947 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11948 | osif_request_complete(request); |
| 11949 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11950 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11951 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11952 | } |
| 11953 | |
| 11954 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11955 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11956 | * @hdd_ctx: HDD context |
| 11957 | * |
| 11958 | * Register the HDD callbacks to CDS/SME. |
| 11959 | * |
| 11960 | * Return: 0 for success or Error code for failure |
| 11961 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11962 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11963 | { |
| 11964 | QDF_STATUS status; |
| 11965 | int ret = 0; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11966 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11967 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11968 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 11969 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 11970 | hdd_err("in ftm mode, no need to register callbacks"); |
| 11971 | return ret; |
| 11972 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11973 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11974 | mac_handle = hdd_ctx->mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11975 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11976 | sme_register_oem_data_rsp_callback(mac_handle, |
| 11977 | hdd_send_oem_data_rsp_msg); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11978 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11979 | sme_register_mgmt_frame_ind_callback(mac_handle, |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 11980 | hdd_indicate_mgmt_frame); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11981 | sme_set_tsfcb(mac_handle, hdd_get_tsf_cb, hdd_ctx); |
| 11982 | sme_nan_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11983 | wlan_hdd_cfg80211_nan_callback); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11984 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11985 | wlan_hdd_cfg80211_stats_ext_callback); |
| 11986 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11987 | sme_ext_scan_register_callback(mac_handle, |
| 11988 | wlan_hdd_cfg80211_extscan_callback); |
| 11989 | sme_stats_ext2_register_callback(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 11990 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11991 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11992 | sme_set_rssi_threshold_breached_cb(mac_handle, |
| 11993 | hdd_rssi_threshold_breached); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11994 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11995 | sme_set_link_layer_stats_ind_cb(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11996 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 11997 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11998 | 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] | 11999 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12000 | sme_set_link_layer_ext_cb(mac_handle, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 12001 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 12002 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12003 | status = sme_set_lost_link_info_cb(mac_handle, |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 12004 | hdd_lost_link_info_cb); |
| 12005 | /* print error and not block the startup process */ |
| 12006 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12007 | hdd_err("set lost link info callback failed"); |
| 12008 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12009 | ret = hdd_register_data_stall_detect_cb(); |
| 12010 | if (ret) { |
| 12011 | hdd_err("Register data stall detect detect callback failed."); |
| 12012 | return ret; |
| 12013 | } |
| 12014 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12015 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 12016 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12017 | sme_register_set_connection_info_cb(mac_handle, |
| 12018 | hdd_set_connection_in_progress, |
| 12019 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12020 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12021 | status = sme_congestion_register_callback(mac_handle, |
| 12022 | hdd_update_cca_info_cb); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12023 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12024 | hdd_err("set congestion callback failed"); |
| 12025 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12026 | status = sme_set_bt_activity_info_cb(mac_handle, |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 12027 | hdd_bt_activity_cb); |
| 12028 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12029 | hdd_err("set bt activity info callback failed"); |
| 12030 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12031 | status = sme_register_tx_queue_cb(mac_handle, |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 12032 | hdd_tx_queue_cb); |
| 12033 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12034 | hdd_err("Register tx queue callback failed"); |
| 12035 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12036 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12037 | |
| 12038 | return ret; |
| 12039 | } |
| 12040 | |
| 12041 | /** |
| 12042 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 12043 | * @hdd_ctx: HDD context |
| 12044 | * |
| 12045 | * De-Register the HDD callbacks to CDS/SME. |
| 12046 | * |
| 12047 | * Return: void |
| 12048 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12049 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12050 | { |
| 12051 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12052 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12053 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12054 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12055 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12056 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12057 | hdd_err("in ftm mode, no need to deregister callbacks"); |
| 12058 | return; |
| 12059 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12060 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12061 | mac_handle = hdd_ctx->mac_handle; |
| 12062 | sme_deregister_tx_queue_cb(mac_handle); |
| 12063 | status = sme_deregister_for_dcc_stats_event(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12064 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12065 | hdd_err("De-register of dcc stats callback failed: %d", |
| 12066 | status); |
| 12067 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12068 | sme_reset_link_layer_stats_ind_cb(mac_handle); |
| 12069 | sme_reset_rssi_threshold_breached_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12070 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12071 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12072 | wlan_hdd_cfg80211_stats_ext_callback); |
| 12073 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12074 | sme_nan_deregister_callback(mac_handle); |
| 12075 | status = sme_reset_tsfcb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12076 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12077 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 12078 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12079 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12080 | ret = hdd_deregister_data_stall_detect_cb(); |
| 12081 | if (ret) |
| 12082 | hdd_err("Failed to de-register data stall detect event callback"); |
| 12083 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12084 | sme_deregister_oem_data_rsp_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12085 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12086 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12087 | } |
| 12088 | |
| 12089 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12090 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 12091 | * @adapter: Pointer to the HDD |
| 12092 | * @enable: bool value |
| 12093 | * |
| 12094 | * This to take counter measure to handle deauth req from HDD |
| 12095 | * |
| 12096 | * Return: None |
| 12097 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12098 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 12099 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12100 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12101 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12102 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12103 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12104 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12105 | /* Ignore request to deauth bcmc station */ |
| 12106 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12107 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12108 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12109 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12110 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 12111 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12112 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12113 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12114 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12115 | } |
| 12116 | |
| 12117 | /** |
| 12118 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 12119 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 12120 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12121 | * |
| 12122 | * This to take counter measure to handle deauth req from HDD |
| 12123 | * |
| 12124 | * Return: None |
| 12125 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12126 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 12127 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12128 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12129 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12130 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12131 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 12132 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12133 | return; |
| 12134 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12135 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 12136 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12137 | } |
| 12138 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12139 | /** |
| 12140 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 12141 | * @hdd_ctx: HDD Context |
| 12142 | * |
| 12143 | * API to find if there is any STA or P2P-Client is connected |
| 12144 | * |
| 12145 | * Return: true if connected; false otherwise |
| 12146 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12147 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12148 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12149 | return sme_is_sta_p2p_client_connected(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12150 | } |
| 12151 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12152 | void wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12153 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12154 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12155 | struct hdd_adapter *adapter = NULL; |
| 12156 | struct csr_roam_profile *roam_profile; |
| 12157 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12158 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12159 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12160 | hdd_debug("No active sta session"); |
| 12161 | return; |
| 12162 | } |
| 12163 | |
| 12164 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12165 | roam_profile = hdd_roam_profile(adapter); |
| 12166 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12167 | |
| 12168 | if (cur_adapter->session_id != adapter->session_id && |
| 12169 | adapter->device_mode == QDF_STA_MODE && |
| 12170 | hdd_conn_is_connected(sta_ctx)) { |
| 12171 | hdd_debug("%d Disable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12172 | sme_stop_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12173 | adapter->session_id, |
| 12174 | ecsr_driver_disabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12175 | } |
| 12176 | } |
| 12177 | } |
| 12178 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12179 | void wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12180 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12181 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12182 | struct hdd_adapter *adapter = NULL; |
| 12183 | struct csr_roam_profile *roam_profile; |
| 12184 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12185 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12186 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12187 | hdd_debug("No active sta session"); |
| 12188 | return; |
| 12189 | } |
| 12190 | |
| 12191 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12192 | roam_profile = hdd_roam_profile(adapter); |
| 12193 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12194 | |
| 12195 | if (cur_adapter->session_id != adapter->session_id && |
| 12196 | adapter->device_mode == QDF_STA_MODE && |
| 12197 | hdd_conn_is_connected(sta_ctx)) { |
| 12198 | hdd_debug("%d Enable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12199 | sme_start_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12200 | adapter->session_id, |
| 12201 | REASON_DRIVER_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12202 | } |
| 12203 | } |
| 12204 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12205 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12206 | /** |
| 12207 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 12208 | * @skb: sk buffer pointer |
| 12209 | * |
| 12210 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 12211 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 12212 | * |
| 12213 | * Return: None |
| 12214 | */ |
| 12215 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 12216 | { |
| 12217 | #ifdef CNSS_GENL |
| 12218 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 12219 | #else |
| 12220 | nl_srv_bcast(skb); |
| 12221 | #endif |
| 12222 | } |
| 12223 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12224 | 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] | 12225 | { |
| 12226 | struct sk_buff *skb; |
| 12227 | struct nlmsghdr *nlh; |
| 12228 | tAniMsgHdr *ani_hdr; |
| 12229 | void *nl_data = NULL; |
| 12230 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12231 | struct radio_index_tlv *radio_info; |
| 12232 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12233 | |
| 12234 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 12235 | flags = GFP_ATOMIC; |
| 12236 | |
| 12237 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 12238 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12239 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12240 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12241 | |
| 12242 | nlh = (struct nlmsghdr *)skb->data; |
| 12243 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 12244 | nlh->nlmsg_flags = 0; |
| 12245 | nlh->nlmsg_seq = 0; |
| 12246 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 12247 | |
| 12248 | ani_hdr = NLMSG_DATA(nlh); |
| 12249 | ani_hdr->type = type; |
| 12250 | |
| 12251 | switch (type) { |
| 12252 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 12253 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12254 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12255 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12256 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12257 | ani_hdr->length = 0; |
| 12258 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12259 | break; |
| 12260 | case WLAN_SVC_WLAN_STATUS_IND: |
| 12261 | case WLAN_SVC_WLAN_VERSION_IND: |
| 12262 | case WLAN_SVC_DFS_CAC_START_IND: |
| 12263 | case WLAN_SVC_DFS_CAC_END_IND: |
| 12264 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 12265 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 12266 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 12267 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 12268 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 12269 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12270 | ani_hdr->length = len; |
| 12271 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 12272 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 12273 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12274 | break; |
| 12275 | |
| 12276 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 12277 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12278 | type); |
| 12279 | kfree_skb(skb); |
| 12280 | return; |
| 12281 | } |
| 12282 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12283 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 12284 | * Add radio index at the end of the svc event in TLV format |
| 12285 | * to maintain the backward compatibility with userspace |
| 12286 | * applications. |
| 12287 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12288 | |
| 12289 | tlv_len = 0; |
| 12290 | |
| 12291 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 12292 | < WLAN_NL_MAX_PAYLOAD) { |
| 12293 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 12294 | sizeof(*ani_hdr) + len); |
| 12295 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 12296 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 12297 | radio_info->radio = radio; |
| 12298 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12299 | hdd_debug("Added radio index tlv - radio index %d", |
| 12300 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12301 | } |
| 12302 | |
| 12303 | nlh->nlmsg_len += tlv_len; |
| 12304 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 12305 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12306 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12307 | } |
| 12308 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12309 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 12310 | void wlan_hdd_auto_shutdown_cb(void) |
| 12311 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12312 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12313 | |
| 12314 | if (!hdd_ctx) |
| 12315 | return; |
| 12316 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12317 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12318 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 12319 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12320 | } |
| 12321 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12322 | 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] | 12323 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12324 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12325 | bool ap_connected = false, sta_connected = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12326 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12327 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12328 | mac_handle = hdd_ctx->mac_handle; |
| 12329 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12330 | return; |
| 12331 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12332 | if (hdd_ctx->config->wlan_auto_shutdown == 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12333 | return; |
| 12334 | |
| 12335 | if (enable == false) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12336 | if (sme_set_auto_shutdown_timer(mac_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12337 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12338 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12339 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12340 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12341 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12342 | return; |
| 12343 | } |
| 12344 | |
| 12345 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12346 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->psoc)) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12347 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12348 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12349 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 12350 | conn_info.connState == |
| 12351 | eConnectionState_Associated) { |
| 12352 | sta_connected = true; |
| 12353 | break; |
| 12354 | } |
| 12355 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12356 | |
| 12357 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12358 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12359 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12360 | ap_connected = true; |
| 12361 | break; |
| 12362 | } |
| 12363 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12364 | } |
| 12365 | } |
| 12366 | |
| 12367 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12368 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12369 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12370 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12371 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12372 | if (sme_set_auto_shutdown_timer(mac_handle, |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12373 | hdd_ctx->config->wlan_auto_shutdown) |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12374 | != QDF_STATUS_SUCCESS) |
| 12375 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 12376 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 12377 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12378 | hdd_ctx->config->wlan_auto_shutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12379 | } |
| 12380 | #endif |
| 12381 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12382 | struct hdd_adapter * |
| 12383 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 12384 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12385 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12386 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12387 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12388 | |
| 12389 | con_sap_adapter = NULL; |
| 12390 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12391 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12392 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 12393 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12394 | adapter != this_sap_adapter) { |
| 12395 | if (check_start_bss) { |
| 12396 | if (test_bit(SOFTAP_BSS_STARTED, |
| 12397 | &adapter->event_flags)) { |
| 12398 | con_sap_adapter = adapter; |
| 12399 | break; |
| 12400 | } |
| 12401 | } else { |
| 12402 | con_sap_adapter = adapter; |
| 12403 | break; |
| 12404 | } |
| 12405 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12406 | } |
| 12407 | |
| 12408 | return con_sap_adapter; |
| 12409 | } |
| 12410 | |
| 12411 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12412 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12413 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12414 | return adapter->device_mode == QDF_STA_MODE || |
| 12415 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12416 | } |
| 12417 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12418 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12419 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12420 | return adapter->device_mode == QDF_SAP_MODE || |
| 12421 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 12422 | } |
| 12423 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12424 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12425 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12426 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12427 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12428 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12429 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12430 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 12431 | conn_info.connState == eConnectionState_Associated) { |
| 12432 | return true; |
| 12433 | } |
| 12434 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12435 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12436 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12437 | return true; |
| 12438 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12439 | } |
| 12440 | |
| 12441 | return false; |
| 12442 | } |
| 12443 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12444 | 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] | 12445 | { |
| 12446 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12447 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 12448 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12449 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 12450 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12451 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12452 | return is_running; |
| 12453 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12454 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12455 | 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] | 12456 | { |
| 12457 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 12458 | hdd_ctx->bus_bw_timer_running = true; |
| 12459 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 12460 | hdd_ctx->config->bus_bw_compute_interval); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12461 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 12462 | } |
| 12463 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12464 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12465 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12466 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12467 | |
| 12468 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12469 | hdd_debug("Bandwidth compute timer already started"); |
| 12470 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12471 | } |
| 12472 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12473 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12474 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12475 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12476 | } |
| 12477 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12478 | 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] | 12479 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12480 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12481 | |
| 12482 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12483 | hdd_debug("Bandwidth compute timer already started"); |
| 12484 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 12485 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12486 | |
| 12487 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12488 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12489 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12490 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12491 | } |
| 12492 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12493 | 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] | 12494 | { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12495 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12496 | |
| 12497 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12498 | hdd_ctx->bus_bw_timer_running = false; |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 12499 | qdf_timer_sync_cancel(&hdd_ctx->bus_bw_timer); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12500 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 12501 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 12502 | /* work callback is long running; flush outside of lock */ |
| 12503 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12504 | hdd_reset_tcp_delack(hdd_ctx); |
| 12505 | } |
| 12506 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12507 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12508 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12509 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12510 | |
| 12511 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12512 | hdd_debug("Bandwidth compute timer already stopped"); |
| 12513 | return; |
| 12514 | } |
| 12515 | |
| 12516 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12517 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12518 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12519 | } |
| 12520 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12521 | 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] | 12522 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12523 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12524 | |
| 12525 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 12526 | hdd_debug("Bandwidth compute timer already stopped"); |
| 12527 | return; |
| 12528 | } |
| 12529 | |
| 12530 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12531 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12532 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12533 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12534 | } |
| 12535 | #endif |
| 12536 | |
| 12537 | /** |
| 12538 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 12539 | * and sta's operating channel. |
| 12540 | * @sta_adapter: Describe the first argument to foobar. |
| 12541 | * @ap_adapter: Describe the second argument to foobar. |
| 12542 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 12543 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 12544 | * set this flag to true else false. |
| 12545 | * |
| 12546 | * This function checks the sap's operating channel and sta's operating channel. |
| 12547 | * if both are same then it will return false else it will restart the sap in |
| 12548 | * sta's channel and return true. |
| 12549 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12550 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12551 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12552 | QDF_STATUS |
| 12553 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 12554 | struct hdd_adapter *ap_adapter, |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 12555 | struct csr_roam_profile *roam_profile, |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12556 | tScanResultHandle *scan_cache, |
| 12557 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12558 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12559 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12560 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12561 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12562 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12563 | *concurrent_chnl_same = true; |
| 12564 | |
| 12565 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12566 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 12567 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12568 | scan_cache, |
| 12569 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12570 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12571 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12572 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 12573 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12574 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12575 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12576 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12577 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12578 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 12579 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12580 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12581 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12582 | } |
| 12583 | } |
| 12584 | } else { |
| 12585 | /* |
| 12586 | * Lets handle worst case scenario here, Scan cache lookup is |
| 12587 | * failed so we have to stop the SAP to avoid any channel |
| 12588 | * discrepancy between SAP's channel and STA's channel. |
| 12589 | * Return the status as failure so caller function could know |
| 12590 | * that scan look up is failed. |
| 12591 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12592 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12593 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12594 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12595 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12596 | } |
| 12597 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12598 | /** |
| 12599 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 12600 | * @ap_adapter: SAP adapter |
| 12601 | * |
| 12602 | * This function will process the stopping of sap adapter. |
| 12603 | * |
| 12604 | * Return: None |
| 12605 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12606 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12607 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12608 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12609 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12610 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12611 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12612 | |
| 12613 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12614 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12615 | return; |
| 12616 | } |
| 12617 | |
| 12618 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12619 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12620 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12621 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12622 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12623 | mutex_lock(&hdd_ctx->sap_lock); |
| 12624 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 12625 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12626 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12627 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12628 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12629 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12630 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12631 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 12632 | qdf_stop_bss_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 12633 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12634 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12635 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12636 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12637 | return; |
| 12638 | } |
| 12639 | } |
| 12640 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12641 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12642 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12643 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12644 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12645 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12646 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12647 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12648 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12649 | } |
| 12650 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12651 | } |
| 12652 | |
| 12653 | /** |
| 12654 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 12655 | * @ap_adapter: SAP adapter |
| 12656 | * |
| 12657 | * This function will process the starting of sap adapter. |
| 12658 | * |
| 12659 | * Return: None |
| 12660 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12661 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12662 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12663 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12664 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12665 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12666 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 12667 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12668 | |
| 12669 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12670 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12671 | return; |
| 12672 | } |
| 12673 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12674 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 12675 | hdd_err("SoftAp role has not been enabled"); |
| 12676 | return; |
| 12677 | } |
| 12678 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12679 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 12680 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12681 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 12682 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12683 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12684 | mutex_lock(&hdd_ctx->sap_lock); |
| 12685 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 12686 | goto end; |
| 12687 | |
| 12688 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12689 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12690 | goto end; |
| 12691 | } |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12692 | wlan_reg_set_channel_params(hdd_ctx->pdev, |
Abhinav Kumar | 6f69448 | 2018-09-04 16:07:39 +0530 | [diff] [blame] | 12693 | hdd_ap_ctx->sap_config.channel, 0, |
| 12694 | &hdd_ap_ctx->sap_config.ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12695 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 12696 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12697 | 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] | 12698 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12699 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12700 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12701 | goto end; |
| 12702 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12703 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12704 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 12705 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12706 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12707 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12708 | goto end; |
| 12709 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12710 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12711 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12712 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12713 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12714 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12715 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12716 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12717 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12718 | true); |
| 12719 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 12720 | mutex_unlock(&hdd_ctx->sap_lock); |
| 12721 | |
| 12722 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12723 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12724 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12725 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 12726 | /* SAP context and beacon cleanup will happen during driver unload |
| 12727 | * in hdd_stop_adapter |
| 12728 | */ |
| 12729 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 12730 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12731 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12732 | |
| 12733 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12734 | * hdd_get_fw_version() - Get FW version |
| 12735 | * @hdd_ctx: pointer to HDD context. |
| 12736 | * @major_spid: FW version - major spid. |
| 12737 | * @minor_spid: FW version - minor spid |
| 12738 | * @ssid: FW version - ssid |
| 12739 | * @crmid: FW version - crmid |
| 12740 | * |
| 12741 | * This function is called to get the firmware build version stored |
| 12742 | * as part of the HDD context |
| 12743 | * |
| 12744 | * Return: None |
| 12745 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12746 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12747 | uint32_t *major_spid, uint32_t *minor_spid, |
| 12748 | uint32_t *siid, uint32_t *crmid) |
| 12749 | { |
| 12750 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 12751 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 12752 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 12753 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 12754 | } |
| 12755 | |
| 12756 | #ifdef QCA_CONFIG_SMP |
| 12757 | /** |
| 12758 | * wlan_hdd_get_cpu() - get cpu_index |
| 12759 | * |
| 12760 | * Return: cpu_index |
| 12761 | */ |
| 12762 | int wlan_hdd_get_cpu(void) |
| 12763 | { |
| 12764 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12765 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12766 | put_cpu(); |
| 12767 | return cpu_index; |
| 12768 | } |
| 12769 | #endif |
| 12770 | |
| 12771 | /** |
| 12772 | * hdd_get_fwpath() - get framework path |
| 12773 | * |
| 12774 | * This function is used to get the string written by |
| 12775 | * userspace to start the wlan driver |
| 12776 | * |
| 12777 | * Return: string |
| 12778 | */ |
| 12779 | const char *hdd_get_fwpath(void) |
| 12780 | { |
| 12781 | return fwpath.string; |
| 12782 | } |
| 12783 | |
Dustin Brown | 94ce20f | 2018-09-04 13:11:38 -0700 | [diff] [blame] | 12784 | static inline int hdd_state_query_cb(void) |
| 12785 | { |
| 12786 | return !!wlan_hdd_validate_context(cds_get_context(QDF_MODULE_ID_HDD)); |
| 12787 | } |
| 12788 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12789 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12790 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12791 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12792 | * This function initilizes CDS global context with the help of cds_init. This |
| 12793 | * has to be the first function called after probe to get a valid global |
| 12794 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12795 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12796 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12797 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12798 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12799 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12800 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12801 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12802 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12803 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12804 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12805 | hdd_err("Failed to allocate CDS context"); |
| 12806 | ret = -ENOMEM; |
| 12807 | goto err_out; |
| 12808 | } |
Dustin Brown | 94ce20f | 2018-09-04 13:11:38 -0700 | [diff] [blame] | 12809 | qdf_register_module_state_query_callback(hdd_state_query_cb); |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 12810 | |
| 12811 | wlan_init_bug_report_lock(); |
| 12812 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12813 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12814 | wlan_logging_sock_init_svc(); |
| 12815 | #endif |
| 12816 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12817 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 12818 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 12819 | QDF_TIMER_TYPE_SW); |
| 12820 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12821 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 12822 | hdd_register_debug_callback(); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12823 | wlan_roam_debug_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12824 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12825 | err_out: |
| 12826 | return ret; |
| 12827 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12828 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12829 | /** |
| 12830 | * hdd_deinit() - Deinitialize Driver |
| 12831 | * |
| 12832 | * This function frees CDS global context with the help of cds_deinit. This |
| 12833 | * has to be the last function call in remove callback to free the global |
| 12834 | * context. |
| 12835 | */ |
| 12836 | void hdd_deinit(void) |
| 12837 | { |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12838 | wlan_roam_debug_deinit(); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12839 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12840 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12841 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12842 | wlan_logging_sock_deinit_svc(); |
| 12843 | #endif |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12844 | |
| 12845 | wlan_destroy_bug_report_lock(); |
| 12846 | cds_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12847 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12848 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12849 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 12850 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 12851 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12852 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12853 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12854 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12855 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 12856 | struct file *file) |
| 12857 | { |
| 12858 | return 0; |
| 12859 | } |
| 12860 | |
| 12861 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 12862 | const char __user *user_buf, |
| 12863 | size_t count, |
| 12864 | loff_t *f_pos) |
| 12865 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12866 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12867 | static const char wlan_off_str[] = "OFF"; |
| 12868 | static const char wlan_on_str[] = "ON"; |
| 12869 | int ret; |
| 12870 | unsigned long rc; |
| 12871 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12872 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12873 | pr_err("Failed to read buffer\n"); |
| 12874 | return -EINVAL; |
| 12875 | } |
| 12876 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12877 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12878 | pr_debug("Wifi turning off from UI\n"); |
| 12879 | goto exit; |
| 12880 | } |
| 12881 | |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 12882 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12883 | pr_info("Wifi Turning On from UI\n"); |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12884 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12885 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12886 | pr_err("Invalid value received from framework"); |
| 12887 | goto exit; |
| 12888 | } |
| 12889 | |
| 12890 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 12891 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12892 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 12893 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 12894 | if (!rc) { |
Srinivas Girigowda | 09625b0 | 2018-09-10 15:28:09 -0700 | [diff] [blame] | 12895 | hdd_alert("Timed-out!!"); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12896 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12897 | return ret; |
| 12898 | } |
| 12899 | |
| 12900 | hdd_start_complete(0); |
| 12901 | } |
| 12902 | |
| 12903 | exit: |
| 12904 | return count; |
| 12905 | } |
| 12906 | |
| 12907 | |
| 12908 | const struct file_operations wlan_hdd_state_fops = { |
| 12909 | .owner = THIS_MODULE, |
| 12910 | .open = wlan_hdd_state_ctrl_param_open, |
| 12911 | .write = wlan_hdd_state_ctrl_param_write, |
| 12912 | }; |
| 12913 | |
| 12914 | static int wlan_hdd_state_ctrl_param_create(void) |
| 12915 | { |
| 12916 | unsigned int wlan_hdd_state_major = 0; |
| 12917 | int ret; |
| 12918 | struct device *dev; |
| 12919 | |
| 12920 | device = MKDEV(wlan_hdd_state_major, 0); |
| 12921 | |
| 12922 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 12923 | if (ret) { |
| 12924 | pr_err("Failed to register qcwlanstate"); |
| 12925 | goto dev_alloc_err; |
| 12926 | } |
| 12927 | wlan_hdd_state_major = MAJOR(device); |
| 12928 | |
| 12929 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 12930 | if (IS_ERR(class)) { |
| 12931 | pr_err("wlan_hdd_state class_create error"); |
| 12932 | goto class_err; |
| 12933 | } |
| 12934 | |
| 12935 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 12936 | if (IS_ERR(dev)) { |
| 12937 | pr_err("wlan_hdd_statedevice_create error"); |
| 12938 | goto err_class_destroy; |
| 12939 | } |
| 12940 | |
| 12941 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 12942 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 12943 | if (ret) { |
| 12944 | pr_err("Failed to add cdev error"); |
| 12945 | goto cdev_add_err; |
| 12946 | } |
| 12947 | |
| 12948 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 12949 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 12950 | |
| 12951 | return 0; |
| 12952 | |
| 12953 | cdev_add_err: |
| 12954 | device_destroy(class, device); |
| 12955 | err_class_destroy: |
| 12956 | class_destroy(class); |
| 12957 | class_err: |
| 12958 | unregister_chrdev_region(device, dev_num); |
| 12959 | dev_alloc_err: |
| 12960 | return -ENODEV; |
| 12961 | } |
| 12962 | |
| 12963 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 12964 | { |
| 12965 | cdev_del(&wlan_hdd_state_cdev); |
| 12966 | device_destroy(class, device); |
| 12967 | class_destroy(class); |
| 12968 | unregister_chrdev_region(device, dev_num); |
| 12969 | |
| 12970 | pr_info("Device node unregistered"); |
| 12971 | } |
| 12972 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12973 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12974 | * hdd_component_init() - Initialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12975 | * |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12976 | * Return: QDF_STATUS |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12977 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12978 | static QDF_STATUS hdd_component_init(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12979 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 12980 | QDF_STATUS status; |
| 12981 | |
| 12982 | /* initialize converged components */ |
| 12983 | status = dispatcher_init(); |
| 12984 | if (QDF_IS_STATUS_ERROR(status)) |
| 12985 | return status; |
| 12986 | |
| 12987 | /* initialize non-converged components */ |
| 12988 | status = ucfg_mlme_init(); |
| 12989 | if (QDF_IS_STATUS_ERROR(status)) |
| 12990 | goto dispatcher_deinit; |
| 12991 | |
| 12992 | status = ucfg_fwol_init(); |
| 12993 | if (QDF_IS_STATUS_ERROR(status)) |
| 12994 | goto mlme_deinit; |
| 12995 | |
| 12996 | status = disa_init(); |
| 12997 | if (QDF_IS_STATUS_ERROR(status)) |
| 12998 | goto fwol_deinit; |
| 12999 | |
| 13000 | status = pmo_init(); |
| 13001 | if (QDF_IS_STATUS_ERROR(status)) |
| 13002 | goto disa_deinit; |
| 13003 | |
| 13004 | status = ucfg_ocb_init(); |
| 13005 | if (QDF_IS_STATUS_ERROR(status)) |
| 13006 | goto pmo_deinit; |
| 13007 | |
| 13008 | status = ipa_init(); |
| 13009 | if (QDF_IS_STATUS_ERROR(status)) |
| 13010 | goto ocb_deinit; |
| 13011 | |
| 13012 | status = ucfg_action_oui_init(); |
| 13013 | if (QDF_IS_STATUS_ERROR(status)) |
| 13014 | goto ipa_deinit; |
| 13015 | |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13016 | status = nan_init(); |
| 13017 | if (QDF_IS_STATUS_ERROR(status)) |
| 13018 | goto action_oui_deinit; |
| 13019 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13020 | status = ucfg_p2p_init(); |
| 13021 | if (QDF_IS_STATUS_ERROR(status)) |
| 13022 | goto nan_deinit; |
| 13023 | |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13024 | status = policy_mgr_init(); |
| 13025 | if (QDF_IS_STATUS_ERROR(status)) |
| 13026 | goto p2p_deinit; |
| 13027 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame^] | 13028 | status = ucfg_tdls_init(); |
| 13029 | if (QDF_IS_STATUS_ERROR(status)) |
| 13030 | goto policy_deinit; |
| 13031 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13032 | return QDF_STATUS_SUCCESS; |
| 13033 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame^] | 13034 | policy_deinit: |
| 13035 | policy_mgr_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13036 | p2p_deinit: |
| 13037 | ucfg_p2p_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13038 | nan_deinit: |
| 13039 | nan_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13040 | action_oui_deinit: |
| 13041 | ucfg_action_oui_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13042 | ipa_deinit: |
| 13043 | ipa_deinit(); |
| 13044 | ocb_deinit: |
| 13045 | ucfg_ocb_deinit(); |
| 13046 | pmo_deinit: |
| 13047 | pmo_deinit(); |
| 13048 | disa_deinit: |
| 13049 | disa_deinit(); |
| 13050 | fwol_deinit: |
| 13051 | ucfg_fwol_deinit(); |
| 13052 | mlme_deinit: |
| 13053 | ucfg_mlme_deinit(); |
| 13054 | dispatcher_deinit: |
| 13055 | dispatcher_deinit(); |
| 13056 | |
| 13057 | return status; |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13058 | } |
| 13059 | |
| 13060 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13061 | * hdd_component_deinit() - Deinitialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13062 | * |
| 13063 | * Return: None |
| 13064 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13065 | static void hdd_component_deinit(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13066 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13067 | /* deinitialize non-converged components */ |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame^] | 13068 | ucfg_tdls_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13069 | policy_mgr_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13070 | ucfg_p2p_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13071 | nan_deinit(); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 13072 | ucfg_action_oui_deinit(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 13073 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13074 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13075 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13076 | disa_deinit(); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13077 | ucfg_fwol_deinit(); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13078 | ucfg_mlme_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13079 | |
| 13080 | /* deinitialize converged components */ |
| 13081 | dispatcher_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13082 | } |
| 13083 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13084 | QDF_STATUS hdd_component_psoc_open(struct wlan_objmgr_psoc *psoc) |
| 13085 | { |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13086 | QDF_STATUS status; |
| 13087 | |
| 13088 | status = ucfg_mlme_psoc_open(psoc); |
| 13089 | if (QDF_IS_STATUS_ERROR(status)) |
| 13090 | return status; |
| 13091 | |
| 13092 | status = ucfg_fwol_psoc_open(psoc); |
| 13093 | if (QDF_IS_STATUS_ERROR(status)) |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13094 | goto err_fwol; |
| 13095 | |
| 13096 | status = ucfg_pmo_psoc_open(psoc); |
| 13097 | if (QDF_IS_STATUS_ERROR(status)) |
| 13098 | goto err_pmo; |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13099 | |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13100 | status = ucfg_policy_mgr_psoc_open(psoc); |
| 13101 | if (QDF_IS_STATUS_ERROR(status)) |
| 13102 | goto err_plcy_mgr; |
| 13103 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13104 | status = ucfg_p2p_psoc_open(psoc); |
| 13105 | if (QDF_IS_STATUS_ERROR(status)) |
| 13106 | goto err_p2p; |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame^] | 13107 | |
| 13108 | status = ucfg_tdls_psoc_open(psoc); |
| 13109 | if (QDF_IS_STATUS_ERROR(status)) |
| 13110 | goto err_tdls; |
| 13111 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13112 | return status; |
| 13113 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame^] | 13114 | err_tdls: |
| 13115 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13116 | err_p2p: |
| 13117 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13118 | err_plcy_mgr: |
| 13119 | ucfg_pmo_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13120 | err_pmo: |
| 13121 | ucfg_fwol_psoc_close(psoc); |
| 13122 | err_fwol: |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13123 | ucfg_mlme_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13124 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13125 | return status; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13126 | } |
| 13127 | |
| 13128 | void hdd_component_psoc_close(struct wlan_objmgr_psoc *psoc) |
| 13129 | { |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame^] | 13130 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13131 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13132 | ucfg_policy_mgr_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13133 | ucfg_pmo_psoc_close(psoc); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13134 | ucfg_fwol_psoc_close(psoc); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13135 | ucfg_mlme_psoc_close(psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13136 | } |
| 13137 | |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13138 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 13139 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13140 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13141 | disa_psoc_enable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13142 | nan_psoc_enable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13143 | p2p_psoc_enable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13144 | policy_mgr_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13145 | } |
| 13146 | |
| 13147 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 13148 | { |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13149 | policy_mgr_psoc_disable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13150 | p2p_psoc_disable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13151 | nan_psoc_disable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13152 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13153 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13154 | } |
| 13155 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 13156 | QDF_STATUS hdd_component_pdev_open(struct wlan_objmgr_pdev *pdev) |
| 13157 | { |
| 13158 | return ucfg_mlme_pdev_open(pdev); |
| 13159 | } |
| 13160 | |
| 13161 | void hdd_component_pdev_close(struct wlan_objmgr_pdev *pdev) |
| 13162 | { |
| 13163 | ucfg_mlme_pdev_close(pdev); |
| 13164 | } |
| 13165 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13166 | static struct hdd_driver __hdd_driver; |
| 13167 | |
| 13168 | static QDF_STATUS hdd_driver_ctx_init(struct hdd_driver *hdd_driver) |
| 13169 | { |
| 13170 | QDF_BUG(hdd_driver); |
| 13171 | if (!hdd_driver) |
| 13172 | return QDF_STATUS_E_INVAL; |
| 13173 | |
| 13174 | hdd_driver->state = driver_state_uninit; |
| 13175 | |
| 13176 | return dsc_driver_create(&hdd_driver->dsc_driver); |
| 13177 | } |
| 13178 | |
| 13179 | static void hdd_driver_ctx_deinit(struct hdd_driver *hdd_driver) |
| 13180 | { |
| 13181 | QDF_BUG(hdd_driver); |
| 13182 | if (!hdd_driver) |
| 13183 | return; |
| 13184 | |
| 13185 | dsc_driver_destroy(&hdd_driver->dsc_driver); |
| 13186 | qdf_mem_zero(hdd_driver, sizeof(*hdd_driver)); |
| 13187 | } |
| 13188 | |
| 13189 | struct hdd_driver *hdd_driver_get(void) |
| 13190 | { |
| 13191 | return &__hdd_driver; |
| 13192 | } |
| 13193 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13194 | static QDF_STATUS hdd_qdf_print_init(void) |
| 13195 | { |
| 13196 | QDF_STATUS status; |
| 13197 | int qdf_print_idx; |
| 13198 | |
| 13199 | status = qdf_print_setup(); |
| 13200 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13201 | pr_err("Failed qdf_print_setup; status:%u\n", status); |
| 13202 | return status; |
| 13203 | } |
| 13204 | |
| 13205 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 13206 | if (qdf_print_idx < 0) { |
| 13207 | pr_err("Failed to register for qdf_print_ctrl\n"); |
| 13208 | return QDF_STATUS_E_FAILURE; |
| 13209 | } |
| 13210 | |
| 13211 | qdf_set_pidx(qdf_print_idx); |
| 13212 | |
| 13213 | return QDF_STATUS_SUCCESS; |
| 13214 | } |
| 13215 | |
| 13216 | static void hdd_qdf_print_deinit(void) |
| 13217 | { |
| 13218 | int qdf_pidx = qdf_get_pidx(); |
| 13219 | |
| 13220 | qdf_set_pidx(-1); |
| 13221 | qdf_print_ctrl_cleanup(qdf_pidx); |
| 13222 | |
| 13223 | /* currently, no qdf print 'un-setup'*/ |
| 13224 | } |
| 13225 | |
| 13226 | static QDF_STATUS hdd_qdf_init(void) |
| 13227 | { |
| 13228 | QDF_STATUS status; |
| 13229 | |
| 13230 | status = hdd_qdf_print_init(); |
| 13231 | if (QDF_IS_STATUS_ERROR(status)) |
| 13232 | goto exit; |
| 13233 | |
| 13234 | status = qdf_debugfs_init(); |
| 13235 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13236 | hdd_err("Failed to init debugfs; status:%u", status); |
| 13237 | goto print_deinit; |
| 13238 | } |
| 13239 | |
| 13240 | qdf_lock_stats_init(); |
| 13241 | qdf_mem_init(); |
| 13242 | qdf_mc_timer_manager_init(); |
| 13243 | qdf_event_list_init(); |
| 13244 | |
| 13245 | status = qdf_cpuhp_init(); |
| 13246 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13247 | hdd_err("Failed to init cpuhp; status:%u", status); |
| 13248 | goto event_deinit; |
| 13249 | } |
| 13250 | |
| 13251 | status = qdf_trace_spin_lock_init(); |
| 13252 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13253 | hdd_err("Failed to init spinlock; status:%u", status); |
| 13254 | goto cpuhp_deinit; |
| 13255 | } |
| 13256 | |
| 13257 | qdf_trace_init(); |
| 13258 | qdf_register_debugcb_init(); |
| 13259 | |
| 13260 | return QDF_STATUS_SUCCESS; |
| 13261 | |
| 13262 | cpuhp_deinit: |
| 13263 | qdf_cpuhp_deinit(); |
| 13264 | event_deinit: |
| 13265 | qdf_event_list_destroy(); |
| 13266 | qdf_mc_timer_manager_exit(); |
| 13267 | qdf_mem_exit(); |
| 13268 | qdf_lock_stats_deinit(); |
| 13269 | qdf_debugfs_exit(); |
| 13270 | print_deinit: |
| 13271 | hdd_qdf_print_deinit(); |
| 13272 | |
| 13273 | exit: |
| 13274 | return status; |
| 13275 | } |
| 13276 | |
| 13277 | static void hdd_qdf_deinit(void) |
| 13278 | { |
| 13279 | /* currently, no debugcb deinit */ |
| 13280 | |
| 13281 | qdf_trace_deinit(); |
| 13282 | |
| 13283 | /* currently, no trace spinlock deinit */ |
| 13284 | |
| 13285 | qdf_cpuhp_deinit(); |
| 13286 | qdf_event_list_destroy(); |
| 13287 | qdf_mc_timer_manager_exit(); |
| 13288 | qdf_mem_exit(); |
| 13289 | qdf_lock_stats_deinit(); |
| 13290 | qdf_debugfs_exit(); |
| 13291 | hdd_qdf_print_deinit(); |
| 13292 | } |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13293 | |
| 13294 | /** |
| 13295 | * hdd_driver_load() - Perform the driver-level load operation |
| 13296 | * |
| 13297 | * Note: this is used in both static and DLKM driver builds |
| 13298 | * |
| 13299 | * Return: Errno |
| 13300 | */ |
| 13301 | static int hdd_driver_load(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13302 | { |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13303 | struct hdd_driver *hdd_driver = hdd_driver_get(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13304 | QDF_STATUS status; |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13305 | int errno; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13306 | |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 13307 | pr_err("%s: Loading driver v%s\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13308 | WLAN_MODULE_NAME, |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 13309 | g_wlan_driver_version); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13310 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13311 | status = hdd_qdf_init(); |
| 13312 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13313 | errno = qdf_status_to_os_return(status); |
| 13314 | goto exit; |
| 13315 | } |
| 13316 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13317 | status = hdd_driver_ctx_init(hdd_driver); |
| 13318 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13319 | hdd_err("Failed to init driver context; status:%u", status); |
| 13320 | errno = qdf_status_to_os_return(status); |
| 13321 | goto qdf_deinit; |
| 13322 | } |
| 13323 | |
| 13324 | status = dsc_driver_trans_start(hdd_driver->dsc_driver, "load"); |
| 13325 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13326 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13327 | errno = qdf_status_to_os_return(status); |
| 13328 | goto hdd_driver_deinit; |
| 13329 | } |
| 13330 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13331 | errno = hdd_init(); |
| 13332 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13333 | hdd_err("Failed to init HDD; errno:%d", errno); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13334 | goto trans_stop; |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13335 | } |
| 13336 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13337 | status = hdd_component_init(); |
| 13338 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13339 | hdd_err("Failed to init components; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13340 | errno = qdf_status_to_os_return(status); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13341 | goto hdd_deinit; |
| 13342 | } |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13343 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13344 | status = qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
| 13345 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13346 | hdd_err("Failed to create wake lock; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13347 | errno = qdf_status_to_os_return(status); |
| 13348 | goto comp_deinit; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13349 | } |
| 13350 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13351 | hdd_set_conparam(con_mode); |
| 13352 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13353 | errno = wlan_hdd_state_ctrl_param_create(); |
| 13354 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13355 | hdd_err("Failed to create ctrl param; errno:%d", errno); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13356 | goto wakelock_destroy; |
| 13357 | } |
| 13358 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13359 | errno = pld_init(); |
| 13360 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13361 | hdd_err("Failed to init PLD; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13362 | goto param_destroy; |
| 13363 | } |
| 13364 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13365 | hdd_driver->state = driver_state_loaded; |
| 13366 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
| 13367 | |
| 13368 | /* psoc probe can happen in registration; do after 'load' transition */ |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13369 | errno = wlan_hdd_register_driver(); |
| 13370 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13371 | hdd_err("Failed to register driver; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13372 | goto pld_deinit; |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13373 | } |
| 13374 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13375 | hdd_debug("%s: driver loaded", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13376 | |
| 13377 | return 0; |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13378 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13379 | pld_deinit: |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13380 | status = dsc_driver_trans_start(hdd_driver->dsc_driver, "unload"); |
| 13381 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13382 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13383 | pld_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13384 | |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13385 | param_destroy: |
| 13386 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13387 | wakelock_destroy: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13388 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13389 | comp_deinit: |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13390 | hdd_component_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13391 | hdd_deinit: |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13392 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13393 | trans_stop: |
| 13394 | hdd_driver->state = driver_state_deinit; |
| 13395 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
| 13396 | hdd_driver_deinit: |
| 13397 | hdd_driver_ctx_deinit(hdd_driver); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13398 | qdf_deinit: |
| 13399 | hdd_qdf_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13400 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13401 | exit: |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13402 | return errno; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13403 | } |
| 13404 | |
| 13405 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13406 | * hdd_driver_unload() - Performs the driver-level unload operation |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13407 | * |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13408 | * Note: this is used in both static and DLKM driver builds |
| 13409 | * |
| 13410 | * Return: None |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13411 | */ |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13412 | static void hdd_driver_unload(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13413 | { |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13414 | struct hdd_driver *hdd_driver = hdd_driver_get(); |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 13415 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13416 | QDF_STATUS status; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 13417 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13418 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 13419 | QWLAN_VERSIONSTR); |
| 13420 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13421 | status = dsc_driver_trans_start_wait(hdd_driver->dsc_driver, "unload"); |
| 13422 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13423 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13424 | hdd_err("Unable to unload wlan; status:%u", status); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 13425 | return; |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13426 | } |
| 13427 | |
| 13428 | dsc_driver_wait_for_ops(hdd_driver->dsc_driver); |
| 13429 | |
| 13430 | if (!hdd_wait_for_recovery_completion()) { |
| 13431 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
| 13432 | return; |
| 13433 | } |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 13434 | |
Will Huang | ba035ec | 2018-07-05 11:13:30 +0800 | [diff] [blame] | 13435 | cds_set_driver_loaded(false); |
| 13436 | cds_set_unload_in_progress(true); |
| 13437 | |
| 13438 | if (!cds_wait_for_external_threads_completion(__func__)) |
| 13439 | hdd_warn("External threads are still active attempting " |
| 13440 | "driver unload anyway"); |
| 13441 | |
Rajeev Kumar | 3505ae5 | 2018-05-10 18:44:45 -0700 | [diff] [blame] | 13442 | if (hdd_ctx) |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 13443 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 13444 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13445 | wlan_hdd_unregister_driver(); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13446 | pld_deinit(); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13447 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13448 | hdd_set_conparam(0); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13449 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13450 | hdd_component_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13451 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13452 | |
| 13453 | hdd_driver->state = driver_state_deinit; |
| 13454 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 13455 | |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13456 | hdd_driver_ctx_deinit(hdd_driver); |
| 13457 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13458 | hdd_qdf_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13459 | } |
| 13460 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13461 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13462 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13463 | * wlan_boot_cb() - Wlan boot callback |
| 13464 | * @kobj: object whose directory we're creating the link in. |
| 13465 | * @attr: attribute the user is interacting with |
| 13466 | * @buff: the buffer containing the user data |
| 13467 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13468 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13469 | * This callback is invoked when the fs is ready to start the |
| 13470 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13471 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13472 | * 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] | 13473 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13474 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13475 | struct kobj_attribute *attr, |
| 13476 | const char *buf, |
| 13477 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13478 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13479 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13480 | if (wlan_loader->loaded_state) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13481 | hdd_err("wlan driver already initialized"); |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13482 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13483 | } |
| 13484 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13485 | if (hdd_driver_load()) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13486 | return -EIO; |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13487 | |
| 13488 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13489 | |
| 13490 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13491 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13492 | |
| 13493 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13494 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 13495 | * |
| 13496 | * Return: None |
| 13497 | * |
| 13498 | */ |
| 13499 | static void hdd_sysfs_cleanup(void) |
| 13500 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13501 | /* remove from group */ |
| 13502 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 13503 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 13504 | wlan_loader->attr_group); |
| 13505 | |
| 13506 | /* unlink the object from parent */ |
| 13507 | kobject_del(wlan_loader->boot_wlan_obj); |
| 13508 | |
| 13509 | /* free the object */ |
| 13510 | kobject_put(wlan_loader->boot_wlan_obj); |
| 13511 | |
| 13512 | kfree(wlan_loader->attr_group); |
| 13513 | kfree(wlan_loader); |
| 13514 | |
| 13515 | wlan_loader = NULL; |
| 13516 | } |
| 13517 | |
| 13518 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13519 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 13520 | * ready |
| 13521 | * |
| 13522 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 13523 | * when the filesystem is ready. |
| 13524 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13525 | * QDF API cannot be used here since this function is called even before |
| 13526 | * initializing WLAN driver. |
| 13527 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13528 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13529 | */ |
| 13530 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13531 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13532 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13533 | |
| 13534 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13535 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13536 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13537 | |
| 13538 | wlan_loader->boot_wlan_obj = NULL; |
| 13539 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 13540 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13541 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13542 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13543 | |
| 13544 | wlan_loader->loaded_state = 0; |
| 13545 | wlan_loader->attr_group->attrs = attrs; |
| 13546 | |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 13547 | wlan_loader->boot_wlan_obj = kobject_create_and_add(WLAN_LOADER_NAME, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13548 | kernel_kobj); |
| 13549 | if (!wlan_loader->boot_wlan_obj) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13550 | hdd_err("sysfs create and add failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13551 | goto error_return; |
| 13552 | } |
| 13553 | |
| 13554 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 13555 | wlan_loader->attr_group); |
| 13556 | if (ret) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13557 | hdd_err("sysfs create group failed; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13558 | goto error_return; |
| 13559 | } |
| 13560 | |
| 13561 | return 0; |
| 13562 | |
| 13563 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13564 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13565 | |
| 13566 | return ret; |
| 13567 | } |
| 13568 | |
| 13569 | /** |
| 13570 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 13571 | * |
| 13572 | * Return: 0 on success or errno on failure |
| 13573 | */ |
| 13574 | static int wlan_deinit_sysfs(void) |
| 13575 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13576 | if (!wlan_loader) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13577 | hdd_err("wlan_loader is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13578 | return -EINVAL; |
| 13579 | } |
| 13580 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13581 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13582 | return 0; |
| 13583 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13584 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13585 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13586 | |
| 13587 | #ifdef MODULE |
| 13588 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13589 | * hdd_module_init() - Module init helper |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13590 | * |
| 13591 | * Module init helper function used by both module and static driver. |
| 13592 | * |
| 13593 | * Return: 0 for success, errno on failure |
| 13594 | */ |
| 13595 | static int hdd_module_init(void) |
| 13596 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13597 | if (hdd_driver_load()) |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13598 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13599 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 13600 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13601 | } |
| 13602 | #else |
| 13603 | static int __init hdd_module_init(void) |
| 13604 | { |
| 13605 | int ret = -EINVAL; |
| 13606 | |
| 13607 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13608 | if (ret) |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13609 | hdd_err("Failed to create sysfs entry"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13610 | |
| 13611 | return ret; |
| 13612 | } |
| 13613 | #endif |
| 13614 | |
| 13615 | |
| 13616 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13617 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13618 | * hdd_module_exit() - Exit function |
| 13619 | * |
| 13620 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 13621 | * |
| 13622 | * Return: None |
| 13623 | */ |
| 13624 | static void __exit hdd_module_exit(void) |
| 13625 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13626 | hdd_driver_unload(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13627 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13628 | #else |
| 13629 | static void __exit hdd_module_exit(void) |
| 13630 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13631 | hdd_driver_unload(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13632 | wlan_deinit_sysfs(); |
| 13633 | } |
| 13634 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13635 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13636 | static int fwpath_changed_handler(const char *kmessage, |
| 13637 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13638 | { |
| 13639 | return param_set_copystring(kmessage, kp); |
| 13640 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13641 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13642 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
| 13643 | static bool is_monitor_mode_supported(void) |
| 13644 | { |
| 13645 | return true; |
| 13646 | } |
| 13647 | #else |
| 13648 | static bool is_monitor_mode_supported(void) |
| 13649 | { |
| 13650 | pr_err("Monitor mode not supported!"); |
| 13651 | return false; |
| 13652 | } |
| 13653 | #endif |
| 13654 | |
| 13655 | #ifdef WLAN_FEATURE_EPPING |
| 13656 | static bool is_epping_mode_supported(void) |
| 13657 | { |
| 13658 | return true; |
| 13659 | } |
| 13660 | #else |
| 13661 | static bool is_epping_mode_supported(void) |
| 13662 | { |
| 13663 | pr_err("Epping mode not supported!"); |
| 13664 | return false; |
| 13665 | } |
| 13666 | #endif |
| 13667 | |
Ryan Hsu | 6e9db0b | 2018-06-01 10:45:51 -0700 | [diff] [blame] | 13668 | #ifdef QCA_WIFI_FTM |
| 13669 | static bool is_ftm_mode_supported(void) |
| 13670 | { |
| 13671 | return true; |
| 13672 | } |
| 13673 | #else |
| 13674 | static bool is_ftm_mode_supported(void) |
| 13675 | { |
| 13676 | pr_err("FTM mode not supported!"); |
| 13677 | return false; |
| 13678 | } |
| 13679 | #endif |
| 13680 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13681 | /** |
| 13682 | * is_con_mode_valid() check con mode is valid or not |
| 13683 | * @mode: global con mode |
| 13684 | * |
| 13685 | * Return: TRUE on success FALSE on failure |
| 13686 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13687 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13688 | { |
| 13689 | switch (mode) { |
| 13690 | case QDF_GLOBAL_MONITOR_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13691 | return is_monitor_mode_supported(); |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13692 | case QDF_GLOBAL_EPPING_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13693 | return is_epping_mode_supported(); |
| 13694 | case QDF_GLOBAL_FTM_MODE: |
Ryan Hsu | 6e9db0b | 2018-06-01 10:45:51 -0700 | [diff] [blame] | 13695 | return is_ftm_mode_supported(); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13696 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13697 | return true; |
| 13698 | default: |
| 13699 | return false; |
| 13700 | } |
| 13701 | } |
| 13702 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13703 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13704 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13705 | { |
| 13706 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 13707 | return; |
| 13708 | |
| 13709 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13710 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 13711 | hdd_info("Release wakelock for monitor mode!"); |
| 13712 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 13713 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
Dundi Raviteja | 0a2a65b | 2018-04-30 12:34:11 +0530 | [diff] [blame] | 13714 | /* fallthrough */ |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 13715 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13716 | case QDF_GLOBAL_FTM_MODE: |
| 13717 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 13718 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 13719 | hdd_stop_all_adapters(hdd_ctx); |
Ashish Kumar Dhanotiya | 6ff329e | 2018-10-05 20:38:10 +0530 | [diff] [blame] | 13720 | hdd_deinit_all_adapters(hdd_ctx, false); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13721 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13722 | break; |
| 13723 | default: |
| 13724 | break; |
| 13725 | } |
| 13726 | } |
| 13727 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13728 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13729 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13730 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 13731 | int driver_status; |
| 13732 | |
| 13733 | driver_status = hdd_ctx->driver_status; |
| 13734 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13735 | switch (curr_mode) { |
| 13736 | case QDF_GLOBAL_MISSION_MODE: |
| 13737 | case QDF_GLOBAL_MONITOR_MODE: |
| 13738 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13739 | hdd_close_all_adapters(hdd_ctx, false); |
| 13740 | break; |
| 13741 | case QDF_GLOBAL_EPPING_MODE: |
| 13742 | epping_disable(); |
| 13743 | epping_close(); |
| 13744 | break; |
| 13745 | default: |
| 13746 | return; |
| 13747 | } |
| 13748 | } |
| 13749 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13750 | static int |
| 13751 | hdd_parse_driver_mode(const char *mode_str, enum QDF_GLOBAL_MODE *out_mode) |
| 13752 | { |
| 13753 | int mode; |
| 13754 | int errno; |
| 13755 | |
Dustin Brown | 62743f4 | 2018-10-24 14:53:18 -0700 | [diff] [blame] | 13756 | *out_mode = QDF_GLOBAL_MAX_MODE; |
| 13757 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13758 | errno = kstrtoint(mode_str, 0, &mode); |
| 13759 | if (!errno) |
| 13760 | *out_mode = (enum QDF_GLOBAL_MODE)mode; |
| 13761 | |
| 13762 | return errno; |
| 13763 | } |
| 13764 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13765 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13766 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13767 | * @kmessage: con mode name on which driver to be bring up |
| 13768 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13769 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13770 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13771 | * This function is invoked when user updates con mode using sys entry, |
| 13772 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13773 | * |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13774 | * Return: Errno |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13775 | */ |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13776 | static int __con_mode_handler(const char *kmessage, |
| 13777 | const struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13778 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13779 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13780 | enum QDF_GLOBAL_MODE curr_mode; |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13781 | enum QDF_GLOBAL_MODE next_mode; |
| 13782 | int errno; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13783 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13784 | hdd_info("Driver mode changing to %s", kmessage); |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 13785 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13786 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13787 | if (errno) |
| 13788 | return errno; |
| 13789 | |
| 13790 | errno = hdd_parse_driver_mode(kmessage, &next_mode); |
| 13791 | if (errno) { |
| 13792 | hdd_err_rl("Failed to parse driver mode '%s'", kmessage); |
| 13793 | return errno; |
| 13794 | } |
| 13795 | |
| 13796 | if (!is_con_mode_valid(next_mode)) { |
| 13797 | hdd_err_rl("Requested driver mode is invalid"); |
| 13798 | return -EINVAL; |
| 13799 | } |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13800 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13801 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13802 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13803 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13804 | curr_mode = hdd_get_conparam(); |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13805 | if (curr_mode == next_mode) { |
| 13806 | hdd_err_rl("Driver is already in the requested mode"); |
| 13807 | errno = 0; |
| 13808 | goto unlock; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 13809 | } |
| 13810 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 13811 | /* ensure adapters are stopped */ |
| 13812 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 13813 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13814 | errno = hdd_wlan_stop_modules(hdd_ctx, true); |
| 13815 | if (errno) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13816 | hdd_err("Stop wlan modules failed"); |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13817 | goto unlock; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13818 | } |
| 13819 | |
Dustin Brown | dd4e50f | 2018-05-24 15:43:42 -0700 | [diff] [blame] | 13820 | /* Cleanup present mode before switching to new mode */ |
| 13821 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 13822 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13823 | hdd_set_conparam(next_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13824 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13825 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 13826 | if (errno) { |
| 13827 | hdd_err("Start wlan modules failed: %d", errno); |
| 13828 | goto unlock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13829 | } |
| 13830 | |
jitiphil | 7af5cf2 | 2018-10-26 16:06:27 +0530 | [diff] [blame] | 13831 | errno = hdd_open_adapters_for_mode(hdd_ctx, next_mode); |
| 13832 | if (errno) { |
| 13833 | hdd_err("Failed to open adapters"); |
| 13834 | goto unlock; |
| 13835 | } |
| 13836 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13837 | if (next_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 13838 | struct hdd_adapter *adapter = |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13839 | hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 13840 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13841 | QDF_BUG(adapter); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 13842 | if (!adapter) { |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13843 | hdd_err("Failed to get monitor adapter"); |
| 13844 | goto unlock; |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 13845 | } |
| 13846 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13847 | errno = hdd_start_adapter(adapter); |
| 13848 | if (errno) { |
| 13849 | hdd_err("Failed to start monitor adapter"); |
| 13850 | goto unlock; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13851 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13852 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13853 | hdd_info("Acquire wakelock for monitor mode"); |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 13854 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 13855 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 13856 | } |
| 13857 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 13858 | /* con_mode is a global module parameter */ |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13859 | con_mode = next_mode; |
| 13860 | hdd_info("Driver mode successfully changed to %s", kmessage); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13861 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13862 | errno = 0; |
| 13863 | |
| 13864 | unlock: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13865 | mutex_unlock(&hdd_init_deinit_lock); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 13866 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13867 | |
Dustin Brown | c07ce8e | 2018-10-23 17:01:58 -0700 | [diff] [blame] | 13868 | return errno; |
| 13869 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13870 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13871 | 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] | 13872 | { |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13873 | struct hdd_driver *hdd_driver = hdd_driver_get(); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13874 | struct hdd_context *hdd_ctx; |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13875 | QDF_STATUS status; |
| 13876 | int errno; |
| 13877 | |
| 13878 | hdd_enter(); |
| 13879 | |
Dustin Brown | 13fa987 | 2018-11-13 10:57:45 -0800 | [diff] [blame] | 13880 | /* This handler will be invoked before module init when the wlan driver |
| 13881 | * is loaded using 'insmod wlan.ko con_mode=5' for example. Return |
| 13882 | * success in this case, as module init will bring up the correct |
| 13883 | * con_mode when it runs. |
| 13884 | */ |
| 13885 | if (hdd_driver->state == driver_state_uninit) |
| 13886 | return 0; |
| 13887 | |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13888 | status = dsc_driver_trans_start_wait(hdd_driver->dsc_driver, |
| 13889 | "mode change"); |
| 13890 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13891 | hdd_err("Failed to start 'mode change'; status:%u", status); |
| 13892 | errno = qdf_status_to_os_return(status); |
| 13893 | goto exit; |
| 13894 | } |
| 13895 | |
| 13896 | dsc_driver_wait_for_ops(hdd_driver->dsc_driver); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13897 | |
| 13898 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13899 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13900 | if (errno) |
| 13901 | goto trans_stop; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13902 | |
Ashish Kumar Dhanotiya | 759b327 | 2018-05-18 17:49:46 +0530 | [diff] [blame] | 13903 | if (!cds_wait_for_external_threads_completion(__func__)) { |
| 13904 | hdd_warn("External threads are still active, can not change mode"); |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13905 | errno = -EAGAIN; |
| 13906 | goto trans_stop; |
Ashish Kumar Dhanotiya | 759b327 | 2018-05-18 17:49:46 +0530 | [diff] [blame] | 13907 | } |
| 13908 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13909 | cds_ssr_protect(__func__); |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13910 | errno = __con_mode_handler(kmessage, kp, hdd_ctx); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 13911 | cds_ssr_unprotect(__func__); |
| 13912 | |
Dustin Brown | 67d3041 | 2018-09-20 12:10:22 -0700 | [diff] [blame] | 13913 | trans_stop: |
| 13914 | dsc_driver_trans_stop(hdd_driver->dsc_driver); |
| 13915 | |
| 13916 | exit: |
| 13917 | hdd_exit(); |
| 13918 | |
| 13919 | return errno; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13920 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13921 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13922 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13923 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13924 | { |
| 13925 | int ret; |
| 13926 | |
| 13927 | ret = param_set_int(kmessage, kp); |
| 13928 | |
| 13929 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 13930 | pr_err("Only FTM mode supported!"); |
| 13931 | return -ENOTSUPP; |
| 13932 | } |
| 13933 | |
| 13934 | hdd_set_conparam(con_mode_ftm); |
| 13935 | con_mode = con_mode_ftm; |
| 13936 | |
| 13937 | return ret; |
| 13938 | } |
| 13939 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13940 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13941 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13942 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13943 | { |
| 13944 | int ret; |
| 13945 | |
| 13946 | ret = param_set_int(kmessage, kp); |
| 13947 | |
| 13948 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 13949 | pr_err("Only Monitor mode supported!"); |
| 13950 | return -ENOTSUPP; |
| 13951 | } |
| 13952 | |
| 13953 | hdd_set_conparam(con_mode_monitor); |
| 13954 | con_mode = con_mode_monitor; |
| 13955 | |
| 13956 | return ret; |
| 13957 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 13958 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13959 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13960 | /** |
| 13961 | * hdd_get_conparam() - driver exit point |
| 13962 | * |
| 13963 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 13964 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13965 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13966 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13967 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13968 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13969 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13970 | } |
| 13971 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13972 | void hdd_set_conparam(int32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13973 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 13974 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13975 | } |
| 13976 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13977 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13978 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 13979 | * @hdd_ctx: HDD context |
| 13980 | * |
| 13981 | * Cleans up the pre cac interface, if it exists |
| 13982 | * |
| 13983 | * Return: None |
| 13984 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13985 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13986 | { |
| 13987 | uint8_t session_id; |
| 13988 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 13989 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13990 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13991 | 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] | 13992 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13993 | hdd_err("failed to get pre cac vdev id"); |
| 13994 | return; |
| 13995 | } |
| 13996 | |
| 13997 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 13998 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 13999 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14000 | return; |
| 14001 | } |
| 14002 | |
| 14003 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 14004 | wlan_hdd_sap_pre_cac_failure, |
| 14005 | (void *)precac_adapter); |
| 14006 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 14007 | |
| 14008 | } |
| 14009 | |
| 14010 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14011 | * hdd_update_ol_config - API to update ol configuration parameters |
| 14012 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14013 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14014 | * Return: void |
| 14015 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14016 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14017 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14018 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14019 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14020 | bool self_recovery = false; |
| 14021 | QDF_STATUS status; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14022 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14023 | if (!ol_ctx) |
| 14024 | return; |
| 14025 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14026 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14027 | if (QDF_IS_STATUS_ERROR(status)) |
| 14028 | hdd_err("Failed to get self recovery ini config"); |
| 14029 | |
| 14030 | cfg.enable_self_recovery = self_recovery; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14031 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 14032 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 14033 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 14034 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14035 | |
| 14036 | ol_init_ini_config(ol_ctx, &cfg); |
| 14037 | } |
| 14038 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14039 | #ifdef FEATURE_RUNTIME_PM |
| 14040 | /** |
| 14041 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 14042 | * @hdd_ctx: hdd context |
| 14043 | * @cfg: pointer to the configuration memory being populated |
| 14044 | * |
| 14045 | * Return: void |
| 14046 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14047 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14048 | struct hif_config_info *cfg) |
| 14049 | { |
| 14050 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14051 | cfg->runtime_pm_delay = |
| 14052 | ucfg_pmo_get_runtime_pm_delay(hdd_ctx->psoc); |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14053 | } |
| 14054 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14055 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14056 | struct hif_config_info *cfg) |
| 14057 | { |
| 14058 | } |
| 14059 | #endif |
| 14060 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14061 | /** |
| 14062 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 14063 | * @hdd_ctx: HDD Context |
| 14064 | * |
| 14065 | * Return: void |
| 14066 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14067 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14068 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14069 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14070 | struct hif_config_info cfg; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14071 | bool prevent_link_down = false; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14072 | bool self_recovery = false; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14073 | QDF_STATUS status; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14074 | |
| 14075 | if (!scn) |
| 14076 | return; |
| 14077 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14078 | status = ucfg_mlme_get_prevent_link_down(hdd_ctx->psoc, |
| 14079 | &prevent_link_down); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14080 | if (QDF_IS_STATUS_ERROR(status)) |
| 14081 | hdd_err("Failed to get prevent_link_down config"); |
| 14082 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14083 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14084 | if (QDF_IS_STATUS_ERROR(status)) |
| 14085 | hdd_err("Failed to get self recovery ini config"); |
| 14086 | |
| 14087 | cfg.enable_self_recovery = self_recovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14088 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14089 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14090 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14091 | if (prevent_link_down) |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14092 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14093 | } |
| 14094 | |
| 14095 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14096 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 14097 | * datapath |
| 14098 | * @hdd_ctx: HDD Context |
| 14099 | * |
| 14100 | * Return: 0 for success/errno for failure |
| 14101 | */ |
| 14102 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 14103 | { |
| 14104 | struct cdp_config_params params; |
| 14105 | QDF_STATUS status; |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14106 | void *soc; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14107 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14108 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 14109 | params.tso_enable = cfg_get(hdd_ctx->psoc, CFG_DP_TSO); |
| 14110 | 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] | 14111 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 14112 | params.tx_flow_stop_queue_threshold = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 14113 | 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] | 14114 | params.tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 14115 | cfg_get(hdd_ctx->psoc, |
| 14116 | CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14117 | #endif |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14118 | params.flow_steering_enable = |
| 14119 | cfg_get(hdd_ctx->psoc, CFG_DP_FLOW_STEERING_ENABLED); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14120 | params.napi_enable = hdd_ctx->napi_enable; |
| 14121 | params.tcp_udp_checksumoffload = |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14122 | cfg_get(hdd_ctx->psoc, |
| 14123 | CFG_DP_TCP_UDP_CKSUM_OFFLOAD); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14124 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14125 | status = cdp_update_config_parameters(soc, ¶ms); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14126 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 14127 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14128 | return status; |
| 14129 | } |
| 14130 | |
| 14131 | return 0; |
| 14132 | } |
| 14133 | |
| 14134 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14135 | * hdd_update_config() - Initialize driver per module ini parameters |
| 14136 | * @hdd_ctx: HDD Context |
| 14137 | * |
| 14138 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14139 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14140 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14141 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14142 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14143 | int ret; |
| 14144 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14145 | if (ucfg_pmo_is_ns_offloaded(hdd_ctx->psoc)) |
| 14146 | hdd_ctx->ns_offload_enable = true; |
| 14147 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14148 | hdd_update_ol_config(hdd_ctx); |
| 14149 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14150 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 14151 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 14152 | else |
| 14153 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 14154 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14155 | |
| 14156 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14157 | } |
| 14158 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14159 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 14160 | /** |
| 14161 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 14162 | * @psoc_cfg: pmo psoc Configuration |
| 14163 | * @hdd_ctx: Pointer to hdd context |
| 14164 | * |
| 14165 | * Return: none |
| 14166 | */ |
| 14167 | static inline void hdd_ra_populate_pmo_config( |
| 14168 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14169 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14170 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 14171 | bool is_rate_limit_enabled; |
| 14172 | QDF_STATUS status; |
| 14173 | |
| 14174 | status = ucfg_fwol_get_is_rate_limit_enabled(hdd_ctx->psoc, |
| 14175 | &is_rate_limit_enabled); |
| 14176 | if (QDF_IS_STATUS_ERROR(status)) |
| 14177 | return; |
| 14178 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14179 | psoc_cfg->ra_ratelimit_interval = |
| 14180 | hdd_ctx->config->RArateLimitInterval; |
| 14181 | psoc_cfg->ra_ratelimit_enable = |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 14182 | is_rate_limit_enabled; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14183 | } |
| 14184 | #else |
| 14185 | static inline void hdd_ra_populate_pmo_config( |
| 14186 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14187 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14188 | { |
| 14189 | } |
| 14190 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 14191 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14192 | /** |
| 14193 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 14194 | * @hdd_ctx: HDD context |
| 14195 | * |
| 14196 | * Return: void |
| 14197 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14198 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14199 | { |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14200 | struct pmo_psoc_cfg psoc_cfg; |
| 14201 | QDF_STATUS status; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14202 | enum pmo_wow_enable_type wow_enable; |
| 14203 | |
| 14204 | ucfg_pmo_get_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14205 | |
| 14206 | /* |
| 14207 | * Value of hdd_ctx->wowEnable can be, |
| 14208 | * 0 - Disable both magic pattern match and pattern byte match. |
| 14209 | * 1 - Enable magic pattern match on all interfaces. |
| 14210 | * 2 - Enable pattern byte match on all interfaces. |
| 14211 | * 3 - Enable both magic patter and pattern byte match on |
| 14212 | * all interfaces. |
| 14213 | */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14214 | wow_enable = ucfg_pmo_get_wow_enable(hdd_ctx->psoc); |
| 14215 | psoc_cfg.magic_ptrn_enable = (wow_enable & 0x01) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14216 | psoc_cfg.ptrn_match_enable_all_vdev = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14217 | (wow_enable & 0x02) ? true : false; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 14218 | psoc_cfg.packet_filter_enabled = !hdd_ctx->config->disablePacketFilter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14219 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 14220 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 14221 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 14222 | &psoc_cfg.sta_max_li_mod_dtim); |
| 14223 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14224 | |
| 14225 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 14226 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14227 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14228 | status = ucfg_pmo_update_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 14229 | if (QDF_IS_STATUS_ERROR(status)) |
| 14230 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 14231 | |
| 14232 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14233 | } |
| 14234 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14235 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 14236 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 14237 | struct hdd_context *hdd_ctx) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14238 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 14239 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 14240 | struct hdd_config *cfg = hdd_ctx->config; |
| 14241 | bool mawc_enabled; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 14242 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14243 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 14244 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 14245 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 14246 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 14247 | pno_cfg->channel_prediction_full_scan = |
| 14248 | cfg->channel_prediction_full_scan; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 14249 | |
| 14250 | ucfg_mlme_is_mawc_enabled(hdd_ctx->psoc, &mawc_enabled); |
| 14251 | mawc_cfg->enable = mawc_enabled && cfg->mawc_nlo_enabled; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 14252 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 14253 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 14254 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14255 | } |
| 14256 | #else |
| 14257 | static inline void |
| 14258 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 14259 | struct hdd_context *hdd_ctx) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14260 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14261 | } |
| 14262 | #endif |
| 14263 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14264 | 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] | 14265 | struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14266 | { |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14267 | struct wlan_fwol_ie_whitelist whitelist = {0}; |
| 14268 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14269 | QDF_STATUS status; |
| 14270 | bool is_ie_whitelist_enable = false; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14271 | uint8_t i = 0; |
| 14272 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14273 | status = ucfg_fwol_get_ie_whitelist(psoc, &is_ie_whitelist_enable); |
| 14274 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14275 | hdd_err("Unable to get IE whitelist param"); |
| 14276 | return; |
| 14277 | } |
| 14278 | |
| 14279 | ie_whitelist->white_list = is_ie_whitelist_enable; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14280 | if (!ie_whitelist->white_list) |
| 14281 | return; |
| 14282 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14283 | status = ucfg_fwol_get_all_whitelist_params(psoc, &whitelist); |
| 14284 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14285 | hdd_err("Unable to get all whitelist params"); |
| 14286 | return; |
| 14287 | } |
| 14288 | |
| 14289 | ie_whitelist->ie_bitmap[0] = whitelist.ie_bitmap_0; |
| 14290 | ie_whitelist->ie_bitmap[1] = whitelist.ie_bitmap_1; |
| 14291 | ie_whitelist->ie_bitmap[2] = whitelist.ie_bitmap_2; |
| 14292 | ie_whitelist->ie_bitmap[3] = whitelist.ie_bitmap_3; |
| 14293 | ie_whitelist->ie_bitmap[4] = whitelist.ie_bitmap_4; |
| 14294 | ie_whitelist->ie_bitmap[5] = whitelist.ie_bitmap_5; |
| 14295 | ie_whitelist->ie_bitmap[6] = whitelist.ie_bitmap_6; |
| 14296 | ie_whitelist->ie_bitmap[7] = whitelist.ie_bitmap_7; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14297 | |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14298 | ie_whitelist->num_vendor_oui = whitelist.no_of_probe_req_ouis; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14299 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14300 | ie_whitelist->voui[i] = whitelist.probe_req_voui[i]; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14301 | } |
| 14302 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14303 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 14304 | { |
| 14305 | uint8_t i, score; |
| 14306 | |
| 14307 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 14308 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 14309 | if (score > MAX_INDEX_SCORE) |
| 14310 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 14311 | MAX_INDEX_SCORE, i); |
| 14312 | } |
| 14313 | |
| 14314 | return per_index_score; |
| 14315 | } |
| 14316 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14317 | QDF_STATUS hdd_update_score_config( |
| 14318 | struct scoring_config *score_config, struct hdd_context *hdd_ctx) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14319 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14320 | struct hdd_config *cfg = hdd_ctx->config; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14321 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14322 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14323 | bool bval = false; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14324 | |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14325 | /* Populate the nss chain params from ini for this vdev type */ |
| 14326 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 14327 | QDF_STA_MODE, |
| 14328 | hdd_ctx->num_rf_chains); |
| 14329 | |
| 14330 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]; |
| 14331 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]; |
| 14332 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14333 | sme_update_score_config(hdd_ctx->mac_handle, score_config); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14334 | |
| 14335 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 14336 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14337 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14338 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 14339 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 14340 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 14341 | score_config->he_cap = 1; |
| 14342 | |
| 14343 | if (score_config->he_cap || |
| 14344 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 14345 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 14346 | score_config->vht_cap = 1; |
| 14347 | |
| 14348 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 14349 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 14350 | score_config->ht_cap = 1; |
| 14351 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14352 | status = ucfg_mlme_get_vht_for_24ghz(hdd_ctx->psoc, &bval); |
| 14353 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14354 | hdd_err("Failed to get vht_for_24ghz"); |
| 14355 | if (score_config->vht_cap && bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14356 | score_config->vht_24G_cap = 1; |
| 14357 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14358 | status = ucfg_mlme_get_vht_enable_tx_bf(hdd_ctx->psoc, |
| 14359 | &bval); |
| 14360 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14361 | hdd_err("unable to get vht_enable_tx_bf"); |
| 14362 | |
| 14363 | if (bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14364 | score_config->beamformee_cap = 1; |
| 14365 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14366 | return QDF_STATUS_SUCCESS; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14367 | } |
| 14368 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14369 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14370 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 14371 | * @hdd_ctx: HDD context |
| 14372 | * |
| 14373 | * Return: 0 if success else err |
| 14374 | */ |
| 14375 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 14376 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14377 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14378 | struct dfs_user_config dfs_cfg; |
| 14379 | QDF_STATUS status; |
| 14380 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 14381 | ucfg_mlme_get_dfs_filter_offload(hdd_ctx->psoc, |
| 14382 | &dfs_cfg.dfs_is_phyerr_filter_offload); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14383 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 14384 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14385 | hdd_err("failed dfs psoc configuration"); |
| 14386 | return -EINVAL; |
| 14387 | } |
| 14388 | |
| 14389 | return 0; |
| 14390 | } |
| 14391 | |
| 14392 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14393 | * hdd_update_scan_config - API to update scan configuration parameters |
| 14394 | * @hdd_ctx: HDD context |
| 14395 | * |
| 14396 | * Return: 0 if success else err |
| 14397 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14398 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14399 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14400 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14401 | struct scan_user_cfg scan_cfg; |
| 14402 | struct hdd_config *cfg = hdd_ctx->config; |
| 14403 | QDF_STATUS status; |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 14404 | uint8_t scan_bucket_thre; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14405 | uint8_t select_5ghz_margin; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 14406 | bool roam_prefer_5ghz; |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14407 | uint32_t mcast_mcc_rest_time = 0; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14408 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14409 | status = ucfg_mlme_get_select_5ghz_margin(hdd_ctx->psoc, |
| 14410 | &select_5ghz_margin); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14411 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14412 | hdd_err("Failed to get select_5ghz_margin"); |
| 14413 | return -EIO; |
| 14414 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14415 | |
| 14416 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 14417 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 14418 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 14419 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 14420 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 14421 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 14422 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 14423 | /* convert to ms */ |
| 14424 | scan_cfg.scan_cache_aging_time = |
| 14425 | cfg->scanAgingTimeout * 1000; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 14426 | ucfg_mlme_is_roam_prefer_5ghz(hdd_ctx->psoc, &roam_prefer_5ghz); |
| 14427 | scan_cfg.prefer_5ghz = (uint32_t)roam_prefer_5ghz; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14428 | scan_cfg.select_5ghz_margin = select_5ghz_margin; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14429 | ucfg_mlme_get_first_scan_bucket_threshold(hdd_ctx->psoc, |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 14430 | &scan_bucket_thre); |
| 14431 | scan_cfg.scan_bucket_threshold = (int32_t)scan_bucket_thre; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 14432 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14433 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 14434 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 14435 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 14436 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 14437 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 14438 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14439 | status = ucfg_mlme_get_sta_miracast_mcc_rest_time(hdd_ctx->psoc, |
| 14440 | &mcast_mcc_rest_time); |
| 14441 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14442 | hdd_err("ucfg_mlme_get_sta_miracast_mcc_rest_time, use def"); |
| 14443 | return -EIO; |
| 14444 | } |
| 14445 | scan_cfg.sta_miracast_mcc_rest_time = mcast_mcc_rest_time; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 14446 | hdd_update_pno_config(&scan_cfg.pno_cfg, hdd_ctx); |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14447 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14448 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14449 | status = hdd_update_score_config(&scan_cfg.score_config, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14450 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14451 | hdd_err("Failed to update scoring config"); |
| 14452 | return -EINVAL; |
| 14453 | } |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14454 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14455 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 14456 | if (status != QDF_STATUS_SUCCESS) { |
| 14457 | hdd_err("failed pmo psoc configuration"); |
| 14458 | return -EINVAL; |
| 14459 | } |
Liangwei Dong | ac3ddde | 2018-09-10 23:25:12 -0400 | [diff] [blame] | 14460 | ucfg_scan_set_global_config( |
| 14461 | psoc, SCAN_CFG_DROP_BCN_ON_CHANNEL_MISMATCH, |
| 14462 | cfg_get(psoc, CFG_DROP_BCN_ON_CHANNEL_MISMATCH)); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14463 | |
| 14464 | return 0; |
| 14465 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14466 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14467 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14468 | { |
| 14469 | int ret; |
| 14470 | |
| 14471 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14472 | if (ret) |
| 14473 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14474 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14475 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14476 | if (ret) |
| 14477 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14478 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14479 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14480 | if (ret) |
| 14481 | return ret; |
| 14482 | |
| 14483 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14484 | if (ret) |
| 14485 | return ret; |
| 14486 | |
| 14487 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14488 | |
| 14489 | return ret; |
| 14490 | } |
| 14491 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14492 | /** |
| 14493 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 14494 | * @mode : cfg80211 DFS mode |
| 14495 | * |
| 14496 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 14497 | */ |
| 14498 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 14499 | { |
| 14500 | switch (mode) { |
| 14501 | case DFS_MODE_ENABLE: |
| 14502 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14503 | case DFS_MODE_DISABLE: |
| 14504 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14505 | case DFS_MODE_DEPRIORITIZE: |
| 14506 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14507 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14508 | hdd_debug("ACS dfs mode is NONE"); |
| 14509 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14510 | } |
| 14511 | } |
| 14512 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14513 | /** |
| 14514 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 14515 | * @hddctx: pointer to hdd context |
| 14516 | * @set_value: enable/disable |
| 14517 | * |
| 14518 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 14519 | * Host(even though it is duplicate). When Host send vendor command |
| 14520 | * disable,FW doesn't perform any action. Whenever any change in |
| 14521 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 14522 | * |
| 14523 | * return - 0 on success, appropriate error values on failure. |
| 14524 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14525 | 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] | 14526 | { |
| 14527 | QDF_STATUS status; |
| 14528 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14529 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14530 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14531 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14532 | status = sme_enable_disable_chanavoidind_event(hdd_ctx->mac_handle, |
| 14533 | set_value); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14534 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14535 | hdd_err("Failed to send chan avoid command to SME"); |
| 14536 | return -EINVAL; |
| 14537 | } |
| 14538 | return 0; |
| 14539 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14540 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14541 | /** |
| 14542 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 14543 | * @value: value to set |
| 14544 | * |
| 14545 | * This function will set the passed value to roaming in progress flag. |
| 14546 | * |
| 14547 | * Return: None |
| 14548 | */ |
| 14549 | void hdd_set_roaming_in_progress(bool value) |
| 14550 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14551 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14552 | |
| 14553 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14554 | if (!hdd_ctx) { |
| 14555 | hdd_err("HDD context is NULL"); |
| 14556 | return; |
| 14557 | } |
| 14558 | |
| 14559 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14560 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14561 | } |
| 14562 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14563 | bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14564 | { |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14565 | if (!hdd_ctx) { |
| 14566 | hdd_err("HDD context is NULL"); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14567 | return false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14568 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 14569 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14570 | hdd_debug("roaming_in_progress = %d", hdd_ctx->roaming_in_progress); |
| 14571 | |
| 14572 | return hdd_ctx->roaming_in_progress; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14573 | } |
| 14574 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14575 | /** |
| 14576 | * hdd_is_connection_in_progress() - check if connection is in |
| 14577 | * progress |
| 14578 | * @session_id: session id |
| 14579 | * @reason: scan reject reason |
| 14580 | * |
| 14581 | * Go through each adapter and check if Connection is in progress |
| 14582 | * |
| 14583 | * Return: true if connection is in progress else false |
| 14584 | */ |
| 14585 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 14586 | enum scan_reject_states *reason) |
| 14587 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 14588 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14589 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14590 | uint8_t sta_id = 0; |
| 14591 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14592 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14593 | mac_handle_t mac_handle; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14594 | |
| 14595 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14596 | if (!hdd_ctx) { |
| 14597 | hdd_err("HDD context is NULL"); |
| 14598 | return false; |
| 14599 | } |
| 14600 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14601 | mac_handle = hdd_ctx->mac_handle; |
| 14602 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14603 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 929afa4 | 2018-06-01 15:04:44 -0700 | [diff] [blame] | 14604 | hdd_debug("Adapter with device mode %s(%d) exists", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 14605 | qdf_opmode_str(adapter->device_mode), |
| 14606 | adapter->device_mode); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14607 | if (((QDF_STA_MODE == adapter->device_mode) |
| 14608 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 14609 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 14610 | && (eConnectionState_Connecting == |
| 14611 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 14612 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14613 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14614 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14615 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14616 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14617 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14618 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14619 | } |
| 14620 | return true; |
| 14621 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 14622 | /* |
| 14623 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 14624 | * hdd_is_roaming_in_progress is for LFR3 |
| 14625 | */ |
| 14626 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 14627 | sme_neighbor_middle_of_roaming( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14628 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14629 | adapter->session_id)) || |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14630 | hdd_is_roaming_in_progress(hdd_ctx)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14631 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14632 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14633 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14634 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14635 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14636 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14637 | } |
| 14638 | return true; |
| 14639 | } |
| 14640 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 14641 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 14642 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 14643 | hdd_sta_ctx = |
| 14644 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 14645 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 14646 | hdd_sta_ctx->conn_info.connState) |
| 14647 | && sme_is_sta_key_exchange_in_progress( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14648 | mac_handle, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14649 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 14650 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14651 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14652 | " is in middle of WPS/EAPOL exchange.", |
| 14653 | MAC_ADDR_ARRAY(sta_mac)); |
| 14654 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14655 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14656 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14657 | } |
| 14658 | return true; |
| 14659 | } |
| 14660 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 14661 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 14662 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 14663 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14664 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14665 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14666 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14667 | continue; |
| 14668 | |
| 14669 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14670 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 14671 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14672 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14673 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 14674 | MAC_ADDR_ARRAY(sta_mac)); |
| 14675 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14676 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14677 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14678 | } |
| 14679 | return true; |
| 14680 | } |
| 14681 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14682 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14683 | return true; |
| 14684 | } |
| 14685 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14686 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14687 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14688 | return false; |
| 14689 | } |
| 14690 | |
| 14691 | /** |
| 14692 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14693 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14694 | * |
| 14695 | * Return: None |
| 14696 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14697 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14698 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 14699 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 14700 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14701 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14702 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 14703 | tsap_config_t *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14704 | void *sap_ctx; |
| 14705 | |
| 14706 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 14707 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 14708 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14709 | |
| 14710 | mutex_lock(&hdd_ctx->sap_lock); |
| 14711 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 14712 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14713 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 14714 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 14715 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 14716 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14717 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14718 | qdf_stop_bss_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 14719 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14720 | |
| 14721 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14722 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14723 | goto end; |
| 14724 | } |
| 14725 | } |
| 14726 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14727 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14728 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14729 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14730 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14731 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14732 | |
| 14733 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14734 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14735 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14736 | eUPDATE_IE_ALL); |
| 14737 | goto end; |
| 14738 | } |
| 14739 | |
| 14740 | qdf_event_reset(&hostapd_state->qdf_event); |
| 14741 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 14742 | sap_config, |
| 14743 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14744 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14745 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14746 | eUPDATE_IE_ALL); |
| 14747 | goto end; |
| 14748 | } |
| 14749 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14750 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14751 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14752 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Vignesh Viswanathan | 865daaa | 2018-10-11 19:30:44 +0530 | [diff] [blame] | 14753 | SME_CMD_START_STOP_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14754 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14755 | eUPDATE_IE_ALL); |
| 14756 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14757 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14758 | goto end; |
| 14759 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14760 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14761 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14762 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14763 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14764 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14765 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14766 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14767 | ap_adapter->device_mode, |
| 14768 | true); |
| 14769 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14770 | } |
| 14771 | end: |
| 14772 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14773 | } |
| 14774 | |
| 14775 | /** |
| 14776 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 14777 | * with non dfs acs |
| 14778 | * |
| 14779 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 14780 | * |
| 14781 | * Return: None |
| 14782 | */ |
| 14783 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 14784 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14785 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14786 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 14787 | struct cds_context *cds_ctx; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14788 | uint8_t restart_chan; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14789 | |
| 14790 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14791 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14792 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14793 | return; |
| 14794 | } |
| 14795 | |
| 14796 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 14797 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14798 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14799 | return; |
| 14800 | } |
| 14801 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14802 | if (policy_mgr_get_concurrency_mode(hdd_ctx->psoc) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14803 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 14804 | hdd_debug("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14805 | return; |
| 14806 | } |
| 14807 | |
| 14808 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14809 | if (ap_adapter && |
| 14810 | test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags) && |
| 14811 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, |
| 14812 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14813 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14814 | 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] | 14815 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14816 | restart_chan = |
| 14817 | hdd_get_safe_channel_from_pcl_and_acs_range(ap_adapter); |
| 14818 | if (!restart_chan || |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14819 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, restart_chan)) |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14820 | restart_chan = SAP_DEFAULT_5GHZ_CHANNEL; |
| 14821 | |
| 14822 | hdd_switch_sap_channel(ap_adapter, restart_chan, true); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14823 | } |
| 14824 | } |
| 14825 | |
| 14826 | /** |
| 14827 | * hdd_set_connection_in_progress() - to set the connection in |
| 14828 | * progress flag |
| 14829 | * @value: value to set |
| 14830 | * |
| 14831 | * This function will set the passed value to connection in progress flag. |
| 14832 | * If value is previously being set to true then no need to set it again. |
| 14833 | * |
| 14834 | * Return: true if value is being set correctly and false otherwise. |
| 14835 | */ |
| 14836 | bool hdd_set_connection_in_progress(bool value) |
| 14837 | { |
| 14838 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14839 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14840 | |
| 14841 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14842 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14843 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14844 | return false; |
| 14845 | } |
| 14846 | |
| 14847 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 14848 | /* |
| 14849 | * if the value is set to true previously and if someone is |
| 14850 | * trying to make it true again then it could be some race |
| 14851 | * condition being triggered. Avoid this situation by returning |
| 14852 | * false |
| 14853 | */ |
| 14854 | if (hdd_ctx->connection_in_progress && value) |
| 14855 | status = false; |
| 14856 | else |
| 14857 | hdd_ctx->connection_in_progress = value; |
| 14858 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 14859 | return status; |
| 14860 | } |
| 14861 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14862 | 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] | 14863 | { |
| 14864 | if (!adapter) { |
| 14865 | hdd_err("Invalid adapter"); |
| 14866 | return -EINVAL; |
| 14867 | } |
| 14868 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14869 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14870 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 14871 | set_value, VDEV_CMD); |
| 14872 | return 0; |
| 14873 | |
| 14874 | } |
| 14875 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14876 | 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] | 14877 | { |
| 14878 | if (!adapter) { |
| 14879 | hdd_err("Invalid adapter"); |
| 14880 | return -EINVAL; |
| 14881 | } |
| 14882 | |
| 14883 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 14884 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14885 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 14886 | set_value, VDEV_CMD); |
| 14887 | return 0; |
| 14888 | } |
| 14889 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14890 | 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] | 14891 | *psoc, uint8_t vdev_id) |
| 14892 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14893 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14894 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 14895 | |
| 14896 | /* |
| 14897 | * Currently PSOC is not being used. But this logic will |
| 14898 | * change once we have the converged implementation of |
| 14899 | * HDD context per PSOC in place. This would break if |
| 14900 | * multiple vdev objects reuse the vdev id. |
| 14901 | */ |
| 14902 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 14903 | if (!adapter) |
| 14904 | hdd_err("Get adapter by vdev id failed"); |
| 14905 | |
| 14906 | return adapter; |
| 14907 | } |
| 14908 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14909 | 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] | 14910 | int8_t *rssi, int8_t *snr) |
| 14911 | { |
| 14912 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14913 | mac_handle_t mac_handle; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14914 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14915 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14916 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14917 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 14918 | status = sme_get_rssi_snr_by_bssid(mac_handle, |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14919 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14920 | if (QDF_STATUS_SUCCESS != status) { |
| 14921 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 14922 | return -EINVAL; |
| 14923 | } |
| 14924 | |
| 14925 | return 0; |
| 14926 | } |
| 14927 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14928 | /** |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14929 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 14930 | * @adapter - HDD adapter |
| 14931 | * |
| 14932 | * Return: 0 on success and non zero value on failure |
| 14933 | */ |
| 14934 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 14935 | { |
| 14936 | struct hdd_context *hdd_ctx; |
| 14937 | int ret; |
| 14938 | QDF_STATUS status; |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14939 | uint8_t sys_pref = 0; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14940 | |
| 14941 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 14942 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14943 | if (ret < 0) |
| 14944 | return ret; |
| 14945 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14946 | ucfg_policy_mgr_get_sys_pref(hdd_ctx->psoc, |
| 14947 | &sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14948 | /* set the system preferece to default */ |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 14949 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->psoc, sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14950 | |
| 14951 | /* clear the bitmap */ |
| 14952 | adapter->active_ac = 0; |
| 14953 | |
| 14954 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14955 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14956 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14957 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
| 14958 | adapter->session_id, |
| 14959 | false, 0, 0, false); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14960 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14961 | hdd_err("failed to reset limit off chan params"); |
| 14962 | ret = -EINVAL; |
| 14963 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14964 | |
| 14965 | return ret; |
| 14966 | } |
| 14967 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14968 | /** |
| 14969 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 14970 | * @drv_op: Enum indicating driver op |
| 14971 | * |
| 14972 | * Return: none |
| 14973 | */ |
| 14974 | void hdd_start_driver_ops_timer(int drv_op) |
| 14975 | { |
| 14976 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 14977 | switch (drv_op) { |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 14978 | case HDD_DRV_OP_PROBE: |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14979 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 14980 | break; |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 14981 | case HDD_DRV_OP_REMOVE: |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14982 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 14983 | break; |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 14984 | case HDD_DRV_OP_SHUTDOWN: |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14985 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 14986 | break; |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 14987 | case HDD_DRV_OP_REINIT: |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14988 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 14989 | break; |
Jeff Johnson | 5794d4f | 2018-12-04 11:57:09 -0800 | [diff] [blame] | 14990 | case HDD_DRV_OP_IFF_UP: |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 14991 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 14992 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14993 | } |
| 14994 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 14995 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14996 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
Dustin Brown | cfc54fe | 2018-06-18 16:17:41 -0700 | [diff] [blame] | 14997 | HDD_OPS_INACTIVITY_TIMEOUT * qdf_timer_get_multiplier()); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14998 | } |
| 14999 | |
| 15000 | /** |
| 15001 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 15002 | * |
| 15003 | * Return: none |
| 15004 | */ |
| 15005 | void hdd_stop_driver_ops_timer(void) |
| 15006 | { |
| 15007 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 15008 | } |
| 15009 | |
| 15010 | /** |
| 15011 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 15012 | * inactivity timer |
| 15013 | * |
| 15014 | * Return: None |
| 15015 | */ |
| 15016 | void hdd_drv_ops_inactivity_handler(void) |
| 15017 | { |
Rajeev Kumar | 4471f1b | 2018-06-08 14:18:28 -0700 | [diff] [blame] | 15018 | 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] | 15019 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 15020 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 15021 | if (hdd_drv_ops_task) { |
| 15022 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 15023 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 15024 | } else { |
| 15025 | hdd_err("hdd_drv_ops_task is null"); |
| 15026 | } |
| 15027 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15028 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 15029 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 15030 | sizeof("shutdown"))) |
| 15031 | QDF_BUG(0); |
| 15032 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 15033 | if (cds_is_fw_down()) { |
| 15034 | hdd_err("FW is down"); |
| 15035 | return; |
| 15036 | } |
| 15037 | |
Dustin Brown | 83044c2 | 2018-08-13 15:00:44 -0700 | [diff] [blame] | 15038 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 15039 | } |
| 15040 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15041 | /** |
| 15042 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 15043 | * @struct hdd_context *hdd_ctx |
| 15044 | * @struct hdd_adapter *padapter |
| 15045 | * @bool enble |
| 15046 | * |
| 15047 | * Return: none |
| 15048 | */ |
| 15049 | void hdd_set_rx_mode_rps(bool enable) |
| 15050 | { |
| 15051 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 15052 | struct hdd_context *hdd_ctx; |
| 15053 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15054 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 15055 | if (!cds_cfg) |
| 15056 | return; |
| 15057 | |
| 15058 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 15059 | if (!hdd_ctx) |
| 15060 | return; |
| 15061 | |
| 15062 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 15063 | if (!adapter) |
| 15064 | return; |
| 15065 | |
| 15066 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15067 | if (enable && !cds_cfg->rps_enabled) |
| 15068 | hdd_send_rps_ind(adapter); |
| 15069 | else if (!enable && cds_cfg->rps_enabled) |
| 15070 | hdd_send_rps_disable_ind(adapter); |
| 15071 | } |
| 15072 | } |
| 15073 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15074 | /* Register the module init/exit functions */ |
| 15075 | module_init(hdd_module_init); |
| 15076 | module_exit(hdd_module_exit); |
| 15077 | |
| 15078 | MODULE_LICENSE("Dual BSD/GPL"); |
| 15079 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 15080 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 15081 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15082 | static const struct kernel_param_ops con_mode_ops = { |
| 15083 | .set = con_mode_handler, |
| 15084 | .get = param_get_int, |
| 15085 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15086 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15087 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 15088 | .set = con_mode_handler_ftm, |
| 15089 | .get = param_get_int, |
| 15090 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 15091 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15092 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15093 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 15094 | .set = con_mode_handler_monitor, |
| 15095 | .get = param_get_int, |
| 15096 | }; |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15097 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 15098 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15099 | static const struct kernel_param_ops fwpath_ops = { |
| 15100 | .set = fwpath_changed_handler, |
| 15101 | .get = param_get_string, |
| 15102 | }; |
| 15103 | |
| 15104 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 15105 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15106 | |
| 15107 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 15108 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15109 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15110 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15111 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 15112 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15113 | #endif |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15114 | |
| 15115 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 15116 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15117 | |
| 15118 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15119 | |
| 15120 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15121 | |
| 15122 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |